mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 00:33:11 +02:00
Shape entities have the correct pipeline picked when fading is activated. Still need to support instanced rendering
This commit is contained in:
parent
f8b2ffe359
commit
1f14b6ef38
11 changed files with 40 additions and 25 deletions
|
@ -839,6 +839,7 @@ render::ShapePipelinePointer PolyVoxPayload::shapePipelineFactory(const render::
|
|||
slotBindings.insert(gpu::Shader::Binding(std::string("xMap"), 0));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("yMap"), 1));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("zMap"), 2));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("fadeMaskMap"), 3));
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
state->setCullMode(gpu::State::CULL_BACK);
|
||||
|
|
|
@ -91,7 +91,12 @@ namespace render {
|
|||
}
|
||||
|
||||
template <> const ShapeKey shapeGetShapeKey(const ShapePayload::Pointer& payload) {
|
||||
return ShapeKey::Builder().withCustom(GeometryCache::CUSTOM_PIPELINE_NUMBER).build();
|
||||
auto shapeKey = ShapeKey::Builder().withCustom(GeometryCache::CUSTOM_PIPELINE_NUMBER);
|
||||
auto entity = payload->_entity;
|
||||
if (entity->getLocalRenderAlpha() < 1.f) {
|
||||
shapeKey.withTranslucent();
|
||||
}
|
||||
return shapeKey.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,14 +156,14 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
} else {
|
||||
// FIXME, support instanced multi-shape rendering using multidraw indirect
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
auto pipeline = color.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline();
|
||||
auto shapeKey = render::ShapeKey(args->_globalShapeKey);
|
||||
|
||||
assert(pipeline != nullptr);
|
||||
assert(args->_shapePipeline != nullptr);
|
||||
|
||||
if (render::ShapeKey(args->_globalShapeKey).isWireframe()) {
|
||||
geometryCache->renderWireShapeInstance(args, batch, MAPPING[_shape], color, pipeline);
|
||||
if (shapeKey.isWireframe()) {
|
||||
geometryCache->renderWireShapeInstance(args, batch, MAPPING[_shape], color, args->_shapePipeline);
|
||||
} else {
|
||||
geometryCache->renderSolidShapeInstance(args, batch, MAPPING[_shape], color, pipeline);
|
||||
geometryCache->renderSolidShapeInstance(args, batch, MAPPING[_shape], color, args->_shapePipeline);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,8 @@ render::ItemID FadeEditJob::findNearestItem(const render::RenderContextPointer&
|
|||
|
||||
for (const auto& itemBound : inputs) {
|
||||
if (!itemBound.bound.contains(rayOrigin) && itemBound.bound.findRayIntersection(rayOrigin, rayDirection, isectDistance, face, normal)) {
|
||||
if (isectDistance>minDistance && isectDistance < minIsectDistance) {
|
||||
auto& item = renderContext->_scene->getItem(itemBound.id);
|
||||
if (item.getKey().isWorldSpace() && isectDistance>minDistance && isectDistance < minIsectDistance) {
|
||||
nearestItem = itemBound.id;
|
||||
minIsectDistance = isectDistance;
|
||||
}
|
||||
|
|
|
@ -544,8 +544,8 @@ void GeometryCache::initializeShapePipelines() {
|
|||
if (!_simpleOpaquePipeline) {
|
||||
_simpleOpaquePipeline = getShapePipeline(false, false, true, false);
|
||||
_simpleTransparentPipeline = getShapePipeline(false, true, true, false);
|
||||
_simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, true, false, false);
|
||||
_simpleTransparentFadePipeline = getFadingShapePipeline(false, true, true, false, false);
|
||||
_simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, false, false, false);
|
||||
_simpleTransparentFadePipeline = getFadingShapePipeline(false, true, false, false, false);
|
||||
_simpleWirePipeline = getShapePipeline(false, false, true, true);
|
||||
}
|
||||
}
|
||||
|
@ -554,10 +554,8 @@ render::ShapePipelinePointer GeometryCache::getShapePipeline(bool textured, bool
|
|||
bool unlit, bool depthBias) {
|
||||
|
||||
return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, false), nullptr,
|
||||
[](const render::ShapePipeline&, gpu::Batch& batch, render::Args*) {
|
||||
// Set the defaults needed for a simple program
|
||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||
[](const render::ShapePipeline& , gpu::Batch& batch, render::Args*) {
|
||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO, DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -568,11 +566,9 @@ render::ShapePipelinePointer GeometryCache::getFadingShapePipeline(bool textured
|
|||
auto fadeBatchSetter = fadeEffect->getBatchSetter();
|
||||
auto fadeItemSetter = fadeEffect->getItemSetter();
|
||||
return std::make_shared<render::ShapePipeline>(getSimplePipeline(textured, transparent, culled, unlit, depthBias, true), nullptr,
|
||||
[fadeBatchSetter, fadeItemSetter](const render::ShapePipeline& pipeline, gpu::Batch& batch, render::Args* args) {
|
||||
// Set the defaults needed for a simple program
|
||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||
fadeBatchSetter(pipeline, batch, args);
|
||||
[fadeBatchSetter, fadeItemSetter](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args* args) {
|
||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO, DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||
fadeBatchSetter(shapePipeline, batch, args);
|
||||
},
|
||||
fadeItemSetter
|
||||
);
|
||||
|
@ -1970,6 +1966,7 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
|
|||
_unlitShader = gpu::Shader::createProgram(VS, PSUnlit);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("originalTexture"), render::ShapePipeline::Slot::MAP::ALBEDO));
|
||||
gpu::Shader::makeProgram(*_simpleShader, slotBindings);
|
||||
gpu::Shader::makeProgram(*_unlitShader, slotBindings);
|
||||
});
|
||||
|
@ -1984,6 +1981,8 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
|
|||
_unlitFadeShader = gpu::Shader::createProgram(VS, PSUnlit);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("originalTexture"), render::ShapePipeline::Slot::MAP::ALBEDO));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("fadeMaskMap"), render::ShapePipeline::Slot::MAP::FADE_MASK));
|
||||
gpu::Shader::makeProgram(*_simpleFadeShader, slotBindings);
|
||||
gpu::Shader::makeProgram(*_unlitFadeShader, slotBindings);
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@ void main(void) {
|
|||
vec3 specular = DEFAULT_SPECULAR;
|
||||
float shininess = DEFAULT_SHININESS;
|
||||
float emissiveAmount = 0.0;
|
||||
|
||||
|
||||
#ifdef PROCEDURAL
|
||||
|
||||
#ifdef PROCEDURAL_V1
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// simple_fade.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/045/17.
|
||||
// Created by Olivier Prat on 06/04/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
<@include model/Material.slh@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
// the albedo texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
@ -28,6 +27,9 @@ in vec4 _color;
|
|||
in vec2 _texCoord0;
|
||||
in vec4 _worldPosition;
|
||||
|
||||
// Declare after all samplers to prevent sampler location mix up with originalTexture
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
// the albedo texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
@ -27,6 +26,9 @@ in vec4 _color;
|
|||
in vec2 _texCoord0;
|
||||
in vec4 _worldPosition;
|
||||
|
||||
// Declare after all samplers to prevent sampler location mix up with originalTexture
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<$declareStandardCameraTransform()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
// the albedo texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
@ -34,6 +33,9 @@ in vec4 _color;
|
|||
in vec2 _texCoord0;
|
||||
in vec4 _worldPosition;
|
||||
|
||||
// Declare after all samplers to prevent sampler location mix up with originalTexture
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
<@include gpu/Color.slh@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
// the albedo texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
@ -28,6 +27,9 @@ in vec4 _worldPosition;
|
|||
|
||||
layout(location = 0) out vec4 _fragColor0;
|
||||
|
||||
// Declare after all samplers to prevent sampler location mix up with originalTexture
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ void Item::resetPayload(const PayloadPointer& payload) {
|
|||
|
||||
const ShapeKey Item::getShapeKey() const {
|
||||
auto shapeKey = _payload->getShapeKey();
|
||||
if (_transitionId != TransitionStage::INVALID_INDEX) {
|
||||
if (!TransitionStage::isIndexInvalid(_transitionId)) {
|
||||
// Objects that are fading are rendered double-sided to give a sense of volume
|
||||
return ShapeKey::Builder(shapeKey).withFade().withoutCullFace();
|
||||
}
|
||||
return shapeKey;
|
||||
|
|
Loading…
Reference in a new issue