Thanks!
In the meanwhile, I've discovered that the original shader actually
works with a directional light, but not with a point light. Otherwise,
with my modification it works with the point light, but not with the
directional one.
To make both lights work, I added after the line
" vec3 LightPosition = gl_LightSource[0].position.xyz;\n"
of the original shader the following lines:
" if(gl_LightSource[0].position.w != 0.0)\n"
" LightPosition -= vec3(gl_ModelViewMatrix * gl_Vertex);\n"
Also, in the fragment shader I added the light color to the fragment
final color calculation:
" color = clamp(gl_LightSource[0].diffuse.rgb * texcolor *
basecolor * intensity, 0.0, 1.0);\n"
Hope this makes sense to you :)
Christian
---------------------------------------------------------------------
Hello Christian,
On 07/28/2014 03:04 PM, Christian Bar wrote:
> I managed to make the QuadTreeTerrain rendering work inside my application.
> I changed the light position calculation inside the vertex shader. Now
> it is:
>
> " vec3 LightPosition = gl_LightSource[0].position.xyz -
> vec3(gl_ModelViewMatrix * gl_Vertex);\n"
>
> I'm not a shader expert, but to me now it seems to work...
hmm, that changes the lighting from a directional to a (sort of) point
light.
In the meantime I've noticed that my last change to the shader using
gl_ModelViewMatrixInverse was wrong; the tangent space vectors are first
transformed to eye-space, so the light direction can be left in
eye-space as well.
> If it's ok for you, can you commit this line, along with the
> modification you did in the other patch?
I've committed the other changes, but left the shader in its original
form. I feel uneasy changing it without some understanding why that is
the correct change.
Cheers,
Carsten
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users