History

merged master

ericrius1 committed 11 years ago

Commit cf720f92 parents 10cefe0 62b3ca9275 files · +8836 −7501Browse files

Showing the changes to libraries/render-utils/src/DeferredLightingEffect.cpp (1 of 275 files). Show all

Unified · Split

libraries/render-utils/src/DeferredLightingEffect.cpp+25−6
@@ -61,15 +61,26 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { · 60 unmodified lines
6161 gpu::Shader::BindingSet slotBindings;
6262 gpu::Shader::makeProgram(*program, slotBindings);
6363 gpu::Shader::makeProgram(*programTextured, slotBindings);
64−
64+
6565 gpu::StatePointer state = gpu::StatePointer(new gpu::State());
6666 state->setCullMode(gpu::State::CULL_BACK);
6767 state->setDepthTest(true, true, gpu::LESS_EQUAL);
6868 state->setBlendFunction(false,
6969 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
7070 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
71+
72+
73+ gpu::StatePointer stateCullNone = gpu::StatePointer(new gpu::State());
74+ stateCullNone->setCullMode(gpu::State::CULL_NONE);
75+ stateCullNone->setDepthTest(true, true, gpu::LESS_EQUAL);
76+ stateCullNone->setBlendFunction(false,
77+ gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
78+ gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
79+
7180 _simpleProgram = gpu::PipelinePointer(gpu::Pipeline::create(program, state));
81+ _simpleProgramCullNone = gpu::PipelinePointer(gpu::Pipeline::create(program, stateCullNone));
7282 _simpleProgramTextured = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, state));
83+ _simpleProgramTexturedCullNone = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, stateCullNone));
7384
7485 _viewState = viewState;
7586 loadLightProgram(directional_light_frag, false, _directionalLight, _directionalLightLocations);
@@ -106,13 +117,21 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { · 30 unmodified lines
106117 lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset(_ambientLightMode % gpu::SphericalHarmonics::NUM_PRESET));
107118 }
108119
109−void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured) {
120+void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled) {
110121 // DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(batch, true, true, true);
111122
112123 if (textured) {
113− batch.setPipeline(_simpleProgramTextured);
124+ if (culled) {
125+ batch.setPipeline(_simpleProgramTextured);
126+ } else {
127+ batch.setPipeline(_simpleProgramTexturedCullNone);
128+ }
114129 } else {
115− batch.setPipeline(_simpleProgram);
130+ if (culled) {
131+ batch.setPipeline(_simpleProgram);
132+ } else {
133+ batch.setPipeline(_simpleProgramCullNone);
134+ }
116135 }
117136 }
118137
@@ -207,7 +226,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu · 88 unmodified lines
207226 }
208227 }
209228
210−void DeferredLightingEffect::prepare() {
229+void DeferredLightingEffect::prepare(RenderArgs* args) {
211230 // clear the normal and specular buffers
212231 auto textureCache = DependencyManager::get<TextureCache>();
213232 textureCache->setPrimaryDrawBuffers(false, true, false);
@@ -221,7 +240,7 @@ void DeferredLightingEffect::prepare() { · 7 unmodified lines
221240 textureCache->setPrimaryDrawBuffers(true, false, false);
222241 }
223242
224−void DeferredLightingEffect::render() {
243+void DeferredLightingEffect::render(RenderArgs* args) {
225244 // perform deferred lighting, rendering to free fbo
226245 glDisable(GL_BLEND);
227246 glDisable(GL_LIGHTING);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t