1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
// march along ray from back to front, accumulating color
float4 sum = make_float4( 0.0f );;
float t = tnear;
for ( int i = 0; i < maxSteps; ++i ) {
float3 pos = eyeRay.o + eyeRay.d * t;
pos = pos * 0.5f + 0.5f; // map position to [0, 1] coordinates
// read from 3D texture
float sample = tex3D( tex, pos.x, pos.y, pos.z );
// lookup in transfer function texture
float4 col = tex1D( transferTex, ( sample - transferOffset ) * transferScale );
// accumulate result
sum.x += col.x + ( 1.0 - col.w ) * sum.x;
sum.y += col.y + ( 1.0 - col.w ) * sum.y;
sum.z += col.z + ( 1.0 - col.w ) * sum.z;
sum.w += col.w + ( 1.0 - col.w ) * sum.w;
t += tstep;
if ( t > tfar ) break;
} |
Partager