mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 18:16:08 +02:00
Add culled option for simple programs
This commit is contained in:
parent
67473ac254
commit
9c7f24eeb6
3 changed files with 27 additions and 6 deletions
|
@ -113,7 +113,7 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
|||
auto& batch = *args->_batch;
|
||||
batch._glLineWidth(_lineWidth);
|
||||
batch.setModelTransform(transform);
|
||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch);
|
||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, false, false);
|
||||
|
||||
// for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise
|
||||
// we just draw a line...
|
||||
|
|
|
@ -61,15 +61,26 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
|
|||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
gpu::Shader::makeProgram(*programTextured, slotBindings);
|
||||
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
state->setCullMode(gpu::State::CULL_BACK);
|
||||
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||
state->setBlendFunction(false,
|
||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
|
||||
|
||||
gpu::StatePointer stateCullNone = gpu::StatePointer(new gpu::State());
|
||||
stateCullNone->setCullMode(gpu::State::CULL_NONE);
|
||||
stateCullNone->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||
stateCullNone->setBlendFunction(false,
|
||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
|
||||
_simpleProgram = gpu::PipelinePointer(gpu::Pipeline::create(program, state));
|
||||
_simpleProgramCullNone = gpu::PipelinePointer(gpu::Pipeline::create(program, stateCullNone));
|
||||
_simpleProgramTextured = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, state));
|
||||
_simpleProgramTexturedCullNone = gpu::PipelinePointer(gpu::Pipeline::create(programTextured, stateCullNone));
|
||||
|
||||
_viewState = viewState;
|
||||
loadLightProgram(directional_light_frag, false, _directionalLight, _directionalLightLocations);
|
||||
|
@ -106,13 +117,21 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
|
|||
lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset(_ambientLightMode % gpu::SphericalHarmonics::NUM_PRESET));
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured) {
|
||||
void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled) {
|
||||
// DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(batch, true, true, true);
|
||||
|
||||
if (textured) {
|
||||
batch.setPipeline(_simpleProgramTextured);
|
||||
if (culled) {
|
||||
batch.setPipeline(_simpleProgramTextured);
|
||||
} else {
|
||||
batch.setPipeline(_simpleProgramTexturedCullNone);
|
||||
}
|
||||
} else {
|
||||
batch.setPipeline(_simpleProgram);
|
||||
if (culled) {
|
||||
batch.setPipeline(_simpleProgram);
|
||||
} else {
|
||||
batch.setPipeline(_simpleProgramCullNone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
void init(AbstractViewStateInterface* viewState);
|
||||
|
||||
/// Sets up the state necessary to render static untextured geometry with the simple program.
|
||||
void bindSimpleProgram(gpu::Batch& batch, bool textured = false);
|
||||
void bindSimpleProgram(gpu::Batch& batch, bool textured = false, bool culled = true);
|
||||
|
||||
/// Tears down the state necessary to render static untextured geometry with the simple program.
|
||||
void releaseSimpleProgram(gpu::Batch& batch);
|
||||
|
@ -100,7 +100,9 @@ private:
|
|||
static void loadLightProgram(const char* fragSource, bool limited, ProgramObject& program, LightLocations& locations);
|
||||
|
||||
gpu::PipelinePointer _simpleProgram;
|
||||
gpu::PipelinePointer _simpleProgramCullNone;
|
||||
gpu::PipelinePointer _simpleProgramTextured;
|
||||
gpu::PipelinePointer _simpleProgramTexturedCullNone;
|
||||
|
||||
ProgramObject _directionalSkyboxLight;
|
||||
LightLocations _directionalSkyboxLightLocations;
|
||||
|
|
Loading…
Reference in a new issue