mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 09:13:28 +02:00
Working fade parameters through instanced draw calls
This commit is contained in:
parent
d055b1aa8e
commit
3316be4dea
7 changed files with 22 additions and 34 deletions
libraries
entities-renderer/src
gpu/src/gpu
render-utils/src
render/src/render
|
@ -157,7 +157,7 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
} else {
|
||||
// FIXME, support instanced multi-shape rendering using multidraw indirect
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
auto shapeKey = render::ShapeKey(args->_globalShapeKey);
|
||||
auto shapeKey = render::ShapeKey(args->_itemShapeKey);
|
||||
|
||||
assert(args->_shapePipeline != nullptr);
|
||||
|
||||
|
|
|
@ -18,4 +18,7 @@ layout(location = 4) in vec4 inTangent;
|
|||
layout(location = 5) in ivec4 inSkinClusterIndex;
|
||||
layout(location = 6) in vec4 inSkinClusterWeight;
|
||||
layout(location = 7) in vec4 inTexCoord1;
|
||||
layout(location = 8) in vec4 inTexCoord2;
|
||||
layout(location = 9) in vec4 inTexCoord3;
|
||||
layout(location = 10) in vec4 inTexCoord4;
|
||||
<@endif@>
|
||||
|
|
|
@ -155,19 +155,15 @@ in vec4 _fadeData3;
|
|||
<@endfunc@>
|
||||
|
||||
<@func declareFadeVertexInstanced()@>
|
||||
in vec4 _texCoord2;
|
||||
in vec4 _texCoord3;
|
||||
in vec4 _texCoord4;
|
||||
|
||||
out vec4 _fadeData1;
|
||||
out vec4 _fadeData2;
|
||||
out vec4 _fadeData3;
|
||||
<@endfunc@>
|
||||
|
||||
<@func passThroughFadeObjectParams()@>
|
||||
_fadeData1 = _texCoord2;
|
||||
_fadeData2 = _texCoord3;
|
||||
_fadeData3 = _texCoord4;
|
||||
_fadeData1 = inTexCoord2;
|
||||
_fadeData2 = inTexCoord3;
|
||||
_fadeData3 = inTexCoord4;
|
||||
<@endfunc@>
|
||||
|
||||
<@endif@>
|
|
@ -60,7 +60,7 @@ static const int VERTICES_PER_TRIANGLE = 3;
|
|||
static const gpu::Element POSITION_ELEMENT { gpu::VEC3, gpu::FLOAT, gpu::XYZ };
|
||||
static const gpu::Element NORMAL_ELEMENT { gpu::VEC3, gpu::FLOAT, gpu::XYZ };
|
||||
static const gpu::Element COLOR_ELEMENT { gpu::VEC4, gpu::NUINT8, gpu::RGBA };
|
||||
static const gpu::Element TEXCOORD4_ELEMENT { gpu::VEC4, gpu::HALF, gpu::XYZW };
|
||||
static const gpu::Element TEXCOORD4_ELEMENT { gpu::VEC4, gpu::FLOAT, gpu::XYZW };
|
||||
|
||||
static gpu::Stream::FormatPointer SOLID_STREAM_FORMAT;
|
||||
static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT;
|
||||
|
@ -620,7 +620,7 @@ void GeometryCache::renderWireShapeInstances(gpu::Batch& batch, Shape shape, siz
|
|||
}
|
||||
|
||||
void setupBatchFadeInstance(gpu::Batch& batch, gpu::BufferPointer colorBuffer,
|
||||
gpu::BufferPointer& fadeBuffer1, gpu::BufferPointer& fadeBuffer2, gpu::BufferPointer& fadeBuffer3) {
|
||||
gpu::BufferPointer fadeBuffer1, gpu::BufferPointer fadeBuffer2, gpu::BufferPointer fadeBuffer3) {
|
||||
gpu::BufferView colorView(colorBuffer, COLOR_ELEMENT);
|
||||
gpu::BufferView texCoord2View(fadeBuffer1, TEXCOORD4_ELEMENT);
|
||||
gpu::BufferView texCoord3View(fadeBuffer2, TEXCOORD4_ELEMENT);
|
||||
|
@ -2102,7 +2102,7 @@ void renderFadeInstances(RenderArgs* args, gpu::Batch& batch, const glm::vec4& c
|
|||
const glm::vec3& fadeNoiseOffset, const glm::vec3& fadeBaseOffset, const glm::vec3& fadeBaseInvSize, bool isWire,
|
||||
const render::ShapePipelinePointer& pipeline, GeometryCache::Shape shape) {
|
||||
// Add pipeline to name
|
||||
std::string instanceName = (isWire ? "wire_fade_shapes_" : "solid_fade_shapes_") + std::to_string(shape) + "_" + std::to_string(std::hash<render::ShapePipelinePointer>()(pipeline));
|
||||
std::string instanceName = (isWire ? "wire_shapes_" : "solid_shapes_") + std::to_string(shape) + "_" + std::to_string(std::hash<render::ShapePipelinePointer>()(pipeline));
|
||||
|
||||
// Add color to named buffer
|
||||
{
|
||||
|
|
|
@ -532,13 +532,6 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
|||
|
||||
if (_state == WAITING_TO_START) {
|
||||
if (model->isLoaded()) {
|
||||
/* // FIXME as far as I can tell this is the ONLY reason render-util depends on entities.
|
||||
if (EntityItem::getEntitiesShouldFadeFunction()()) {
|
||||
_fadeStartTime = usecTimestampNow();
|
||||
_fadeState = STATE_IN_PROGRESS;
|
||||
} else {
|
||||
_fadeState = STATE_COMPLETE;
|
||||
}*/
|
||||
_state = STARTED;
|
||||
model->setRenderItemsNeedUpdate();
|
||||
} else {
|
||||
|
@ -570,17 +563,6 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
|||
// apply material properties
|
||||
bindMaterial(batch, locations, args->_enableTexturing);
|
||||
|
||||
/* if (args->_enableFade) {
|
||||
// Apply fade effect
|
||||
if (!FadeRenderJob::bindPerItem(batch, args, _transform.getTranslation(), _fadeStartTime)) {
|
||||
_fadeState = STATE_COMPLETE;
|
||||
}
|
||||
}*/
|
||||
/* else {
|
||||
// TODO : very ugly way to update the fade state. Need to improve this with global fade manager.
|
||||
_fadeState = STATE_COMPLETE;
|
||||
}*/
|
||||
|
||||
args->_details._materialSwitches++;
|
||||
|
||||
// Draw!
|
||||
|
|
|
@ -115,7 +115,8 @@ namespace render {
|
|||
DebugFlags _debugFlags { RENDER_DEBUG_NONE };
|
||||
gpu::Batch* _batch = nullptr;
|
||||
|
||||
uint32_t _globalShapeKey { 0 };
|
||||
uint32_t _globalShapeKey{ 0 };
|
||||
uint32_t _itemShapeKey{ 0 };
|
||||
bool _enableTexturing { true };
|
||||
|
||||
bool _enableFade{ false };
|
||||
|
|
|
@ -42,6 +42,7 @@ void render::renderItems(const RenderContextPointer& renderContext, const ItemBo
|
|||
void renderShape(RenderArgs* args, const ShapePlumberPointer& shapeContext, const Item& item, const ShapeKey& globalKey) {
|
||||
assert(item.getKey().isShape());
|
||||
auto key = item.getShapeKey() | globalKey;
|
||||
args->_itemShapeKey = key._flags.to_ulong();
|
||||
if (key.isValid() && !key.hasOwnPipeline()) {
|
||||
args->_shapePipeline = shapeContext->pickPipeline(args, key);
|
||||
if (args->_shapePipeline) {
|
||||
|
@ -54,6 +55,7 @@ void renderShape(RenderArgs* args, const ShapePlumberPointer& shapeContext, cons
|
|||
} else {
|
||||
qCDebug(renderlogging) << "Item could not be rendered with invalid key" << key;
|
||||
}
|
||||
args->_itemShapeKey = 0;
|
||||
}
|
||||
|
||||
void render::renderShapes(const RenderContextPointer& renderContext,
|
||||
|
@ -85,10 +87,10 @@ void render::renderStateSortShapes(const RenderContextPointer& renderContext,
|
|||
using SortedShapes = std::unordered_map<render::ShapeKey, std::vector<Item>, render::ShapeKey::Hash, render::ShapeKey::KeyEqual>;
|
||||
SortedPipelines sortedPipelines;
|
||||
SortedShapes sortedShapes;
|
||||
std::vector<Item> ownPipelineBucket;
|
||||
std::vector< std::tuple<Item,ShapeKey> > ownPipelineBucket;
|
||||
|
||||
for (auto i = 0; i < numItemsToDraw; ++i) {
|
||||
auto item = scene->getItem(inItems[i].id);
|
||||
auto& item = scene->getItem(inItems[i].id);
|
||||
|
||||
{
|
||||
assert(item.getKey().isShape());
|
||||
|
@ -100,7 +102,7 @@ void render::renderStateSortShapes(const RenderContextPointer& renderContext,
|
|||
}
|
||||
bucket.push_back(item);
|
||||
} else if (key.hasOwnPipeline()) {
|
||||
ownPipelineBucket.push_back(item);
|
||||
ownPipelineBucket.push_back( std::make_tuple(item, key) );
|
||||
} else {
|
||||
qCDebug(renderlogging) << "Item could not be rendered with invalid key" << key;
|
||||
}
|
||||
|
@ -114,15 +116,19 @@ void render::renderStateSortShapes(const RenderContextPointer& renderContext,
|
|||
if (!args->_shapePipeline) {
|
||||
continue;
|
||||
}
|
||||
args->_itemShapeKey = pipelineKey._flags.to_ulong();
|
||||
for (auto& item : bucket) {
|
||||
args->_shapePipeline->prepareShapeItem(args, pipelineKey, item);
|
||||
item.render(args);
|
||||
}
|
||||
}
|
||||
args->_shapePipeline = nullptr;
|
||||
for (auto& item : ownPipelineBucket) {
|
||||
for (auto& itemAndKey : ownPipelineBucket) {
|
||||
auto& item = std::get<0>(itemAndKey);
|
||||
args->_itemShapeKey = std::get<1>(itemAndKey)._flags.to_ulong();
|
||||
item.render(args);
|
||||
}
|
||||
args->_itemShapeKey = 0;
|
||||
}
|
||||
|
||||
void DrawLight::run(const RenderContextPointer& renderContext, const ItemBounds& inLights) {
|
||||
|
|
Loading…
Reference in a new issue