volmetrics

changeset 24:c4662d60cd93

foo
author Eleni Maria Stea <elene.mst@gmail.com>
date Thu, 24 Apr 2014 21:33:26 +0300
parents 930c063ae346
children 4b6c952a83bd
files data/shaders/transfer.f.glsl data/shaders/transfer.v.glsl sdr/preview.f.glsl sdr/preview.v.glsl
diffstat 2 files changed, 23 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/data/shaders/transfer.f.glsl	Thu Apr 24 21:33:26 2014 +0300
     1.3 @@ -0,0 +1,18 @@
     1.4 +uniform sampler3D tex;
     1.5 +uniform float tmin;
     1.6 +uniform float tmax;
     1.7 +
     1.8 +float transfer(float x, float tmin, float tmax)
     1.9 +{
    1.10 +	float dt = 0.25 * (tmax - tmin);
    1.11 +	return smoothstep(tmin - dt, tmin + dt, x) *
    1.12 +		(1.0 - smoothstep(tmax - dt, tmax + dt, x));
    1.13 +}
    1.14 +
    1.15 +void main()
    1.16 +{
    1.17 +	float texel = texture3D(tex, gl_TexCoord[0].xyz).x;
    1.18 +	float val = transfer(texel, tmin, tmax);
    1.19 +
    1.20 +	gl_FragColor = vec4(val, val, val, 1.0);
    1.21 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/data/shaders/transfer.v.glsl	Thu Apr 24 21:33:26 2014 +0300
     2.3 @@ -0,0 +1,5 @@
     2.4 +void main()
     2.5 +{
     2.6 +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
     2.7 +	gl_TexCoord[0] = gl_MultiTexCoord0;
     2.8 +}