Commit 39f67ffa authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri

[Volume] Support per component light parameters

Volume property allows the lighting parameters like
ambient coefficient, diffuse, specular, etc. per
component. Added support for these
per-component parameters to the volume mapper.
parent 475507b0
......@@ -3557,17 +3557,26 @@ void vtkOpenGLGPUVolumeRayCastMapper::DoGPURender(vtkRenderer* ren,
//--------------------------------------------------------------------------
this->Impl->SetLightingParameters(ren, prog, vol);
fvalue3[0] = fvalue3[1] = fvalue3[2] = volumeProperty->GetAmbient();
prog->SetUniform3f("in_ambient", fvalue3);
float ambient[4][3];
float diffuse[4][3];
float specular[4][3];
float specularPower[4];
fvalue3[0] = fvalue3[1] = fvalue3[2] = volumeProperty->GetDiffuse();
prog->SetUniform3f("in_diffuse", fvalue3);
fvalue3[0] = fvalue3[1] = fvalue3[2] = volumeProperty->GetSpecular();
prog->SetUniform3f("in_specular", fvalue3);
for (int i = 0; i < numberOfSamplers; ++i)
{
ambient[i][0] = ambient[i][1] = ambient[i][2] =
volumeProperty->GetAmbient(i);
diffuse[i][0] = diffuse[i][1] = diffuse[i][2] =
volumeProperty->GetDiffuse(i);
specular[i][0] = specular[i][1] = specular[i][2] =
volumeProperty->GetSpecular(i);
specularPower[i] = volumeProperty->GetSpecularPower(i);
}
fvalue3[0] = volumeProperty->GetSpecularPower();
prog->SetUniformf("in_shininess", fvalue3[0]);
prog->SetUniform3fv("in_ambient", numberOfSamplers, ambient);
prog->SetUniform3fv("in_diffuse", numberOfSamplers, diffuse);
prog->SetUniform3fv("in_specular", numberOfSamplers, specular);
prog->SetUniform1fv("in_shininess", numberOfSamplers, specularPower);
double clippingRange[2];
cam->GetClippingRange(clippingRange);
......
......@@ -180,10 +180,10 @@ namespace vtkvolume
\nuniform vec3 in_textureExtentsMin;\
\n\
\n// Material and lighting\
\nuniform vec3 in_diffuse;\
\nuniform vec3 in_ambient;\
\nuniform vec3 in_specular;\
\nuniform float in_shininess;\
\nuniform vec3 in_diffuse[4];\
\nuniform vec3 in_ambient[4];\
\nuniform vec3 in_specular[4];\
\nuniform float in_shininess[4];\
\n\
\n// Others\
\nuniform bool in_cellFlag;\
......@@ -616,14 +616,16 @@ namespace vtkvolume
\n }\
\n if (nDotL > 0.0)\
\n {\
\n diffuse = nDotL * in_diffuse * in_lightDiffuseColor[0]\
\n * color.rgb;\
\n diffuse = nDotL * in_diffuse[component] *\
\n in_lightDiffuseColor[0] * color.rgb;\
\n }\
\n specular = pow(nDotH, in_shininess) * in_specular *\
\n specular = pow(nDotH, in_shininess[component]) *\
\n in_specular[component] *\
\n in_lightSpecularColor[0];\
\n // For the headlight, ignore the light's ambient color\
\n // for now as it is causing the old mapper tests to fail\
\n finalColor.xyz = in_ambient * color.rgb + diffuse + specular;"
\n finalColor.xyz = in_ambient[component] * color.rgb +\
\n diffuse + specular;"
);
}
else if (lightingComplexity == 2)
......@@ -669,13 +671,14 @@ namespace vtkvolume
\n }\
\n if (nDotH > 0.0)\
\n {\
\n specular = in_lightSpecularColor[lightNum] * pow(nDotH, in_shininess);\
\n specular = in_lightSpecularColor[lightNum] *\
\n pow(nDotH, in_shininess[component]);\
\n }\
\n ambient += in_lightAmbientColor[lightNum];\
\n }\
\n finalColor.xyz = in_ambient * ambient +\
\n in_diffuse * diffuse * color.rgb +\
\n in_specular * specular;"
\n finalColor.xyz = in_ambient[component] * ambient +\
\n in_diffuse[component] * diffuse * color.rgb +\
\n in_specular[component] * specular;"
);
}
else if (lightingComplexity == 3)
......@@ -746,13 +749,14 @@ namespace vtkvolume
\n }\
\n if (nDotH > 0.0)\
\n {\
\n float sf = attenuation * pow(nDotH, in_shininess);\
\n float sf = attenuation * pow(nDotH, in_shininess[component]);\
\n specular += (sf * in_lightSpecularColor[lightNum]);\
\n }\
\n ambient += in_lightAmbientColor[lightNum];\
\n }\
\n finalColor.xyz = in_ambient * ambient + in_diffuse *\
\n diffuse * color.rgb + in_specular * specular;\
\n finalColor.xyz = in_ambient[component] * ambient +\
\n in_diffuse[component] * diffuse * color.rgb +\
\n in_specular[component] * specular;\
");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment