Hello,
i have some problems with local illumination in volume rendering.
For ray setup I draw a color coded cube twice. first with backface culling and second time with front face culling.
the colors represent the entry and exit points. In a shader I
build the rays and traverse throught the volume (3d texture).
For lighting I calculate the gradients(normals) with the central difference method. The gradients are in volumes object space. The cube’s dimension is from 0,0,0 - 1,1,1. So the gradients, that are in volume’s object space are
within a normalized range of [0,1]. For phong lighting I also need the light vector and the viewing vector. I want that the light source is fixed to the camera. So light vector and view vector should be the same.
I thought I can use the ray’s direction as my view/light vector. But the lightin doesnt work properly. there’s almost
no shading.
Here are some pictures. in the second picture you can see some small specular highlighting and in the last you can see some more specular lightin as it should be. In the first to pictures I used the raydirection computed in the shader as
view and light direction.
vec3 phongShading(in vec3 dir, in vec3 pos, in vec3 normal, vec3 ka, vec3 kd, vec3 ks)
{
vec3 N = normalize(normal);
vec3 L = dir;
vec3 V = normalize(dir);
...
...
}
In the last picture I passed the camera position into the shader as camera position and light
position. And then in the lighting shader I calculated the
view and light direction with
vec3 phongShading(in vec3 pos, in vec3 normal, vec3 ka, vec3 kd, vec3 ks)
{
vec3 N = normalize(normal);
vec3 L = lightPos - pos;
vec3 V = normalize(cameraPos - pos);
...
...
}
Previously I used local lighting in
texture sliced volume rendering and it worked fine. Now, im implementing local lighting in raycasting. Actually it’s not that hard, but there is something I mixed up did wrong.
Can some give me a hint I may did wrong or missed to do ?
regards,
lobbel