mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 09:53:59 +02:00
Fading on polyline now works when the polyline is added to the scene
This commit is contained in:
parent
b652d94a43
commit
a50c267d0b
5 changed files with 18 additions and 18 deletions
libraries
entities-renderer/src
RenderablePolyLineEntityItem.cppRenderablePolyLineEntityItem.hRenderableShapeEntityItem.cpppaintStroke_fade.slf
render-utils/src
|
@ -16,6 +16,7 @@
|
|||
#include <TextureCache.h>
|
||||
#include <PathUtils.h>
|
||||
#include <PerfStat.h>
|
||||
#include <FadeEffect.h>
|
||||
|
||||
#include "RenderablePolyLineEntityItem.h"
|
||||
|
||||
|
@ -46,6 +47,8 @@ render::ShapePipelinePointer PolyLinePayload::shapePipelineFactory(const render:
|
|||
slotBindings.insert(gpu::Shader::Binding(std::string("originalTexture"), PAINTSTROKE_TEXTURE_SLOT));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("polyLineBuffer"), PAINTSTROKE_UNIFORM_SLOT));
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("fadeMaskMap"), PAINTSTROKE_TEXTURE_SLOT + 1));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("fadeParametersBuffer"), PAINTSTROKE_UNIFORM_SLOT+1));
|
||||
gpu::Shader::makeProgram(*fadeProgram, slotBindings);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
@ -59,7 +62,8 @@ render::ShapePipelinePointer PolyLinePayload::shapePipelineFactory(const render:
|
|||
}
|
||||
|
||||
if (key.isFaded()) {
|
||||
return std::make_shared<render::ShapePipeline>(_fadePipeline, nullptr, nullptr, nullptr);
|
||||
auto fadeEffect = DependencyManager::get<FadeEffect>();
|
||||
return std::make_shared<render::ShapePipeline>(_fadePipeline, nullptr, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
|
||||
} else {
|
||||
return std::make_shared<render::ShapePipeline>(_pipeline, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
@ -201,10 +205,7 @@ void RenderablePolyLineEntityItem::updateVertices() {
|
|||
|
||||
}
|
||||
|
||||
void RenderablePolyLineEntityItem::update(const quint64& now) {
|
||||
PolyLineUniforms uniforms;
|
||||
uniforms.color = toGlm(getXColor());
|
||||
memcpy(&_uniformBuffer.edit<PolyLineUniforms>(), &uniforms, sizeof(PolyLineUniforms));
|
||||
void RenderablePolyLineEntityItem::updateMesh() {
|
||||
if (_pointsChanged || _strokeWidthsChanged || _normalsChanged) {
|
||||
QWriteLocker lock(&_quadReadWriteLock);
|
||||
_empty = (_points.size() < 2 || _normals.size() < 2 || _strokeWidths.size() < 2);
|
||||
|
@ -213,7 +214,13 @@ void RenderablePolyLineEntityItem::update(const quint64& now) {
|
|||
updateGeometry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePolyLineEntityItem::update(const quint64& now) {
|
||||
PolyLineUniforms uniforms;
|
||||
uniforms.color = toGlm(getXColor());
|
||||
memcpy(&_uniformBuffer.edit<PolyLineUniforms>(), &uniforms, sizeof(PolyLineUniforms));
|
||||
updateMesh();
|
||||
}
|
||||
|
||||
bool RenderablePolyLineEntityItem::addToScene(const EntityItemPointer& self,
|
||||
|
@ -230,13 +237,12 @@ bool RenderablePolyLineEntityItem::addToScene(const EntityItemPointer& self,
|
|||
|
||||
transaction.resetItem(_myItem, renderPayload);
|
||||
transaction.addTransitionToItem(_myItem, render::Transition::ELEMENT_ENTER_DOMAIN);
|
||||
updateMesh();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderablePolyLineEntityItem::render(RenderArgs* args) {
|
||||
checkFading();
|
||||
|
||||
if (_empty) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
protected:
|
||||
void updateGeometry();
|
||||
void updateVertices();
|
||||
void updateMesh();
|
||||
|
||||
static void createStreamFormat();
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ void RenderableShapeEntityItem::setUserData(const QString& value) {
|
|||
}
|
||||
|
||||
bool RenderableShapeEntityItem::isTransparent() {
|
||||
return getLocalRenderAlpha() < 1.0f || EntityItem::isTransparent();
|
||||
return getLocalRenderAlpha() < 1.0f;
|
||||
}
|
||||
|
||||
namespace render {
|
||||
|
@ -121,7 +121,6 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
|||
PerformanceTimer perfTimer("RenderableShapeEntityItem::render");
|
||||
//Q_ASSERT(getType() == EntityTypes::Shape);
|
||||
Q_ASSERT(args->_batch);
|
||||
checkFading();
|
||||
|
||||
if (!_procedural) {
|
||||
_procedural.reset(new Procedural(getUserData()));
|
||||
|
|
|
@ -44,11 +44,10 @@ void main(void) {
|
|||
vec4 texel = texture(originalTexture, varTexcoord);
|
||||
int frontCondition = 1 -int(gl_FrontFacing) * 2;
|
||||
vec3 color = varColor.rgb;
|
||||
packDeferredFragmentTranslucentEmissive(
|
||||
packDeferredFragmentTranslucent(
|
||||
interpolatedNormal * frontCondition,
|
||||
texel.a * varColor.a,
|
||||
polyline.color * texel.rgb,
|
||||
polyline.color * texel.rgb + fadeEmissive,
|
||||
vec3(0.01, 0.01, 0.01),
|
||||
10.0,
|
||||
fadeEmissive);
|
||||
10.0);
|
||||
}
|
||||
|
|
|
@ -77,9 +77,4 @@ void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3
|
|||
|
||||
}
|
||||
|
||||
void packDeferredFragmentTranslucentEmissive(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness, vec3 emissive) {
|
||||
packDeferredFragmentTranslucent(normal, alpha, albedo, fresnel, roughness);
|
||||
_fragColor3 = vec4(emissive, 1.0);
|
||||
}
|
||||
|
||||
<@endif@>
|
||||
|
|
Loading…
Reference in a new issue