volmetrics

annotate data/shaders/transfer.f.glsl @ 27:069fae435a1d

foo
author Eleni Maria Stea <elene.mst@gmail.com>
date Sun, 27 Apr 2014 19:24:48 +0300
parents
children
rev   line source
elene@24 1 uniform sampler3D tex;
elene@24 2 uniform float tmin;
elene@24 3 uniform float tmax;
elene@24 4
elene@24 5 float transfer(float x, float tmin, float tmax)
elene@24 6 {
elene@24 7 float dt = 0.25 * (tmax - tmin);
elene@24 8 return smoothstep(tmin - dt, tmin + dt, x) *
elene@24 9 (1.0 - smoothstep(tmax - dt, tmax + dt, x));
elene@24 10 }
elene@24 11
elene@24 12 void main()
elene@24 13 {
elene@24 14 float texel = texture3D(tex, gl_TexCoord[0].xyz).x;
elene@24 15 float val = transfer(texel, tmin, tmax);
elene@24 16
elene@24 17 gl_FragColor = vec4(val, val, val, 1.0);
elene@24 18 }