From 7580a1da89ae56673dfa25b8e96c4630f258ddf4 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 15 Sep 2014 17:33:07 -0700 Subject: [PATCH] Glow fix for simple shader. --- interface/resources/shaders/simple.frag | 5 ++++- interface/src/renderer/DeferredLightingEffect.cpp | 5 +++++ interface/src/renderer/DeferredLightingEffect.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/interface/resources/shaders/simple.frag b/interface/resources/shaders/simple.frag index 5c47e29d74..347cb0a859 100644 --- a/interface/resources/shaders/simple.frag +++ b/interface/resources/shaders/simple.frag @@ -14,9 +14,12 @@ // the interpolated normal varying vec4 normal; +// the glow intensity +uniform float glowIntensity; + void main(void) { // set the diffuse, normal, specular data - gl_FragData[0] = vec4(gl_Color.rgb, 0.0); + gl_FragData[0] = vec4(gl_Color.rgb, glowIntensity); gl_FragData[1] = normalize(normal) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0); gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb, gl_FrontMaterial.shininess / 128.0); } diff --git a/interface/src/renderer/DeferredLightingEffect.cpp b/interface/src/renderer/DeferredLightingEffect.cpp index 2e2086e02b..48fbf30898 100644 --- a/interface/src/renderer/DeferredLightingEffect.cpp +++ b/interface/src/renderer/DeferredLightingEffect.cpp @@ -23,6 +23,10 @@ void DeferredLightingEffect::init() { _simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/simple.frag"); _simpleProgram.link(); + _simpleProgram.bind(); + _glowIntensityLocation = _simpleProgram.uniformLocation("glowIntensity"); + _simpleProgram.release(); + loadLightProgram("shaders/directional_light.frag", _directionalLight, _directionalLightLocations); loadLightProgram("shaders/directional_light_shadow_map.frag", _directionalLightShadowMap, _directionalLightShadowMapLocations); @@ -33,6 +37,7 @@ void DeferredLightingEffect::init() { void DeferredLightingEffect::bindSimpleProgram() { Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true, true); _simpleProgram.bind(); + _simpleProgram.setUniformValue(_glowIntensityLocation, Application::getInstance()->getGlowEffect()->getIntensity()); glDisable(GL_BLEND); } diff --git a/interface/src/renderer/DeferredLightingEffect.h b/interface/src/renderer/DeferredLightingEffect.h index 1971019aca..1953afd4c3 100644 --- a/interface/src/renderer/DeferredLightingEffect.h +++ b/interface/src/renderer/DeferredLightingEffect.h @@ -67,6 +67,7 @@ private: static void loadLightProgram(const char* name, ProgramObject& program, LightLocations& locations); ProgramObject _simpleProgram; + int _glowIntensityLocation; ProgramObject _directionalLight; LightLocations _directionalLightLocations;