Explore the WAVE Client Renderer Library which utilizes Three.js for Volume Rendering through Ray Casting.
The technique of GPU accelerated Volume Ray Casting typically involves multi-pass rendering.
In the initial pass, shaders are basic and work by mapping the texture coordinates at object positions where the rays intersect with the back side of the cube.
If you need to access GLSL shader examples, check out the ejs template provided below:
firstPass.frag
precision mediump int;
precision mediump float;
varying vec4 backColor;
void main(void)
{
gl_FragColor = backColor;
}
firstPass.vert
precision mediump int;
precision mediump float;
attribute vec4 vertColor;
varying vec4 backColor;
varying vec4 pos;
void main(void)
{
backColor = vertColor;
pos = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
gl_Position = pos;
}
The second pass involves actual data sampling and visualization of the final image.
secondPass.vert
precision mediump int;
precision mediump float;
attribute vec4 vertColor;
varying vec4 backColor;
varying vec4 pos;
void main(void)
{
backColor = vertColor;
pos = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
gl_Position = pos;
}
secondPass.frag
#ifdef GL_FRAGMENT_PRECISION_HIGH
// highp is supported
precision highp int;
precision highp float;
#else
// high is not supported
precision mediump int;
precision mediump float;
#endif
... (omitted for brevity)
gl_FragColor = accum;
}