#168 Fixed shader based light in parallel projection

Added the light position as a uniform in the standard light model shader snippet in the effect generator.
Set the uniform default value on the shader program where ever it is used.
Added an override global uniform set on the viewer to control the light position, and to set it far behind camera when in parallel projection.
This commit is contained in:
Jacob Støren
2016-08-16 10:58:07 +02:00
parent a3499152a5
commit 0eace5579a
5 changed files with 58 additions and 7 deletions

View File

@@ -32,6 +32,7 @@
#include "cvfShaderSourceProvider.h"
#include "cvfTexture.h"
#include "cvfTexture2D_FF.h"
#include "cvfUniform.h"
@@ -81,6 +82,8 @@ void RivTernaryScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::E
cvf::ref<cvf::ShaderProgram> prog = gen.generate();
eff->setShaderProgram(prog.p());
if(!m_disableLighting) prog->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
// Result mapping texture
m_textureImage = new cvf::TextureImage();