mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 03:04:40 +02:00
working on fading shape entities
This commit is contained in:
parent
d63a0ef08f
commit
2eb0c7735f
16 changed files with 81 additions and 56 deletions
|
@ -776,7 +776,7 @@ void Avatar::renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const
|
||||||
|
|
||||||
{
|
{
|
||||||
PROFILE_RANGE_BATCH(batch, __FUNCTION__":renderBevelCornersRect");
|
PROFILE_RANGE_BATCH(batch, __FUNCTION__":renderBevelCornersRect");
|
||||||
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, false, true, true, true);
|
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, false, false, true, true, true);
|
||||||
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(batch, left, bottom, width, height,
|
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(batch, left, bottom, width, height,
|
||||||
bevelDistance, backgroundColor);
|
bevelDistance, backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
auto pipeline = args->_pipeline;
|
auto pipeline = args->_pipeline;
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
pipeline = _isSolid ? geometryCache->getShapePipeline() : geometryCache->getWireShapePipeline();
|
pipeline = _isSolid ? geometryCache->getOpaqueShapePipeline() : geometryCache->getWireShapePipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isSolid) {
|
if (_isSolid) {
|
||||||
|
@ -55,7 +55,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
|
||||||
batch->setModelTransform(transform);
|
batch->setModelTransform(transform);
|
||||||
geometryCache->renderSolidCubeInstance(*batch, cubeColor, pipeline);
|
geometryCache->renderSolidCubeInstance(*batch, cubeColor, pipeline);
|
||||||
} else {
|
} else {
|
||||||
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
|
geometryCache->bindSimpleProgram(*batch, false, false, false, true, true);
|
||||||
if (getIsDashedLine()) {
|
if (getIsDashedLine()) {
|
||||||
transform.setScale(1.0f);
|
transform.setScale(1.0f);
|
||||||
batch->setModelTransform(transform);
|
batch->setModelTransform(transform);
|
||||||
|
|
|
@ -57,12 +57,12 @@ void Line3DOverlay::render(RenderArgs* args) {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
if (getIsDashedLine()) {
|
if (getIsDashedLine()) {
|
||||||
// TODO: add support for color to renderDashedLine()
|
// TODO: add support for color to renderDashedLine()
|
||||||
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
|
geometryCache->bindSimpleProgram(*batch, false, false, false, true, true);
|
||||||
geometryCache->renderDashedLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
geometryCache->renderDashedLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
||||||
} else if (_glow > 0.0f) {
|
} else if (_glow > 0.0f) {
|
||||||
geometryCache->renderGlowLine(*batch, _start, _end, colorv4, _glow, _glowWidth, _geometryCacheID);
|
geometryCache->renderGlowLine(*batch, _start, _end, colorv4, _glow, _glowWidth, _geometryCacheID);
|
||||||
} else {
|
} else {
|
||||||
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
|
geometryCache->bindSimpleProgram(*batch, false, false, false, true, true);
|
||||||
geometryCache->renderLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
geometryCache->renderLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
||||||
geometryCache->bindSimpleProgram(*batch);
|
geometryCache->bindSimpleProgram(*batch);
|
||||||
geometryCache->renderQuad(*batch, topLeft, bottomRight, rectangleColor);
|
geometryCache->renderQuad(*batch, topLeft, bottomRight, rectangleColor);
|
||||||
} else {
|
} else {
|
||||||
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
|
geometryCache->bindSimpleProgram(*batch, false, false, false, true, true);
|
||||||
if (getIsDashedLine()) {
|
if (getIsDashedLine()) {
|
||||||
glm::vec3 point1(-halfDimensions.x, -halfDimensions.y, 0.0f);
|
glm::vec3 point1(-halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||||
glm::vec3 point2(halfDimensions.x, -halfDimensions.y, 0.0f);
|
glm::vec3 point2(halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||||
|
|
|
@ -47,7 +47,7 @@ void Shape3DOverlay::render(RenderArgs* args) {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
auto pipeline = args->_pipeline;
|
auto pipeline = args->_pipeline;
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
pipeline = _isSolid ? geometryCache->getShapePipeline() : geometryCache->getWireShapePipeline();
|
pipeline = _isSolid ? geometryCache->getOpaqueShapePipeline() : geometryCache->getWireShapePipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.setScale(dimensions);
|
transform.setScale(dimensions);
|
||||||
|
|
|
@ -46,7 +46,7 @@ void Sphere3DOverlay::render(RenderArgs* args) {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
auto pipeline = args->_pipeline;
|
auto pipeline = args->_pipeline;
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
pipeline = _isSolid ? geometryCache->getShapePipeline() : geometryCache->getWireShapePipeline();
|
pipeline = _isSolid ? geometryCache->getOpaqueShapePipeline() : geometryCache->getWireShapePipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isSolid) {
|
if (_isSolid) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ void Web3DOverlay::render(RenderArgs* args) {
|
||||||
|
|
||||||
batch.setModelTransform(transform);
|
batch.setModelTransform(transform);
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
geometryCache->bindSimpleProgram(batch, true, false, true, false);
|
geometryCache->bindSimpleProgram(batch, true, false, false, true, false);
|
||||||
geometryCache->renderQuad(batch, halfSize * -1.0f, halfSize, vec2(0), vec2(1), color);
|
geometryCache->renderQuad(batch, halfSize * -1.0f, halfSize, vec2(0), vec2(1), color);
|
||||||
batch.setResourceTexture(0, args->_whiteTexture); // restore default white color after me
|
batch.setResourceTexture(0, args->_whiteTexture); // restore default white color after me
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,16 +105,12 @@ void RenderableShapeEntityItem::render(RenderArgs* args) {
|
||||||
DependencyManager::get<GeometryCache>()->renderShape(batch, MAPPING[_shape]);
|
DependencyManager::get<GeometryCache>()->renderShape(batch, MAPPING[_shape]);
|
||||||
} else {
|
} else {
|
||||||
// FIXME, support instanced multi-shape rendering using multidraw indirect
|
// FIXME, support instanced multi-shape rendering using multidraw indirect
|
||||||
float fadeRatio = Interpolate::calculateFadeRatio(_fadeStartTime);
|
color.a *= Interpolate::calculateFadeRatio(_fadeStartTime);
|
||||||
if (fadeRatio < 1.0f) {
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
color = glm::vec4(0.0f, 0.0f, 1.0f, 0.5f);
|
auto pipeline = color.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline();
|
||||||
DependencyManager::get<GeometryCache>()->renderSolidShapeInstance(batch, MAPPING[_shape], color);
|
geometryCache->renderSolidShapeInstance(batch, MAPPING[_shape], color, pipeline);
|
||||||
} else {
|
|
||||||
DependencyManager::get<GeometryCache>()->renderSolidShapeInstance(batch, MAPPING[_shape], color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const auto triCount = DependencyManager::get<GeometryCache>()->getShapeTriangleCount(MAPPING[_shape]);
|
static const auto triCount = DependencyManager::get<GeometryCache>()->getShapeTriangleCount(MAPPING[_shape]);
|
||||||
args->_details._trianglesRendered += (int)triCount;
|
args->_details._trianglesRendered += (int)triCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
static EntityItemPointer boxFactory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItemPointer boxFactory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
static EntityItemPointer sphereFactory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItemPointer sphereFactory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
RenderableShapeEntityItem(const EntityItemID& entityItemID) : ShapeEntityItem(entityItemID), _fadeStartTime(usecTimestampNow()) {}
|
RenderableShapeEntityItem(const EntityItemID& entityItemID) : ShapeEntityItem(entityItemID) {}
|
||||||
|
|
||||||
void render(RenderArgs* args) override;
|
void render(RenderArgs* args) override;
|
||||||
void setUserData(const QString& value) override;
|
void setUserData(const QString& value) override;
|
||||||
|
@ -33,7 +33,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<Procedural> _procedural;
|
QSharedPointer<Procedural> _procedural;
|
||||||
quint64 _fadeStartTime { 0 };
|
quint64 _fadeStartTime { usecTimestampNow() };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
||||||
|
|
||||||
batch.setModelTransform(transformToTopLeft);
|
batch.setModelTransform(transformToTopLeft);
|
||||||
|
|
||||||
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, false, false, false, true);
|
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, false, false, false, false, true);
|
||||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, minCorner, maxCorner, backgroundColor);
|
DependencyManager::get<GeometryCache>()->renderQuad(batch, minCorner, maxCorner, backgroundColor);
|
||||||
|
|
||||||
float scale = _lineHeight / _textRenderer->getFontSize();
|
float scale = _lineHeight / _textRenderer->getFontSize();
|
||||||
|
|
|
@ -208,8 +208,9 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
||||||
batch._glActiveBindTexture(GL_TEXTURE0, GL_TEXTURE_2D, _texture);
|
batch._glActiveBindTexture(GL_TEXTURE0, GL_TEXTURE_2D, _texture);
|
||||||
textured = emissive = true;
|
textured = emissive = true;
|
||||||
}
|
}
|
||||||
|
bool transparent = false;
|
||||||
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, textured, culled, emissive);
|
|
||||||
|
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, textured, transparent, culled, emissive);
|
||||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, 0.0f));
|
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, 0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
_fragColor0 = vec4(albedo.rgb, alpha);
|
_fragColor0 = vec4(albedo.rgb, alpha);
|
||||||
|
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -397,14 +397,25 @@ gpu::Stream::FormatPointer& getInstancedSolidStreamFormat() {
|
||||||
return INSTANCED_SOLID_STREAM_FORMAT;
|
return INSTANCED_SOLID_STREAM_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
render::ShapePipelinePointer GeometryCache::_simplePipeline;
|
render::ShapePipelinePointer GeometryCache::_simpleOpaquePipeline;
|
||||||
|
render::ShapePipelinePointer GeometryCache::_simpleTransparentPipeline;
|
||||||
render::ShapePipelinePointer GeometryCache::_simpleWirePipeline;
|
render::ShapePipelinePointer GeometryCache::_simpleWirePipeline;
|
||||||
|
|
||||||
GeometryCache::GeometryCache() :
|
GeometryCache::GeometryCache() :
|
||||||
_nextID(0) {
|
_nextID(0) {
|
||||||
buildShapes();
|
buildShapes();
|
||||||
GeometryCache::_simplePipeline =
|
GeometryCache::_simpleOpaquePipeline =
|
||||||
std::make_shared<render::ShapePipeline>(getSimplePipeline(), nullptr,
|
std::make_shared<render::ShapePipeline>(getSimplePipeline(false, false, true, false), nullptr,
|
||||||
|
[](const render::ShapePipeline&, gpu::Batch& batch) {
|
||||||
|
// Set the defaults needed for a simple program
|
||||||
|
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||||
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
|
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
|
||||||
|
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
GeometryCache::_simpleTransparentPipeline =
|
||||||
|
std::make_shared<render::ShapePipeline>(getSimplePipeline(false, true, true, false), nullptr,
|
||||||
[](const render::ShapePipeline&, gpu::Batch& batch) {
|
[](const render::ShapePipeline&, gpu::Batch& batch) {
|
||||||
// Set the defaults needed for a simple program
|
// Set the defaults needed for a simple program
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||||
|
@ -1703,6 +1714,7 @@ class SimpleProgramKey {
|
||||||
public:
|
public:
|
||||||
enum FlagBit {
|
enum FlagBit {
|
||||||
IS_TEXTURED_FLAG = 0,
|
IS_TEXTURED_FLAG = 0,
|
||||||
|
IS_TRANSPARENT_FLAG,
|
||||||
IS_CULLED_FLAG,
|
IS_CULLED_FLAG,
|
||||||
IS_UNLIT_FLAG,
|
IS_UNLIT_FLAG,
|
||||||
HAS_DEPTH_BIAS_FLAG,
|
HAS_DEPTH_BIAS_FLAG,
|
||||||
|
@ -1712,6 +1724,7 @@ public:
|
||||||
|
|
||||||
enum Flag {
|
enum Flag {
|
||||||
IS_TEXTURED = (1 << IS_TEXTURED_FLAG),
|
IS_TEXTURED = (1 << IS_TEXTURED_FLAG),
|
||||||
|
IS_TRANSPARENT = (1 << IS_TRANSPARENT_FLAG),
|
||||||
IS_CULLED = (1 << IS_CULLED_FLAG),
|
IS_CULLED = (1 << IS_CULLED_FLAG),
|
||||||
IS_UNLIT = (1 << IS_UNLIT_FLAG),
|
IS_UNLIT = (1 << IS_UNLIT_FLAG),
|
||||||
HAS_DEPTH_BIAS = (1 << HAS_DEPTH_BIAS_FLAG),
|
HAS_DEPTH_BIAS = (1 << HAS_DEPTH_BIAS_FLAG),
|
||||||
|
@ -1721,6 +1734,7 @@ public:
|
||||||
bool isFlag(short flagNum) const { return bool((_flags & flagNum) != 0); }
|
bool isFlag(short flagNum) const { return bool((_flags & flagNum) != 0); }
|
||||||
|
|
||||||
bool isTextured() const { return isFlag(IS_TEXTURED); }
|
bool isTextured() const { return isFlag(IS_TEXTURED); }
|
||||||
|
bool isTransparent() const { return isFlag(IS_TRANSPARENT); }
|
||||||
bool isCulled() const { return isFlag(IS_CULLED); }
|
bool isCulled() const { return isFlag(IS_CULLED); }
|
||||||
bool isUnlit() const { return isFlag(IS_UNLIT); }
|
bool isUnlit() const { return isFlag(IS_UNLIT); }
|
||||||
bool hasDepthBias() const { return isFlag(HAS_DEPTH_BIAS); }
|
bool hasDepthBias() const { return isFlag(HAS_DEPTH_BIAS); }
|
||||||
|
@ -1731,9 +1745,9 @@ public:
|
||||||
int getRaw() const { return *reinterpret_cast<const int*>(this); }
|
int getRaw() const { return *reinterpret_cast<const int*>(this); }
|
||||||
|
|
||||||
|
|
||||||
SimpleProgramKey(bool textured = false, bool culled = true,
|
SimpleProgramKey(bool textured = false, bool transparent = false, bool culled = true,
|
||||||
bool unlit = false, bool depthBias = false) {
|
bool unlit = false, bool depthBias = false) {
|
||||||
_flags = (textured ? IS_TEXTURED : 0) | (culled ? IS_CULLED : 0) |
|
_flags = (textured ? IS_TEXTURED : 0) | (transparent ? IS_TRANSPARENT : 0) | (culled ? IS_CULLED : 0) |
|
||||||
(unlit ? IS_UNLIT : 0) | (depthBias ? HAS_DEPTH_BIAS : 0);
|
(unlit ? IS_UNLIT : 0) | (depthBias ? HAS_DEPTH_BIAS : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1748,8 +1762,8 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) {
|
||||||
return a.getRaw() == b.getRaw();
|
return a.getRaw() == b.getRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled, bool unlit, bool depthBiased) {
|
void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) {
|
||||||
batch.setPipeline(getSimplePipeline(textured, culled, unlit, depthBiased));
|
batch.setPipeline(getSimplePipeline(textured, transparent, culled, unlit, depthBiased));
|
||||||
|
|
||||||
// If not textured, set a default albedo map
|
// If not textured, set a default albedo map
|
||||||
if (!textured) {
|
if (!textured) {
|
||||||
|
@ -1761,8 +1775,8 @@ void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool cul
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool culled, bool unlit, bool depthBiased) {
|
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) {
|
||||||
SimpleProgramKey config { textured, culled, unlit, depthBiased };
|
SimpleProgramKey config { textured, transparent, culled, unlit, depthBiased };
|
||||||
|
|
||||||
// Compile the shaders
|
// Compile the shaders
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
|
@ -1798,7 +1812,7 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool culled
|
||||||
state->setDepthBias(1.0f);
|
state->setDepthBias(1.0f);
|
||||||
state->setDepthBiasSlopeScale(1.0f);
|
state->setDepthBiasSlopeScale(1.0f);
|
||||||
}
|
}
|
||||||
state->setBlendFunction(false,
|
state->setBlendFunction(config.isTransparent(),
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
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::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||||
|
|
||||||
|
|
|
@ -152,12 +152,13 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// Bind the pipeline and get the state to render static geometry
|
// Bind the pipeline and get the state to render static geometry
|
||||||
void bindSimpleProgram(gpu::Batch& batch, bool textured = false, bool culled = true,
|
void bindSimpleProgram(gpu::Batch& batch, bool textured = false, bool transparent = false, bool culled = true,
|
||||||
bool unlit = false, bool depthBias = false);
|
bool unlit = false, bool depthBias = false);
|
||||||
// Get the pipeline to render static geometry
|
// Get the pipeline to render static geometry
|
||||||
gpu::PipelinePointer getSimplePipeline(bool textured = false, bool culled = true,
|
gpu::PipelinePointer getSimplePipeline(bool textured = false, bool transparent = false, bool culled = true,
|
||||||
bool unlit = false, bool depthBias = false);
|
bool unlit = false, bool depthBias = false);
|
||||||
render::ShapePipelinePointer getShapePipeline() { return GeometryCache::_simplePipeline; }
|
render::ShapePipelinePointer getOpaqueShapePipeline() { return GeometryCache::_simpleOpaquePipeline; }
|
||||||
|
render::ShapePipelinePointer getTransparentShapePipeline() { return GeometryCache::_simpleTransparentPipeline; }
|
||||||
render::ShapePipelinePointer getWireShapePipeline() { return GeometryCache::_simpleWirePipeline; }
|
render::ShapePipelinePointer getWireShapePipeline() { return GeometryCache::_simpleWirePipeline; }
|
||||||
|
|
||||||
// Static (instanced) geometry
|
// Static (instanced) geometry
|
||||||
|
@ -165,42 +166,42 @@ public:
|
||||||
void renderWireShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer);
|
void renderWireShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer);
|
||||||
|
|
||||||
void renderSolidShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec4& color = glm::vec4(1),
|
void renderSolidShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec4& color = glm::vec4(1),
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline);
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
|
||||||
void renderSolidShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec3& color,
|
void renderSolidShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec3& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline) {
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
|
||||||
renderSolidShapeInstance(batch, shape, glm::vec4(color, 1.0f), pipeline);
|
renderSolidShapeInstance(batch, shape, glm::vec4(color, 1.0f), pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderWireShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec4& color = glm::vec4(1),
|
void renderWireShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec4& color = glm::vec4(1),
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline);
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
|
||||||
void renderWireShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec3& color,
|
void renderWireShapeInstance(gpu::Batch& batch, Shape shape, const glm::vec3& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline) {
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
|
||||||
renderWireShapeInstance(batch, shape, glm::vec4(color, 1.0f), pipeline);
|
renderWireShapeInstance(batch, shape, glm::vec4(color, 1.0f), pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderSolidSphereInstance(gpu::Batch& batch, const glm::vec4& color,
|
void renderSolidSphereInstance(gpu::Batch& batch, const glm::vec4& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline);
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
|
||||||
void renderSolidSphereInstance(gpu::Batch& batch, const glm::vec3& color,
|
void renderSolidSphereInstance(gpu::Batch& batch, const glm::vec3& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline) {
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
|
||||||
renderSolidSphereInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
renderSolidSphereInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderWireSphereInstance(gpu::Batch& batch, const glm::vec4& color,
|
void renderWireSphereInstance(gpu::Batch& batch, const glm::vec4& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline);
|
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline);
|
||||||
void renderWireSphereInstance(gpu::Batch& batch, const glm::vec3& color,
|
void renderWireSphereInstance(gpu::Batch& batch, const glm::vec3& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline) {
|
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline) {
|
||||||
renderWireSphereInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
renderWireSphereInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderSolidCubeInstance(gpu::Batch& batch, const glm::vec4& color,
|
void renderSolidCubeInstance(gpu::Batch& batch, const glm::vec4& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline);
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
|
||||||
void renderSolidCubeInstance(gpu::Batch& batch, const glm::vec3& color,
|
void renderSolidCubeInstance(gpu::Batch& batch, const glm::vec3& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline) {
|
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
|
||||||
renderSolidCubeInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
renderSolidCubeInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderWireCubeInstance(gpu::Batch& batch, const glm::vec4& color,
|
void renderWireCubeInstance(gpu::Batch& batch, const glm::vec4& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simplePipeline);
|
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline);
|
||||||
void renderWireCubeInstance(gpu::Batch& batch, const glm::vec3& color,
|
void renderWireCubeInstance(gpu::Batch& batch, const glm::vec3& color,
|
||||||
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline) {
|
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline) {
|
||||||
renderWireCubeInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
renderWireCubeInstance(batch, glm::vec4(color, 1.0f), pipeline);
|
||||||
|
@ -412,7 +413,8 @@ private:
|
||||||
|
|
||||||
gpu::ShaderPointer _simpleShader;
|
gpu::ShaderPointer _simpleShader;
|
||||||
gpu::ShaderPointer _unlitShader;
|
gpu::ShaderPointer _unlitShader;
|
||||||
static render::ShapePipelinePointer _simplePipeline;
|
static render::ShapePipelinePointer _simpleOpaquePipeline;
|
||||||
|
static render::ShapePipelinePointer _simpleTransparentPipeline;
|
||||||
static render::ShapePipelinePointer _simpleWirePipeline;
|
static render::ShapePipelinePointer _simpleWirePipeline;
|
||||||
gpu::PipelinePointer _glowLinePipeline;
|
gpu::PipelinePointer _glowLinePipeline;
|
||||||
QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
|
QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
|
||||||
|
|
|
@ -29,13 +29,23 @@ void main(void) {
|
||||||
if (_color.a <= 0.0) {
|
if (_color.a <= 0.0) {
|
||||||
texel = colorToLinearRGBA(texel);
|
texel = colorToLinearRGBA(texel);
|
||||||
}
|
}
|
||||||
packDeferredFragment(
|
|
||||||
normalize(_normal.xyz),
|
if (_color.a * texel.a < 1.0) {
|
||||||
texel.a,
|
packDeferredFragmentTranslucent(
|
||||||
_color.rgb * texel.rgb,
|
normalize(_normal),
|
||||||
DEFAULT_ROUGHNESS,
|
_color.a * texel.a,
|
||||||
DEFAULT_METALLIC,
|
_color.rgb * texel.rgb,
|
||||||
DEFAULT_EMISSIVE,
|
DEFAULT_FRESNEL,
|
||||||
DEFAULT_OCCLUSION,
|
DEFAULT_ROUGHNESS);
|
||||||
DEFAULT_SCATTERING);
|
} else {
|
||||||
|
packDeferredFragment(
|
||||||
|
normalize(_normal),
|
||||||
|
1.0,
|
||||||
|
_color.rgb * texel.rgb,
|
||||||
|
DEFAULT_ROUGHNESS,
|
||||||
|
DEFAULT_METALLIC,
|
||||||
|
DEFAULT_EMISSIVE,
|
||||||
|
DEFAULT_OCCLUSION,
|
||||||
|
DEFAULT_SCATTERING);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -78,7 +78,7 @@ void FloorTextureTest::renderTest(size_t testId, RenderArgs* args) {
|
||||||
texture->incremementMinMip();
|
texture->incremementMinMip();
|
||||||
}
|
}
|
||||||
|
|
||||||
geometryCache->bindSimpleProgram(batch, true, true, true);
|
geometryCache->bindSimpleProgram(batch, true, false, true, true);
|
||||||
batch.setInputBuffer(0, vertexBuffer, 0, sizeof(Vertex));
|
batch.setInputBuffer(0, vertexBuffer, 0, sizeof(Vertex));
|
||||||
batch.setInputFormat(vertexFormat);
|
batch.setInputFormat(vertexFormat);
|
||||||
batch.setIndexBuffer(gpu::UINT16, indexBuffer, 0);
|
batch.setIndexBuffer(gpu::UINT16, indexBuffer, 0);
|
||||||
|
|
Loading…
Reference in a new issue