Commit 7be6912b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - improved phong lighting in isosurface raytracer

parent 13800a44
...@@ -158,7 +158,7 @@ void main() ...@@ -158,7 +158,7 @@ void main()
#endif #endif
#ifdef PHONG #ifdef PHONG
// find a proper normal for a headlight // find a proper normal for a headlight
float s = 0.005; float s = 0.01;
float valueXP = texture3D( tex0, curPoint + vec3( s, 0.0, 0.0 ) ).r; float valueXP = texture3D( tex0, curPoint + vec3( s, 0.0, 0.0 ) ).r;
float valueXM = texture3D( tex0, curPoint - vec3( s, 0.0, 0.0 ) ).r; float valueXM = texture3D( tex0, curPoint - vec3( s, 0.0, 0.0 ) ).r;
float valueYP = texture3D( tex0, curPoint + vec3( 0.0, s, 0.0 ) ).r; float valueYP = texture3D( tex0, curPoint + vec3( 0.0, s, 0.0 ) ).r;
...@@ -166,18 +166,11 @@ void main() ...@@ -166,18 +166,11 @@ void main()
float valueZP = texture3D( tex0, curPoint + vec3( 0.0, 0.0, s ) ).r; float valueZP = texture3D( tex0, curPoint + vec3( 0.0, 0.0, s ) ).r;
float valueZM = texture3D( tex0, curPoint - vec3( 0.0, 0.0, s ) ).r; float valueZM = texture3D( tex0, curPoint - vec3( 0.0, 0.0, s ) ).r;
vec3 dir = vec3( 0.0 );//v_ray; vec3 dir = vec3( valueXP - valueXM, valueYP - valueYM, valueZP - valueZM ) ;//v_ray;
dir += vec3( valueXP, 0.0, 0.0 );
dir -= vec3( valueXM, 0.0, 0.0 );
dir += vec3( 0.0, valueYP, 0.0 );
dir -= vec3( 0.0, valueYM, 0.0 );
dir += vec3( 0.0, 0.0, valueZP );
dir -= vec3( 0.0, 0.0, valueZP );
// Phong: // Phong:
float light = blinnPhongIlluminationIntensity( float light = blinnPhongIlluminationIntensity(
0.3, // material ambient 0.1, // material ambient
1.0, // material diffuse 0.75, // material diffuse
1.3, // material specular 1.3, // material specular
10.0, // shinines 10.0, // shinines
1.0, // light diffuse 1.0, // light diffuse
...@@ -190,6 +183,32 @@ void main() ...@@ -190,6 +183,32 @@ void main()
color = light * gl_Color; color = light * gl_Color;
#endif #endif
#ifdef PHONGWITHDEPTH #ifdef PHONGWITHDEPTH
float d = 1.0 - curPointProjected.z;
// find a proper normal for a headlight
float s = 0.01;
float valueXP = texture3D( tex0, curPoint + vec3( s, 0.0, 0.0 ) ).r;
float valueXM = texture3D( tex0, curPoint - vec3( s, 0.0, 0.0 ) ).r;
float valueYP = texture3D( tex0, curPoint + vec3( 0.0, s, 0.0 ) ).r;
float valueYM = texture3D( tex0, curPoint - vec3( 0.0, s, 0.0 ) ).r;
float valueZP = texture3D( tex0, curPoint + vec3( 0.0, 0.0, s ) ).r;
float valueZM = texture3D( tex0, curPoint - vec3( 0.0, 0.0, s ) ).r;
vec3 dir = vec3( valueXP - valueXM, valueYP - valueYM, valueZP - valueZM ) ;//v_ray;
// Phong:
float light = blinnPhongIlluminationIntensity(
0.1, // material ambient
d * d, // material diffuse
1.3, // material specular
10.0, // shinines
1.0, // light diffuse
0.3, // light ambient
normalize( -dir ), // normal
normalize( v_ray ), // view direction
normalize( v_lightSource ) // light source position
);
color = light * gl_Color;
#endif #endif
color.a = u_alpha; color.a = u_alpha;
......
...@@ -71,7 +71,7 @@ void main() ...@@ -71,7 +71,7 @@ void main()
// also get the coordinates of the light // also get the coordinates of the light
vec4 lpos = gl_LightSource[0].position; vec4 lpos = gl_LightSource[0].position;
// lpos = vec4( 0.0, 0.0, 1000.0, 1.0 ); lpos = vec4( 0.0, 0.0, 1000.0, 1.0 );
v_lightSource = worldToLocal( lpos ).xyz; v_lightSource = worldToLocal( lpos ).xyz;
// Simply project the vertex // Simply project the vertex
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment