Updated volume shaders to use the GL_LIGHT 0 values to control the direction of the light source

This commit is contained in:
Robert Osfield
2011-10-27 16:33:18 +00:00
parent 3a64805d20
commit 98d50250ff
5 changed files with 25 additions and 9 deletions

View File

@@ -1,15 +1,30 @@
char volume_vert[] = "#version 110\n"
"varying vec4 cameraPos;\n"
"varying vec4 vertexPos;\n"
"varying vec3 lightDirection;\n"
"varying mat4 texgen;\n"
"\n"
"\n"
"void main(void)\n"
"{\n"
" gl_Position = ftransform();\n"
"\n"
" cameraPos = gl_ModelViewMatrixInverse*vec4(0,0,0,1);\n"
" cameraPos = gl_ModelViewMatrixInverse * vec4(0,0,0,1);\n"
" vertexPos = gl_Vertex;\n"
"\n"
" vec4 lightPosition = gl_ModelViewMatrixInverse * gl_LightSource[0].position;\n"
" if (lightPosition[3]==0.0)\n"
" {\n"
" // directional light source\n"
" lightDirection = -normalize(lightPosition.xyz);\n"
" }\n"
" else\n"
" {\n"
" // positional light source\n"
" lightDirection = normalize((lightPosition-vertexPos).xyz);\n"
" }\n"
"\n"
"\n"
" texgen = mat4(gl_ObjectPlaneS[0], \n"
" gl_ObjectPlaneT[0],\n"
" gl_ObjectPlaneR[0],\n"