Glow fix for simple shader.

This commit is contained in:
Andrzej Kapolka 2014-09-15 17:33:07 -07:00
parent da05d37015
commit 7580a1da89
3 changed files with 10 additions and 1 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -67,6 +67,7 @@ private:
static void loadLightProgram(const char* name, ProgramObject& program, LightLocations& locations);
ProgramObject _simpleProgram;
int _glowIntensityLocation;
ProgramObject _directionalLight;
LightLocations _directionalLightLocations;