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
61 gpu::Shader::BindingSet slotBindings;61 gpu::Shader::BindingSet slotBindings;
62 gpu::Shader::makeProgram(*program, slotBindings);62 gpu::Shader::makeProgram(*program, slotBindings);
63 gpu::Shader::makeProgram(*programTextured, slotBindings);63 gpu::Shader::makeProgram(*programTextured, slotBindings);
64 64
65 gpu::StatePointer state = gpu::StatePointer(new gpu::State());65 gpu::StatePointer state = gpu::StatePointer(new gpu::State());
66 state->setCullMode(gpu::State::CULL_BACK);66 state->setCullMode(gpu::State::CULL_BACK);
67 state->setDepthTest(true, true, gpu::LESS_EQUAL);67 state->setDepthTest(true, true, gpu::LESS_EQUAL);
68 state->setBlendFunction(false,68 state->setBlendFunction(false,
69 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,69 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
70 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);70 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
71 _simpleProgram = gpu::PipelinePointer(gpu::Pipeline::create(program, state));80 _simpleProgram = gpu::PipelinePointer(gpu::Pipeline::create(program, state));
81 _simpleProgramCullNone = gpu::PipelinePointer(gpu::Pipeline::create(program, stateCullNone));
72 _simpleProgramTextured = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, state));82 _simpleProgramTextured = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, state));
83 _simpleProgramTexturedCullNone = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, stateCullNone));
73 84
74 _viewState = viewState;85 _viewState = viewState;
75 loadLightProgram(directional_light_frag, false, _directionalLight, _directionalLightLocations);86 loadLightProgram(directional_light_frag, false, _directionalLight, _directionalLightLocations);
@@ -106,13 +117,21 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { · 30 unmodified lines
106 lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset(_ambientLightMode % gpu::SphericalHarmonics::NUM_PRESET));117 lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset(_ambientLightMode % gpu::SphericalHarmonics::NUM_PRESET));
107}118}
108 119
109void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured) {120void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled) {
110 // DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(batch, true, true, true);121 // DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(batch, true, true, true);
111 122
112 if (textured) {123 if (textured) {
113 batch.setPipeline(_simpleProgramTextured);124 if (culled) {
125 batch.setPipeline(_simpleProgramTextured);
126 } else {
127 batch.setPipeline(_simpleProgramTexturedCullNone);
128 }
114 } else {129 } else {
115 batch.setPipeline(_simpleProgram);130 if (culled) {
131 batch.setPipeline(_simpleProgram);
132 } else {
133 batch.setPipeline(_simpleProgramCullNone);
134 }
116 }135 }
117}136}
118 137
@@ -207,7 +226,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu · 88 unmodified lines
207 }226 }
208}227}
209 228
210void DeferredLightingEffect::prepare() {229void DeferredLightingEffect::prepare(RenderArgs* args) {
211 // clear the normal and specular buffers230 // clear the normal and specular buffers
212 auto textureCache = DependencyManager::get<TextureCache>();231 auto textureCache = DependencyManager::get<TextureCache>();
213 textureCache->setPrimaryDrawBuffers(false, true, false);232 textureCache->setPrimaryDrawBuffers(false, true, false);
@@ -221,7 +240,7 @@ void DeferredLightingEffect::prepare() { · 7 unmodified lines
221 textureCache->setPrimaryDrawBuffers(true, false, false);240 textureCache->setPrimaryDrawBuffers(true, false, false);
222}241}
223 242
224void DeferredLightingEffect::render() {243void DeferredLightingEffect::render(RenderArgs* args) {
225 // perform deferred lighting, rendering to free fbo244 // perform deferred lighting, rendering to free fbo
226 glDisable(GL_BLEND);245 glDisable(GL_BLEND);
227 glDisable(GL_LIGHTING);246 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