Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, Power_P), 1,065 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
strange thing. maybe i forgot something #74236
05/15/06 06:18
05/15/06 06:18
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
but, mul (normals, matWorld) doesnt work like i expected it to. only at world coordinates (0,0,0) it looks right. i remember there was a thing about twisted xyz coordinate, but i dont exactly know it anymore.

or what else is wrong ?

Re: strange thing. maybe i forgot something [Re: ello] #74237
05/15/06 07:47
05/15/06 07:47
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
hmm..
mul(inNormal,matWorld) ought to work in the general case

Maybe you arent inputing your normals correctly? Or your light vector is not in world space or being derived correctly?

Show your shader code and i can look at it.. maybe can figure it out


Sphere Engine--the premier A6 graphics plugin.
Re: strange thing. maybe i forgot something [Re: Matt_Aufderheide] #74238
05/15/06 08:20
05/15/06 08:20
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
i am not even doing some lighting here. i just want the normals in worldspace to be displaced so they dont rotate with the objects.

Code:

float4x4 matWorldViewProj;
float4x4 matWorld;

struct vsIn
{
float4 position : POSITION;
float4 normal : NORMAL;
};

struct vsOut
{
float4 position : POSITION;
float4 normal : TEXCOORD0;
};

vsOut mainVS (vsIn In)
{
vsOut Out;
Out.position = mul(In.position,matWorldViewProj);
Out.normal = mul(In.normal,matWorld);
return Out;
}

float4 mainPS (vsOut In) : COLOR
{
return In.normal;
}

technique normals
{
pass p0
{
CullMode = CCW;
VertexShader = compile vs_2_0 mainVS();
PixelShader = compile ps_2_0 mainPS();
}
}



here is an image with untransposed normals, you see the rotated figure which of course has unfitting normals for the overall scene:


and here with transposed normals, i really dont get it:


Re: strange thing. maybe i forgot something [Re: ello] #74239
05/15/06 13:02
05/15/06 13:02
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
try using saturate? or multiplying the color by some bias factor like 0.1 or something.. it looks to me like your normal colors are just too overbright (not between 0-1).

Or try renormalizing your normals after you multiply with matWorld (shouldnt need to)


Sphere Engine--the premier A6 graphics plugin.
Re: strange thing. maybe i forgot something [Re: Matt_Aufderheide] #74240
05/15/06 13:23
05/15/06 13:23
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
hm, that doesnt give the wanted results, too

normalized:


and saturated:


Re: strange thing. maybe i forgot something [Re: ello] #74241
05/15/06 13:39
05/15/06 13:39
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
I dont see why this isnt working.. what shader verison is this compiled to? You wouldn't happen to be using 3.0 are you?

I have had problems with 3.0 with things like this...it changes some things i dont quite understand.

Try doing something else like doing lighting in the world space, see if that gives you correct results.


Sphere Engine--the premier A6 graphics plugin.
Re: strange thing. maybe i forgot something [Re: Matt_Aufderheide] #74242
05/15/06 14:10
05/15/06 14:10
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
i am using sm2_0, i went down to sm1_1 i but the results are the same. i dont want to have any lighting. just the normals in correct worldspace. plus i remember that it once worked. i dunno.

it must be something dumb obvious thing i believe

Last edited by ello; 05/15/06 14:13.
Re: strange thing. maybe i forgot something [Re: ello] #74243
05/15/06 15:50
05/15/06 15:50
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
I meant..test the shader by calculating lighting, so you know whether or not the normals are actually being transformed.


Sphere Engine--the premier A6 graphics plugin.
Re: strange thing. maybe i forgot something [Re: Matt_Aufderheide] #74244
05/15/06 16:38
05/15/06 16:38
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
mul-ing the normals by the world matrix is going to not only transform the orientation, but also the position, which you don't want- this is causing the overreaction. Maybe it's just me... but I think you want the untransformed normals just raw, maybe normalized...

EDIT: ok.. I see what you mean, reading through again..
You should probably set up your own matrix that doesn't have the translation multiplied in. Or you could mulitply the world transform matrix by an inverse translation for the objects world position...

-Rhuarc

Last edited by Rhuarc; 05/15/06 16:41.

I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: strange thing. maybe i forgot something [Re: Rhuarc] #74245
05/15/06 18:45
05/15/06 18:45
Joined: Oct 2000
Posts: 1,543
Germany
A
Alexander Esslinger Offline
Senior Developer
Alexander Esslinger  Offline
Senior Developer
A

Joined: Oct 2000
Posts: 1,543
Germany
When you want to transform the normal to world-space, the correct way would be to use the inverse transpose of the world-matrix. That's it in HLSL:

Code:
float4 worldNormal = mul(matWorldInv, inNormal);



Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | 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