Showing the changes to libraries/render-utils/src/DeferredLightingEffect.cpp (1 of 275 files). Show all
Unified · Split
| @@ -61,15 +61,26 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { · 60 unmodified lines | ||
| 61 | 61 | gpu::Shader::BindingSet slotBindings; |
| 62 | 62 | gpu::Shader::makeProgram(*program, slotBindings); |
| 63 | 63 | gpu::Shader::makeProgram(*programTextured, slotBindings); |
| 64 | − | |
| 64 | + | |
| 65 | 65 | gpu::StatePointer state = gpu::StatePointer(new gpu::State()); |
| 66 | 66 | state->setCullMode(gpu::State::CULL_BACK); |
| 67 | 67 | state->setDepthTest(true, true, gpu::LESS_EQUAL); |
| 68 | 68 | state->setBlendFunction(false, |
| 69 | 69 | gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, |
| 70 | 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 | 80 | _simpleProgram = gpu::PipelinePointer(gpu::Pipeline::create(program, state)); |
| 81 | + _simpleProgramCullNone = gpu::PipelinePointer(gpu::Pipeline::create(program, stateCullNone)); | |
| 72 | 82 | _simpleProgramTextured = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, state)); |
| 83 | + _simpleProgramTexturedCullNone = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, stateCullNone)); | |
| 73 | 84 | |
| 74 | 85 | _viewState = viewState; |
| 75 | 86 | loadLightProgram(directional_light_frag, false, _directionalLight, _directionalLightLocations); |
| @@ -106,13 +117,21 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { · 30 unmodified lines | ||
| 106 | 117 | lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset(_ambientLightMode % gpu::SphericalHarmonics::NUM_PRESET)); |
| 107 | 118 | } |
| 108 | 119 | |
| 109 | −void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured) { | |
| 120 | +void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled) { | |
| 110 | 121 | // DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(batch, true, true, true); |
| 111 | 122 | |
| 112 | 123 | if (textured) { |
| 113 | − batch.setPipeline(_simpleProgramTextured); | |
| 124 | + if (culled) { | |
| 125 | + batch.setPipeline(_simpleProgramTextured); | |
| 126 | + } else { | |
| 127 | + batch.setPipeline(_simpleProgramTexturedCullNone); | |
| 128 | + } | |
| 114 | 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 | |
| 210 | −void DeferredLightingEffect::prepare() { | |
| 229 | +void DeferredLightingEffect::prepare(RenderArgs* args) { | |
| 211 | 230 | // clear the normal and specular buffers |
| 212 | 231 | auto textureCache = DependencyManager::get<TextureCache>(); |
| 213 | 232 | textureCache->setPrimaryDrawBuffers(false, true, false); |
| @@ -221,7 +240,7 @@ void DeferredLightingEffect::prepare() { · 7 unmodified lines | ||
| 221 | 240 | textureCache->setPrimaryDrawBuffers(true, false, false); |
| 222 | 241 | } |
| 223 | 242 | |
| 224 | −void DeferredLightingEffect::render() { | |
| 243 | +void DeferredLightingEffect::render(RenderArgs* args) { | |
| 225 | 244 | // perform deferred lighting, rendering to free fbo |
| 226 | 245 | glDisable(GL_BLEND); |
| 227 | 246 | glDisable(GL_LIGHTING); |