Advertisement
Guest User

Untitled

a guest
Sep 6th, 2010
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. uniform sampler3D tex, texIndex;
  2. uniform int depth;
  3.  
  4. varying float sphIndex;
  5.  
  6. void main()
  7. {
  8.     vec3 coord3, coord3Index;
  9.     vec4 lastColor, currColor, color;
  10.     color = vec4(0, 0, 0, 0);
  11.  
  12.     float currIndex = 0.0;
  13.     float lastIndex = 0.0;
  14.     float deltaIndex = 0.0;
  15.  
  16.     coord3.xy = gl_TexCoord[0].st;
  17.     coord3Index.xy = coord3.xy;
  18.    
  19.     float zIndex;
  20.  
  21.     color = vec4(0.0, 0.0, 1.0, 1.0);
  22.    
  23.     for(int i = 0; i < depth; i++) {
  24.         zIndex = (i*1.0)/(depth*1.0);
  25.         coord3Index.z = zIndex;
  26.         vec4 vCurrIndex = texture3D(texIndex, coord3Index);
  27.         currIndex = vCurrIndex.r;
  28.        
  29.    
  30.         if ( sphIndex <= currIndex) {ยจ
  31.             if ( currIndex < 0.5) {
  32.                 color = vec4(0.0, 0.0, 1.0, 1.0);
  33.             } else color = vec4(0.0, currIndex, 0.0, 1.0);
  34.  
  35.             if ( sphIndex < 0.5) {
  36.                 color = color + vec4(sphIndex, 0.0, 0.0, 1.0);
  37.             }
  38.             i = depth +1;
  39.            
  40.         } else {
  41.             lastIndex = currIndex;
  42.         }  
  43.     }
  44.    
  45.    
  46.     gl_FragColor = color;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement