Commit d5d28a05 authored by schultezub's avatar schultezub
Browse files

* added EnableShading property to ProcessorDecoratorShading

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@300 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 54a9b8de
......@@ -35,6 +35,7 @@ namespace TUMVis {
ProcessorDecoratorShading::ProcessorDecoratorShading(const std::string& lightUniformName /*= "_lightSource"*/)
: AbstractProcessorDecorator()
, _enableShading("EnableShading", "Enable Shading", true, InvalidationLevel::INVALID_SHADER)
, _lightPosition("LightPosition", "Light Position", tgt::vec3(-8.f), tgt::vec3(-500.f), tgt::vec3(500.f))
, _ambientColor("AmbientColor", "Ambient Light Color", tgt::vec3(0.5f), tgt::vec3(0.f), tgt::vec3(1.f))
, _diffuseColor("DiffuseColor", "Diffuse Light Color", tgt::vec3(0.75f), tgt::vec3(0.f), tgt::vec3(1.f))
......@@ -49,6 +50,7 @@ namespace TUMVis {
}
void ProcessorDecoratorShading::addProperties(HasPropertyCollection* propCollection) {
propCollection->addProperty(&_enableShading);
propCollection->addProperty(&_lightPosition);
propCollection->addProperty(&_ambientColor);
propCollection->addProperty(&_diffuseColor);
......@@ -68,7 +70,12 @@ namespace TUMVis {
std::string ProcessorDecoratorShading::generateHeader() const {
return "";
if (_enableShading.getValue()) {
return "#define ENABLE_SHADING\n";
}
else {
return "";
}
}
}
......@@ -51,6 +51,7 @@ namespace TUMVis {
std::string generateHeader() const;
BoolProperty _enableShading; ///< Flag whether to enable shading;
Vec3Property _lightPosition; ///< Light position
Vec3Property _ambientColor; ///< Ambient light color
Vec3Property _diffuseColor; ///< Diffuse light color
......
......@@ -82,7 +82,9 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
vec3 gradient = computeGradientCentralDifferences(_volume, samplePosition);
vec4 color = lookupTF(_tfTextureParameters, _tfTex, intensity);
#ifdef ENABLE_SHADING
color.rgb = calculatePhongShading(textureToWorld(_volume, samplePosition).xyz, _lightSource, _cameraPosition, gradient, color.xyz, color.xyz, vec3(1.0, 1.0, 1.0));
#endif
// perform compositing
if (color.a > 0.0) {
......
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