Jump to content
  • Advertisement
Sign in to follow this  
uhfath

[LPP] Point lights in Render Monkey

This topic is 2601 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

Recently i've been strugling with my LPP realisation and firstly tried some shader stuff in Render Monkey.
The strangest thing is that i haven't done anything complicated and got different results in OGL and DX versions of effect (attached it).

Here are the screens:
DX Version:
[attachment=2146:DX.jpg]
OGL Version:
[attachment=2147:OGL.jpg]

What was done is just simple rendering of world normals and world positions (they are "world", because local matrices are identity) into RGBA32F textures.
Then a simple full screen shader with a very simple code to calculate a point light source with infinite radius:
DX Version: float3 fragmentNormal = tex2D(normalsSampler, In.TexCoord).rgb;
float3 fragmentPosition = tex2D(positionsSampler, In.TexCoord).rgb;

float3 lightDirection = normalize(float3(0.0, 0.0, 50.0) - fragmentPosition);
float diffuseIntensity = dot(lightDirection, fragmentNormal);

OGL Version: vec3 fragmentNormal = texture2D(normalsSampler, texCoord).rgb;
vec3 fragmentPosition = texture2D(positionsSampler, texCoord).rgb;

vec3 lightDirection = normalize(vec3(0.0, 0.0, 50.0) - fragmentPosition);
float diffuseIntensity = dot(lightDirection, fragmentNormal);


As you can see the code is the same. But why do the results differ that much? From my point of view, DX version gives correct picture.

Share this post


Link to post
Share on other sites
Advertisement
As you can see, the red channel (=x axis) is inverted. The reason could be coordinate system, OGL uses right-handed coordinate system while DX uses a left-handed one.

Share this post


Link to post
Share on other sites
Yes. The coordinate systems are different. But does it mean that DX and OGL must use different formulas for calculating lighting from a point source?

Share this post


Link to post
Share on other sites
You can use the same shader math assuming that in your rendering code (the C/C++/etc part) you build your matrices according to the conventions of each API.

Share this post


Link to post
Share on other sites
Well... i thought that Render Monkey does that on it's own. But i just don't understand why the results in it differ that much.

But never mind... thank you both for your answers. Perhaps it's just a bug.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!