Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 13,972 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 5 1 2 3 4 5
Re: Normalmapping on terrain [Re: xXxGuitar511] #122336
04/10/07 04:36
04/10/07 04:36
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Alright... I've found the problem is the tangent. it's always at 0...


I'm just screwin around and trying different things till I find a solution...


xXxGuitar511
- Programmer
Re: Normalmapping on terrain [Re: xXxGuitar511] #122337
04/10/07 04:42
04/10/07 04:42
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
have I ever told you that you're a genious Excessus? lol, cause you are!

Quote:


EDIT3:
Ok, I can calculate the tangent and binormal from the normal on a terrain. This works on a model terrain, but when I use it on a terrain, I get the SAME tangents as when I use the tangent flag.. Seems like the problem is related to the normals then..
worldToTangentSpace[0] = cross(InNorm, float3(0.0f, 0.0f, 1.0f));
worldToTangentSpace[1] = cross(worldToTangentSpace[0], InNorm);
worldToTangentSpace[2] = InNorm;





Worked PERFECTLY!


I'm gonna finish adding the special touches to the shader now!


xXxGuitar511
- Programmer
Re: Normalmapping on terrain [Re: xXxGuitar511] #122338
04/10/07 06:59
04/10/07 06:59
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Quote:

Ok, I can calculate the tangent and binormal from the normal on a terrain. This works on a model terrain, but when I use it on a terrain, I get the SAME tangents as when I use the tangent flag.. Seems like the problem is related to the normals then..
worldToTangentSpace[0] = cross(InNorm, float3(0.0f, 0.0f, 1.0f));
worldToTangentSpace[1] = cross(worldToTangentSpace[0], InNorm);
worldToTangentSpace[2] = InNorm;





While I'm not clear on why this works, usually tangents must be calculated by taking the texture coords of nearby vertices into account, even on a terrain this ought to apply.. but if it works I guess it dosent matter

Quote:

I would advise you to use the above way of calculating the tangent and not use the tangent flag, because it is faster on the GPU. Ofcourse it only works for terrains.




This is most certainly not faster than using the tangents calculated by the engine.. why would you think that? Tangents are calculated once only, not every frame...otherwise it would be super slow..


Sphere Engine--the premier A6 graphics plugin.
Re: Normalmapping on terrain [Re: Matt_Aufderheide] #122339
04/10/07 07:05
04/10/07 07:05
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Thanks for the input Matt. here's my results:


with the above code for tangents, the shader works perfectly.

using the same worldToTangentSpace method, but using the tangent input, the tangent is always 0. I guess i could try the other thing Excessus mentioned, ent_fixnormals()...


xXxGuitar511
- Programmer
Re: Normalmapping on terrain [Re: xXxGuitar511] #122340
04/10/07 07:31
04/10/07 07:31
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline OP
Expert
Excessus  Offline OP
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Quote:

This is most certainly not faster than using the tangents calculated by the engine.. why would you think that? Tangents are calculated once only, not every frame...otherwise it would be super slow.



Oh yes, ofcourse.. I was thinking about this quote of the manual, but ofcourse it only applies to animated models and certainly not terrains or static entities:
Quote:

On animated models the tangents have to be recalculated every frame, affecting the frame rate, so don't use this flag unnecessarily.




The reason it works is that with terrains, you know the texture coords of nearby vertices since it's a regular grid (also on the uv map).

I find it strange that you get tangents set to 0.. What version are you using, xXxGuitar? From my tests I did get correct tangents for terrains in 6.50.. The ent_fixnormals, I think, just solved a problem with an old .mdl format in the 6.50 engine.

Re: Normalmapping on terrain [Re: Excessus] #122341
04/10/07 15:46
04/10/07 15:46
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Latest public beta, A6.50.6

I'm not sure if I got 0, but It seemed like so...

I also need to create a terrain with one large normal map for testing.


BTW: I used:
4 terrains, with 4802 faces each
3 tiled diffuse textures
3 tiled normal maps
1 large normal map overlay
spec lighting
- usable framerate.

It didn't slow down near as much as I thought it would.

I'll post the shader later today. You can all mess with the tangents, and tell me what I did wrong, ...


xXxGuitar511
- Programmer
Re: Normalmapping on terrain [Re: Excessus] #122342
04/10/07 17:14
04/10/07 17:14
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Quote:

Haven't looked at it thouroughly, but I think this is wrong:
float3 inTangent : TANGENT,

The engine only passes tangents on TEXCOORD2, AFAIK.




Jcl said it works in the 'latest engine' though, I haven't got it to work though. Not sure if he meant the latest beta or the A7 pre-release (should be the same version afaik btw.)

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Normalmapping on terrain [Re: PHeMoX] #122343
04/10/07 18:26
04/10/07 18:26
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
So what would that look like in the shader then?

struct VS_IN
{
float4 inPos : POSITION;
float2 inTex : TEXCOORD0;
float3 inTangent : TEXCOORD2;
};


xXxGuitar511
- Programmer
Re: Normalmapping on terrain [Re: xXxGuitar511] #122344
04/10/07 18:28
04/10/07 18:28
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
besides, the regular tangent input worked in the NM shader I posted.

float3 inTangent : TANGENT;


I'm even using a model for my terrain. So why wouldn't it work?


xXxGuitar511
- Programmer
Re: Normalmapping on terrain [Re: xXxGuitar511] #122345
04/10/07 20:32
04/10/07 20:32
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Edit: all shaders I've got now have;

Quote:


struct VS_INPUT_STRUCT

{

float4 position : POSITION;

float3 normal : NORMAL;

float3 texcoord0 : TEXCOORD0;

float3 tangent : TEXCOORD2;

};





This does work, but not with TANGENT

Cheers

Last edited by PHeMoX; 04/10/07 20:38.

PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Page 3 of 5 1 2 3 4 5

Moderated by  Blink, Hummel, Superku 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1