Reference photos
This is really a fake translucency shader meant to be applied to a single sided surface.
The real challenge is forcing the directlighting() function to use the reversed normals. In the old style of coding, one could just say:
The real challenge is forcing the directlighting() function to use the reversed normals. In the old style of coding, one could just say:
Ci = Os * Cs * (diffuse(nf) + diffuse(-nf) * surfcolor);
Meaning that the final color (Ci) is the apparent opacity, apparent color, and the diffuse of the front face added to the diffuse of the back face multiplied by the surface color.
At first I was switching the normals within the directlighting() function and something just wasn't working with the diffuselighting() call to get Ci. After playing, the reverse of the normal was put in the displacement() function, the normal place to initialize normals to the shader, with the following lines of code. The normals were changed as well as the shading context, that holds the information for the material and object, were also inverted.
At first I was switching the normals within the directlighting() function and something just wasn't working with the diffuselighting() call to get Ci. After playing, the reverse of the normal was put in the displacement() function, the normal place to initialize normals to the shader, with the following lines of code. The normals were changed as well as the shading context, that holds the information for the material and object, were also inverted.
N *= -1; m_shadingCtx -> m_Ns *= -1;
Then came the brute force way of getting the lighting information. After gathering a list of lights, the light color and direction was returned from a modified plausible light shader. The modifications to the basic plausible light shader were to force it to return the color and direction of the light. This worked, but did not show shadows.
Eventually I went back to trying the default method of lighting (directlighting()) to try and figure out the path between the material and the light to generate samples for shadows. I did not figure out the path because calling directlighting() returned shadows and translucent light information!
Eventually I went back to trying the default method of lighting (directlighting()) to try and figure out the path between the material and the light to generate samples for shadows. I did not figure out the path because calling directlighting() returned shadows and translucent light information!
float doReverse = 0;
displacement(point P, point N)
{
if (doReverse) {
reverse normals;
}
else
normal normal initialization;
}
surface ( color Ci, Oi )
{
frontColor = directlighting();
doReverse = 1;
this -> displacement;
backColor = directlighting();
Ci = backColor + frontColor;
}
displacement(point P, point N)
{
if (doReverse) {
reverse normals;
}
else
normal normal initialization;
}
surface ( color Ci, Oi )
{
frontColor = directlighting();
doReverse = 1;
this -> displacement;
backColor = directlighting();
Ci = backColor + frontColor;
}
Translucency Shader |