Merge pull request #4024 from samcake/temp1

Moving deferred lighting shaders from the resource folder to embedded source in the executable
This commit is contained in:
Brad Hefta-Gaub 2014-12-31 10:33:30 -08:00
commit eaa6d4455d
12 changed files with 52 additions and 31 deletions

View file

@ -25,24 +25,37 @@
#include "RenderUtil.h" #include "RenderUtil.h"
#include "TextureCache.h" #include "TextureCache.h"
#include "simple_vert.h"
#include "simple_frag.h"
#include "deferred_light_vert.h"
#include "deferred_light_limited_vert.h"
#include "directional_light_frag.h"
#include "directional_light_shadow_map_frag.h"
#include "directional_light_cascaded_shadow_map_frag.h"
#include "point_light_frag.h"
#include "spot_light_frag.h"
void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
_viewState = viewState; _viewState = viewState;
_simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/simple.vert"); _simpleProgram.addShaderFromSourceCode(QGLShader::Vertex, simple_vert);
_simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/simple.frag"); _simpleProgram.addShaderFromSourceCode(QGLShader::Fragment, simple_frag);
_simpleProgram.link(); _simpleProgram.link();
_simpleProgram.bind(); _simpleProgram.bind();
_glowIntensityLocation = _simpleProgram.uniformLocation("glowIntensity"); _glowIntensityLocation = _simpleProgram.uniformLocation("glowIntensity");
_simpleProgram.release(); _simpleProgram.release();
loadLightProgram("shaders/directional_light.frag", false, _directionalLight, _directionalLightLocations); loadLightProgram(directional_light_frag, false, _directionalLight, _directionalLightLocations);
loadLightProgram("shaders/directional_light_shadow_map.frag", false, _directionalLightShadowMap, loadLightProgram(directional_light_shadow_map_frag, false, _directionalLightShadowMap,
_directionalLightShadowMapLocations); _directionalLightShadowMapLocations);
loadLightProgram("shaders/directional_light_cascaded_shadow_map.frag", false, _directionalLightCascadedShadowMap, loadLightProgram(directional_light_cascaded_shadow_map_frag, false, _directionalLightCascadedShadowMap,
_directionalLightCascadedShadowMapLocations); _directionalLightCascadedShadowMapLocations);
loadLightProgram("shaders/point_light.frag", true, _pointLight, _pointLightLocations); loadLightProgram(point_light_frag, true, _pointLight, _pointLightLocations);
loadLightProgram("shaders/spot_light.frag", true, _spotLight, _spotLightLocations); loadLightProgram(spot_light_frag, true, _spotLight, _spotLightLocations);
} }
void DeferredLightingEffect::bindSimpleProgram() { void DeferredLightingEffect::bindSimpleProgram() {
@ -400,10 +413,9 @@ void DeferredLightingEffect::render() {
_postLightingRenderables.clear(); _postLightingRenderables.clear();
} }
void DeferredLightingEffect::loadLightProgram(const char* name, bool limited, ProgramObject& program, LightLocations& locations) { void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limited, ProgramObject& program, LightLocations& locations) {
program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + program.addShaderFromSourceCode(QGLShader::Vertex, (limited ? deferred_light_limited_vert : deferred_light_vert));
(limited ? "shaders/deferred_light_limited.vert" : "shaders/deferred_light.vert")); program.addShaderFromSourceCode(QGLShader::Fragment, fragSource);
program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + name);
program.link(); program.link();
program.bind(); program.bind();

View file

@ -86,7 +86,7 @@ private:
int radius; int radius;
}; };
static void loadLightProgram(const char* name, bool limited, ProgramObject& program, LightLocations& locations); static void loadLightProgram(const char* fragSource, bool limited, ProgramObject& program, LightLocations& locations);
ProgramObject _simpleProgram; ProgramObject _simpleProgram;
int _glowIntensityLocation; int _glowIntensityLocation;

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// deferred_light.vert // deferred_light.vert
// vertex shader // vertex shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// deferred_light_limited.vert // deferred_light_limited.vert
// vertex shader // vertex shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// directional_light.frag // directional_light.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// directional_light.frag // directional_light.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// directional_light.frag // directional_light.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// spot_light.frag // spot_light.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// simple.frag // simple.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// simple.vert // simple.vert
// vertex shader // vertex shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// spot_light.frag // spot_light.frag
// fragment shader // fragment shader

View file

@ -50,7 +50,7 @@ int main (int argc, char** argv) {
case READY: { case READY: {
if (inputs.back() == "-o") { if (inputs.back() == "-o") {
mode = GRAB_OUTPUT; mode = GRAB_OUTPUT;
} else if (inputs.back() == "-tn") { } else if (inputs.back() == "-t") {
mode = GRAB_TARGET_NAME; mode = GRAB_TARGET_NAME;
} else if (inputs.back() == "-D") { } else if (inputs.back() == "-D") {
mode = GRAB_VAR_NAME; mode = GRAB_VAR_NAME;