volmetrics

diff data/shaders/vol.f.glsl @ 30:e548d95e0667

fixed lighting, added parameter for volume rotation
author Eleni Maria Stea <elene.mst@gmail.com>
date Thu, 01 May 2014 15:28:51 +0300
parents 4b6c952a83bd
children
line diff
     1.1 --- a/data/shaders/vol.f.glsl	Sun Apr 27 21:07:10 2014 +0300
     1.2 +++ b/data/shaders/vol.f.glsl	Thu May 01 15:28:51 2014 +0300
     1.3 @@ -20,7 +20,7 @@
     1.4  	float dfdy = texture3D(tex, p + vec3(0.0, offs.y, 0.0)).x - texel;
     1.5  	float dfdz = texture3D(tex, p + vec3(0.0, 0.0, offs.z)).x - texel;
     1.6  
     1.7 -	return normalize(vec3(dfdx, dfdy, dfdz));
     1.8 +	return -normalize(vec3(dfdx, dfdy, dfdz));
     1.9  }
    1.10  
    1.11  void main()
    1.12 @@ -33,7 +33,7 @@
    1.13  	float texel = texture3D(tex, pt).x;
    1.14  	float val = transfer(texel, tmin, tmax);
    1.15  
    1.16 -	vec3 normal = calc_normal(pt, texel);
    1.17 +	vec3 normal = gl_NormalMatrix * calc_normal(pt, texel);
    1.18  	float ndotl = max(dot(normalize(ldir), normal), 0.0);
    1.19  
    1.20  	gl_FragColor = vec4(ndotl, ndotl, ndotl, val);