mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
Merge pull request #9784 from samcake/blue
Fixing Emissive on overlay for models (opaque and transparent)
This commit is contained in:
commit
1b8f6b9835
16 changed files with 372 additions and 114 deletions
|
@ -62,7 +62,11 @@ namespace render {
|
||||||
if (overlay->is3D()) {
|
if (overlay->is3D()) {
|
||||||
auto overlay3D = std::dynamic_pointer_cast<Base3DOverlay>(overlay);
|
auto overlay3D = std::dynamic_pointer_cast<Base3DOverlay>(overlay);
|
||||||
if (overlay3D->isAA())
|
if (overlay3D->isAA())
|
||||||
return (overlay3D->getDrawInFront() ? LAYER_3D_FRONT : LAYER_3D);
|
if (overlay3D->getDrawInFront()) {
|
||||||
|
return LAYER_3D_FRONT;
|
||||||
|
} else {
|
||||||
|
return LAYER_3D;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return LAYER_NO_AA;
|
return LAYER_NO_AA;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -154,14 +154,6 @@ const gpu::TexturePointer& TextureCache::getBlackTexture() {
|
||||||
return _blackTexture;
|
return _blackTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const gpu::TexturePointer& TextureCache::getNormalFittingTexture() {
|
|
||||||
if (!_normalFittingTexture) {
|
|
||||||
_normalFittingTexture = getImageTexture(PathUtils::resourcesPath() + "images/normalFittingScale.dds");
|
|
||||||
}
|
|
||||||
return _normalFittingTexture;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extra data for creating textures.
|
/// Extra data for creating textures.
|
||||||
class TextureExtra {
|
class TextureExtra {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -124,9 +124,6 @@ public:
|
||||||
/// Returns the a black texture (useful for a default).
|
/// Returns the a black texture (useful for a default).
|
||||||
const gpu::TexturePointer& getBlackTexture();
|
const gpu::TexturePointer& getBlackTexture();
|
||||||
|
|
||||||
// Returns a map used to compress the normals through a fitting scale algorithm
|
|
||||||
const gpu::TexturePointer& getNormalFittingTexture();
|
|
||||||
|
|
||||||
/// Returns a texture version of an image file
|
/// Returns a texture version of an image file
|
||||||
static gpu::TexturePointer getImageTexture(const QString& path, Type type = Type::DEFAULT_TEXTURE, QVariantMap options = QVariantMap());
|
static gpu::TexturePointer getImageTexture(const QString& path, Type type = Type::DEFAULT_TEXTURE, QVariantMap options = QVariantMap());
|
||||||
|
|
||||||
|
@ -151,7 +148,6 @@ private:
|
||||||
gpu::TexturePointer _grayTexture;
|
gpu::TexturePointer _grayTexture;
|
||||||
gpu::TexturePointer _blueTexture;
|
gpu::TexturePointer _blueTexture;
|
||||||
gpu::TexturePointer _blackTexture;
|
gpu::TexturePointer _blackTexture;
|
||||||
gpu::TexturePointer _normalFittingTexture;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_TextureCache_h
|
#endif // hifi_TextureCache_h
|
||||||
|
|
|
@ -65,25 +65,4 @@ float packUnlit() {
|
||||||
return FRAG_PACK_UNLIT;
|
return FRAG_PACK_UNLIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
<!
|
|
||||||
uniform sampler2D normalFittingMap;
|
|
||||||
|
|
||||||
vec3 bestFitNormal(vec3 normal) {
|
|
||||||
vec3 absNorm = abs(normal);
|
|
||||||
float maxNAbs = max(absNorm.z, max(absNorm.x, absNorm.y));
|
|
||||||
|
|
||||||
vec2 texcoord = (absNorm.z < maxNAbs ?
|
|
||||||
(absNorm.y < maxNAbs ? absNorm.yz : absNorm.xz) :
|
|
||||||
absNorm.xy);
|
|
||||||
texcoord = (texcoord.x < texcoord.y ? texcoord.yx : texcoord.xy);
|
|
||||||
texcoord.y /= texcoord.x;
|
|
||||||
vec3 cN = normal / maxNAbs;
|
|
||||||
|
|
||||||
float fittingScale = texture(normalFittingMap, texcoord).a;
|
|
||||||
cN *= fittingScale;
|
|
||||||
|
|
||||||
return (cN * 0.5 + 0.5);
|
|
||||||
}
|
|
||||||
!>
|
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -414,8 +414,6 @@ _nextID(0) {
|
||||||
// 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,
|
||||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
|
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
GeometryCache::_simpleTransparentPipeline =
|
GeometryCache::_simpleTransparentPipeline =
|
||||||
|
@ -424,8 +422,6 @@ _nextID(0) {
|
||||||
// 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,
|
||||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
|
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
GeometryCache::_simpleWirePipeline =
|
GeometryCache::_simpleWirePipeline =
|
||||||
|
@ -1770,7 +1766,6 @@ static void buildWebShader(const std::string& vertShaderText, const std::string&
|
||||||
shaderPointerOut = gpu::Shader::createProgram(VS, PS);
|
shaderPointerOut = gpu::Shader::createProgram(VS, PS);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
|
|
||||||
gpu::Shader::makeProgram(*shaderPointerOut, slotBindings);
|
gpu::Shader::makeProgram(*shaderPointerOut, slotBindings);
|
||||||
auto state = std::make_shared<gpu::State>();
|
auto state = std::make_shared<gpu::State>();
|
||||||
state->setCullMode(gpu::State::CULL_NONE);
|
state->setCullMode(gpu::State::CULL_NONE);
|
||||||
|
@ -1784,9 +1779,6 @@ static void buildWebShader(const std::string& vertShaderText, const std::string&
|
||||||
|
|
||||||
void GeometryCache::bindOpaqueWebBrowserProgram(gpu::Batch& batch, bool isAA) {
|
void GeometryCache::bindOpaqueWebBrowserProgram(gpu::Batch& batch, bool isAA) {
|
||||||
batch.setPipeline(getOpaqueWebBrowserProgram(isAA));
|
batch.setPipeline(getOpaqueWebBrowserProgram(isAA));
|
||||||
// Set a default normal map
|
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
|
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer GeometryCache::getOpaqueWebBrowserProgram(bool isAA) {
|
gpu::PipelinePointer GeometryCache::getOpaqueWebBrowserProgram(bool isAA) {
|
||||||
|
@ -1802,9 +1794,6 @@ gpu::PipelinePointer GeometryCache::getOpaqueWebBrowserProgram(bool isAA) {
|
||||||
|
|
||||||
void GeometryCache::bindTransparentWebBrowserProgram(gpu::Batch& batch, bool isAA) {
|
void GeometryCache::bindTransparentWebBrowserProgram(gpu::Batch& batch, bool isAA) {
|
||||||
batch.setPipeline(getTransparentWebBrowserProgram(isAA));
|
batch.setPipeline(getTransparentWebBrowserProgram(isAA));
|
||||||
// Set a default normal map
|
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
|
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer GeometryCache::getTransparentWebBrowserProgram(bool isAA) {
|
gpu::PipelinePointer GeometryCache::getTransparentWebBrowserProgram(bool isAA) {
|
||||||
|
@ -1827,9 +1816,6 @@ void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool tra
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
}
|
}
|
||||||
// Set a default normal map
|
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
|
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) {
|
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) {
|
||||||
|
@ -1846,7 +1832,6 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
|
||||||
_unlitShader = gpu::Shader::createProgram(VS, PSUnlit);
|
_unlitShader = gpu::Shader::createProgram(VS, PSUnlit);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
|
|
||||||
gpu::Shader::makeProgram(*_simpleShader, slotBindings);
|
gpu::Shader::makeProgram(*_simpleShader, slotBindings);
|
||||||
gpu::Shader::makeProgram(*_unlitShader, slotBindings);
|
gpu::Shader::makeProgram(*_unlitShader, slotBindings);
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,6 +97,8 @@ ShapeKey MeshPartPayload::getShapeKey() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeKey::Builder builder;
|
ShapeKey::Builder builder;
|
||||||
|
builder.withMaterial();
|
||||||
|
|
||||||
if (drawMaterialKey.isTranslucent()) {
|
if (drawMaterialKey.isTranslucent()) {
|
||||||
builder.withTranslucent();
|
builder.withTranslucent();
|
||||||
}
|
}
|
||||||
|
@ -478,6 +480,8 @@ ShapeKey ModelMeshPartPayload::getShapeKey() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeKey::Builder builder;
|
ShapeKey::Builder builder;
|
||||||
|
builder.withMaterial();
|
||||||
|
|
||||||
if (isTranslucent || _fadeState != FADE_COMPLETE) {
|
if (isTranslucent || _fadeState != FADE_COMPLETE) {
|
||||||
builder.withTranslucent();
|
builder.withTranslucent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ RenderDeferredTask::RenderDeferredTask(RenderFetchCullSortTask::Output items) {
|
||||||
// GPU jobs: Start preparing the primary, deferred and lighting buffer
|
// GPU jobs: Start preparing the primary, deferred and lighting buffer
|
||||||
const auto primaryFramebuffer = addJob<PreparePrimaryFramebuffer>("PreparePrimaryBuffer");
|
const auto primaryFramebuffer = addJob<PreparePrimaryFramebuffer>("PreparePrimaryBuffer");
|
||||||
|
|
||||||
// const auto fullFrameRangeTimer = addJob<BeginGPURangeTimer>("BeginRangeTimer");
|
|
||||||
const auto opaqueRangeTimer = addJob<BeginGPURangeTimer>("BeginOpaqueRangeTimer", "DrawOpaques");
|
const auto opaqueRangeTimer = addJob<BeginGPURangeTimer>("BeginOpaqueRangeTimer", "DrawOpaques");
|
||||||
|
|
||||||
const auto prepareDeferredInputs = PrepareDeferred::Inputs(primaryFramebuffer, lightingModel).hasVarying();
|
const auto prepareDeferredInputs = PrepareDeferred::Inputs(primaryFramebuffer, lightingModel).hasVarying();
|
||||||
|
@ -154,21 +153,25 @@ RenderDeferredTask::RenderDeferredTask(RenderFetchCullSortTask::Output items) {
|
||||||
const auto toneMappingInputs = render::Varying(ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer));
|
const auto toneMappingInputs = render::Varying(ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer));
|
||||||
addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
|
addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
|
||||||
|
|
||||||
|
{ // DEbug the bounds of the rendered items, still look at the zbuffer
|
||||||
|
addJob<DrawBounds>("DrawMetaBounds", metas);
|
||||||
|
addJob<DrawBounds>("DrawOpaqueBounds", opaques);
|
||||||
|
addJob<DrawBounds>("DrawTransparentBounds", transparents);
|
||||||
|
}
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
const auto overlayOpaquesInputs = DrawOverlay3D::Inputs(overlayOpaques, lightingModel).hasVarying();
|
const auto overlayOpaquesInputs = DrawOverlay3D::Inputs(overlayOpaques, lightingModel).hasVarying();
|
||||||
const auto overlayTransparentsInputs = DrawOverlay3D::Inputs(overlayTransparents, lightingModel).hasVarying();
|
const auto overlayTransparentsInputs = DrawOverlay3D::Inputs(overlayTransparents, lightingModel).hasVarying();
|
||||||
addJob<DrawOverlay3D>("DrawOverlay3DOpaque", overlayOpaquesInputs, true);
|
addJob<DrawOverlay3D>("DrawOverlay3DOpaque", overlayOpaquesInputs, true);
|
||||||
addJob<DrawOverlay3D>("DrawOverlay3DTransparent", overlayTransparentsInputs, false);
|
addJob<DrawOverlay3D>("DrawOverlay3DTransparent", overlayTransparentsInputs, false);
|
||||||
|
|
||||||
// Debugging stages
|
{ // DEbug the bounds of the rendered OVERLAY items, still look at the zbuffer
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// Bounds do not draw on stencil buffer, so they must come last
|
|
||||||
addJob<DrawBounds>("DrawMetaBounds", metas);
|
|
||||||
addJob<DrawBounds>("DrawOverlayOpaqueBounds", overlayOpaques);
|
addJob<DrawBounds>("DrawOverlayOpaqueBounds", overlayOpaques);
|
||||||
addJob<DrawBounds>("DrawOverlayTransparentBounds", overlayTransparents);
|
addJob<DrawBounds>("DrawOverlayTransparentBounds", overlayTransparents);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debugging stages
|
||||||
|
{
|
||||||
// Debugging Deferred buffer job
|
// Debugging Deferred buffer job
|
||||||
const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer));
|
const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer));
|
||||||
addJob<DebugDeferredBuffer>("DebugDeferredBuffer", debugFramebuffers);
|
addJob<DebugDeferredBuffer>("DebugDeferredBuffer", debugFramebuffers);
|
||||||
|
@ -208,9 +211,6 @@ RenderDeferredTask::RenderDeferredTask(RenderFetchCullSortTask::Output items) {
|
||||||
|
|
||||||
// Blit!
|
// Blit!
|
||||||
addJob<Blit>("Blit", primaryFramebuffer);
|
addJob<Blit>("Blit", primaryFramebuffer);
|
||||||
|
|
||||||
// addJob<EndGPURangeTimer>("RangeTimer", fullFrameRangeTimer);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeginGPURangeTimer::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) {
|
void BeginGPURangeTimer::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) {
|
||||||
|
|
|
@ -50,9 +50,13 @@
|
||||||
|
|
||||||
#include "overlay3D_vert.h"
|
#include "overlay3D_vert.h"
|
||||||
#include "overlay3D_frag.h"
|
#include "overlay3D_frag.h"
|
||||||
|
#include "overlay3D_model_frag.h"
|
||||||
|
#include "overlay3D_model_translucent_frag.h"
|
||||||
#include "overlay3D_translucent_frag.h"
|
#include "overlay3D_translucent_frag.h"
|
||||||
#include "overlay3D_unlit_frag.h"
|
#include "overlay3D_unlit_frag.h"
|
||||||
#include "overlay3D_translucent_unlit_frag.h"
|
#include "overlay3D_translucent_unlit_frag.h"
|
||||||
|
#include "overlay3D_model_unlit_frag.h"
|
||||||
|
#include "overlay3D_model_translucent_unlit_frag.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace render;
|
using namespace render;
|
||||||
|
@ -70,15 +74,24 @@ void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch);
|
||||||
|
|
||||||
void initOverlay3DPipelines(ShapePlumber& plumber) {
|
void initOverlay3DPipelines(ShapePlumber& plumber) {
|
||||||
auto vertex = gpu::Shader::createVertex(std::string(overlay3D_vert));
|
auto vertex = gpu::Shader::createVertex(std::string(overlay3D_vert));
|
||||||
|
auto vertexModel = gpu::Shader::createVertex(std::string(model_vert));
|
||||||
auto pixel = gpu::Shader::createPixel(std::string(overlay3D_frag));
|
auto pixel = gpu::Shader::createPixel(std::string(overlay3D_frag));
|
||||||
auto pixelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_translucent_frag));
|
auto pixelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_translucent_frag));
|
||||||
auto pixelUnlit = gpu::Shader::createPixel(std::string(overlay3D_unlit_frag));
|
auto pixelUnlit = gpu::Shader::createPixel(std::string(overlay3D_unlit_frag));
|
||||||
auto pixelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_translucent_unlit_frag));
|
auto pixelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_translucent_unlit_frag));
|
||||||
|
auto pixelModel = gpu::Shader::createPixel(std::string(overlay3D_model_frag));
|
||||||
|
auto pixelModelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_model_translucent_frag));
|
||||||
|
auto pixelModelUnlit = gpu::Shader::createPixel(std::string(overlay3D_model_unlit_frag));
|
||||||
|
auto pixelModelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_model_translucent_unlit_frag));
|
||||||
|
|
||||||
auto opaqueProgram = gpu::Shader::createProgram(vertex, pixel);
|
auto opaqueProgram = gpu::Shader::createProgram(vertex, pixel);
|
||||||
auto translucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucent);
|
auto translucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucent);
|
||||||
auto unlitOpaqueProgram = gpu::Shader::createProgram(vertex, pixelUnlit);
|
auto unlitOpaqueProgram = gpu::Shader::createProgram(vertex, pixelUnlit);
|
||||||
auto unlitTranslucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucentUnlit);
|
auto unlitTranslucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucentUnlit);
|
||||||
|
auto materialOpaqueProgram = gpu::Shader::createProgram(vertexModel, pixelModel);
|
||||||
|
auto materialTranslucentProgram = gpu::Shader::createProgram(vertexModel, pixelModelTranslucent);
|
||||||
|
auto materialUnlitOpaqueProgram = gpu::Shader::createProgram(vertexModel, pixelModel);
|
||||||
|
auto materialUnlitTranslucentProgram = gpu::Shader::createProgram(vertexModel, pixelModelTranslucent);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
bool isCulled = (i & 1);
|
bool isCulled = (i & 1);
|
||||||
|
@ -103,14 +116,20 @@ void initOverlay3DPipelines(ShapePlumber& plumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeKey::Filter::Builder builder;
|
ShapeKey::Filter::Builder builder;
|
||||||
|
|
||||||
isCulled ? builder.withCullFace() : builder.withoutCullFace();
|
isCulled ? builder.withCullFace() : builder.withoutCullFace();
|
||||||
isBiased ? builder.withDepthBias() : builder.withoutDepthBias();
|
isBiased ? builder.withDepthBias() : builder.withoutDepthBias();
|
||||||
isOpaque ? builder.withOpaque() : builder.withTranslucent();
|
isOpaque ? builder.withOpaque() : builder.withTranslucent();
|
||||||
|
|
||||||
auto simpleProgram = isOpaque ? opaqueProgram : translucentProgram;
|
auto simpleProgram = isOpaque ? opaqueProgram : translucentProgram;
|
||||||
auto unlitProgram = isOpaque ? unlitOpaqueProgram : unlitTranslucentProgram;
|
auto unlitProgram = isOpaque ? unlitOpaqueProgram : unlitTranslucentProgram;
|
||||||
plumber.addPipeline(builder.withoutUnlit().build(), simpleProgram, state, &lightBatchSetter);
|
auto materialProgram = isOpaque ? materialOpaqueProgram : materialTranslucentProgram;
|
||||||
plumber.addPipeline(builder.withUnlit().build(), unlitProgram, state, &batchSetter);
|
auto materialUnlitProgram = isOpaque ? materialUnlitOpaqueProgram : materialUnlitTranslucentProgram;
|
||||||
|
|
||||||
|
plumber.addPipeline(builder.withMaterial().build().key(), materialProgram, state, &lightBatchSetter);
|
||||||
|
plumber.addPipeline(builder.withMaterial().withUnlit().build().key(), materialUnlitProgram, state, &batchSetter);
|
||||||
|
plumber.addPipeline(builder.withoutUnlit().withoutMaterial().build().key(), simpleProgram, state, &lightBatchSetter);
|
||||||
|
plumber.addPipeline(builder.withUnlit().withoutMaterial().build().key(), unlitProgram, state, &batchSetter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,78 +163,87 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
||||||
// TODO: Refactor this to use a filter
|
// TODO: Refactor this to use a filter
|
||||||
// Opaques
|
// Opaques
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder(),
|
Key::Builder().withMaterial(),
|
||||||
modelVertex, modelPixel);
|
modelVertex, modelPixel);
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withMaterial().withUnlit(),
|
||||||
|
modelVertex, modelUnlitPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withUnlit(),
|
Key::Builder().withUnlit(),
|
||||||
modelVertex, modelUnlitPixel);
|
modelVertex, modelUnlitPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTangents(),
|
Key::Builder().withMaterial().withTangents(),
|
||||||
modelNormalMapVertex, modelNormalMapPixel);
|
modelNormalMapVertex, modelNormalMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSpecular(),
|
Key::Builder().withMaterial().withSpecular(),
|
||||||
modelVertex, modelSpecularMapPixel);
|
modelVertex, modelSpecularMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTangents().withSpecular(),
|
Key::Builder().withMaterial().withTangents().withSpecular(),
|
||||||
modelNormalMapVertex, modelNormalSpecularMapPixel);
|
modelNormalMapVertex, modelNormalSpecularMapPixel);
|
||||||
// Translucents
|
// Translucents
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withMaterial().withTranslucent(),
|
||||||
|
modelVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTranslucent(),
|
Key::Builder().withTranslucent(),
|
||||||
modelVertex, modelTranslucentPixel);
|
modelVertex, modelTranslucentPixel);
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withMaterial().withTranslucent().withUnlit(),
|
||||||
|
modelVertex, modelTranslucentUnlitPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTranslucent().withUnlit(),
|
Key::Builder().withTranslucent().withUnlit(),
|
||||||
modelVertex, modelTranslucentUnlitPixel);
|
modelVertex, modelTranslucentUnlitPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTranslucent().withTangents(),
|
Key::Builder().withMaterial().withTranslucent().withTangents(),
|
||||||
modelNormalMapVertex, modelTranslucentPixel);
|
modelNormalMapVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTranslucent().withSpecular(),
|
Key::Builder().withMaterial().withTranslucent().withSpecular(),
|
||||||
modelVertex, modelTranslucentPixel);
|
modelVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTranslucent().withTangents().withSpecular(),
|
Key::Builder().withMaterial().withTranslucent().withTangents().withSpecular(),
|
||||||
modelNormalMapVertex, modelTranslucentPixel);
|
modelNormalMapVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
// FIXME: Ignore lightmap for translucents meshpart
|
// FIXME: Ignore lightmap for translucents meshpart
|
||||||
Key::Builder().withTranslucent().withLightmap(),
|
Key::Builder().withMaterial().withTranslucent().withLightmap(),
|
||||||
modelVertex, modelTranslucentPixel);
|
modelVertex, modelTranslucentPixel);
|
||||||
// Lightmapped
|
// Lightmapped
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withLightmap(),
|
Key::Builder().withMaterial().withLightmap(),
|
||||||
modelLightmapVertex, modelLightmapPixel);
|
modelLightmapVertex, modelLightmapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withLightmap().withTangents(),
|
Key::Builder().withMaterial().withLightmap().withTangents(),
|
||||||
modelLightmapNormalMapVertex, modelLightmapNormalMapPixel);
|
modelLightmapNormalMapVertex, modelLightmapNormalMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withLightmap().withSpecular(),
|
Key::Builder().withMaterial().withLightmap().withSpecular(),
|
||||||
modelLightmapVertex, modelLightmapSpecularMapPixel);
|
modelLightmapVertex, modelLightmapSpecularMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withLightmap().withTangents().withSpecular(),
|
Key::Builder().withMaterial().withLightmap().withTangents().withSpecular(),
|
||||||
modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel);
|
modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel);
|
||||||
// Skinned
|
// Skinned
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned(),
|
Key::Builder().withMaterial().withSkinned(),
|
||||||
skinModelVertex, modelPixel);
|
skinModelVertex, modelPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTangents(),
|
Key::Builder().withMaterial().withSkinned().withTangents(),
|
||||||
skinModelNormalMapVertex, modelNormalMapPixel);
|
skinModelNormalMapVertex, modelNormalMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withSpecular(),
|
Key::Builder().withMaterial().withSkinned().withSpecular(),
|
||||||
skinModelVertex, modelSpecularMapPixel);
|
skinModelVertex, modelSpecularMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTangents().withSpecular(),
|
Key::Builder().withMaterial().withSkinned().withTangents().withSpecular(),
|
||||||
skinModelNormalMapVertex, modelNormalSpecularMapPixel);
|
skinModelNormalMapVertex, modelNormalSpecularMapPixel);
|
||||||
// Skinned and Translucent
|
// Skinned and Translucent
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTranslucent(),
|
Key::Builder().withMaterial().withSkinned().withTranslucent(),
|
||||||
skinModelVertex, modelTranslucentPixel);
|
skinModelVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTranslucent().withTangents(),
|
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(),
|
||||||
skinModelNormalMapVertex, modelTranslucentPixel);
|
skinModelNormalMapVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTranslucent().withSpecular(),
|
Key::Builder().withMaterial().withSkinned().withTranslucent().withSpecular(),
|
||||||
skinModelVertex, modelTranslucentPixel);
|
skinModelVertex, modelTranslucentPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTranslucent().withTangents().withSpecular(),
|
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withSpecular(),
|
||||||
skinModelNormalMapVertex, modelTranslucentPixel);
|
skinModelNormalMapVertex, modelTranslucentPixel);
|
||||||
// Depth-only
|
// Depth-only
|
||||||
addPipeline(
|
addPipeline(
|
||||||
|
@ -244,32 +272,32 @@ void initForwardPipelines(render::ShapePlumber& plumber) {
|
||||||
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3);
|
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3);
|
||||||
// Opaques
|
// Opaques
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder(),
|
Key::Builder().withMaterial(),
|
||||||
modelVertex, modelPixel);
|
modelVertex, modelPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withUnlit(),
|
Key::Builder().withMaterial().withUnlit(),
|
||||||
modelVertex, modelUnlitPixel);
|
modelVertex, modelUnlitPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTangents(),
|
Key::Builder().withMaterial().withTangents(),
|
||||||
modelNormalMapVertex, modelNormalMapPixel);
|
modelNormalMapVertex, modelNormalMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSpecular(),
|
Key::Builder().withMaterial().withSpecular(),
|
||||||
modelVertex, modelSpecularMapPixel);
|
modelVertex, modelSpecularMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withTangents().withSpecular(),
|
Key::Builder().withMaterial().withTangents().withSpecular(),
|
||||||
modelNormalMapVertex, modelNormalSpecularMapPixel);
|
modelNormalMapVertex, modelNormalSpecularMapPixel);
|
||||||
// Skinned
|
// Skinned
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned(),
|
Key::Builder().withMaterial().withSkinned(),
|
||||||
skinModelVertex, modelPixel);
|
skinModelVertex, modelPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTangents(),
|
Key::Builder().withMaterial().withSkinned().withTangents(),
|
||||||
skinModelNormalMapVertex, modelNormalMapPixel);
|
skinModelNormalMapVertex, modelNormalMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withSpecular(),
|
Key::Builder().withMaterial().withSkinned().withSpecular(),
|
||||||
skinModelVertex, modelSpecularMapPixel);
|
skinModelVertex, modelSpecularMapPixel);
|
||||||
addPipeline(
|
addPipeline(
|
||||||
Key::Builder().withSkinned().withTangents().withSpecular(),
|
Key::Builder().withMaterial().withSkinned().withTangents().withSpecular(),
|
||||||
skinModelNormalMapVertex, modelNormalSpecularMapPixel);
|
skinModelNormalMapVertex, modelNormalSpecularMapPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,9 +347,6 @@ void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {
|
||||||
// Set a default albedo map
|
// Set a default albedo map
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::ALBEDO,
|
||||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
// Set a default normal map
|
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
|
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
|
||||||
|
|
||||||
// Set a default material
|
// Set a default material
|
||||||
if (pipeline.locations->materialBufferUnit >= 0) {
|
if (pipeline.locations->materialBufferUnit >= 0) {
|
||||||
|
|
88
libraries/render-utils/src/overlay3D_model.slf
Normal file
88
libraries/render-utils/src/overlay3D_model.slf
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
// overlay3D.slf
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 6/16/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include DeferredGlobalLight.slh@>
|
||||||
|
<$declareEvalSkyboxGlobalColor()$>
|
||||||
|
|
||||||
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
|
<@include gpu/Transform.slh@>
|
||||||
|
<$declareStandardCameraTransform()$>
|
||||||
|
|
||||||
|
<@include MaterialTextures.slh@>
|
||||||
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||||
|
|
||||||
|
in vec2 _texCoord0;
|
||||||
|
in vec2 _texCoord1;
|
||||||
|
in vec4 _position;
|
||||||
|
in vec3 _normal;
|
||||||
|
in vec3 _color;
|
||||||
|
in float _alpha;
|
||||||
|
|
||||||
|
out vec4 _fragColor;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
Material mat = getMaterial();
|
||||||
|
int matKey = getMaterialKey(mat);
|
||||||
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||||
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
|
albedo *= _color;
|
||||||
|
|
||||||
|
float metallic = getMaterialMetallic(mat);
|
||||||
|
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
|
||||||
|
if (metallic <= 0.5) {
|
||||||
|
metallic = 0.0;
|
||||||
|
} else {
|
||||||
|
fresnel = albedo;
|
||||||
|
metallic = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float roughness = getMaterialRoughness(mat);
|
||||||
|
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||||
|
|
||||||
|
vec3 emissive = getMaterialEmissive(mat);
|
||||||
|
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 fragPosition = _position.xyz;
|
||||||
|
//vec3 fragNormal = normalize(_normal);
|
||||||
|
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
vec3 fragNormal;
|
||||||
|
<$transformEyeToWorldDir(cam, _normal, fragNormal)$>;
|
||||||
|
|
||||||
|
vec4 color = vec4(evalSkyboxGlobalColor(
|
||||||
|
cam._viewInverse,
|
||||||
|
1.0,
|
||||||
|
occlusionTex,
|
||||||
|
fragPosition,
|
||||||
|
fragNormal,
|
||||||
|
albedo,
|
||||||
|
fresnel,
|
||||||
|
metallic,
|
||||||
|
roughness),
|
||||||
|
opacity);
|
||||||
|
|
||||||
|
// And emissive
|
||||||
|
color.rgb += emissive * isEmissiveEnabled();
|
||||||
|
|
||||||
|
// Apply standard tone mapping
|
||||||
|
_fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w);
|
||||||
|
}
|
83
libraries/render-utils/src/overlay3D_model_translucent.slf
Normal file
83
libraries/render-utils/src/overlay3D_model_translucent.slf
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
// overlay3D_model_transparent.slf
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 2/27/2017.
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include DeferredGlobalLight.slh@>
|
||||||
|
<$declareEvalGlobalLightingAlphaBlended()$>
|
||||||
|
|
||||||
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
|
<@include gpu/Transform.slh@>
|
||||||
|
<$declareStandardCameraTransform()$>
|
||||||
|
|
||||||
|
<@include MaterialTextures.slh@>
|
||||||
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||||
|
|
||||||
|
in vec2 _texCoord0;
|
||||||
|
in vec2 _texCoord1;
|
||||||
|
in vec4 _position;
|
||||||
|
in vec3 _normal;
|
||||||
|
in vec3 _color;
|
||||||
|
in float _alpha;
|
||||||
|
|
||||||
|
out vec4 _fragColor;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
Material mat = getMaterial();
|
||||||
|
int matKey = getMaterialKey(mat);
|
||||||
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||||
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
|
||||||
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
|
albedo *= _color;
|
||||||
|
|
||||||
|
float metallic = getMaterialMetallic(mat);
|
||||||
|
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
|
||||||
|
if (metallic <= 0.5) {
|
||||||
|
metallic = 0.0;
|
||||||
|
} else {
|
||||||
|
fresnel = albedo;
|
||||||
|
metallic = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float roughness = getMaterialRoughness(mat);
|
||||||
|
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||||
|
|
||||||
|
vec3 emissive = getMaterialEmissive(mat);
|
||||||
|
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 fragPosition = _position.xyz;
|
||||||
|
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
vec3 fragNormal;
|
||||||
|
<$transformEyeToWorldDir(cam, _normal, fragNormal)$>
|
||||||
|
|
||||||
|
vec4 color = vec4(evalGlobalLightingAlphaBlended(
|
||||||
|
cam._viewInverse,
|
||||||
|
1.0,
|
||||||
|
occlusionTex,
|
||||||
|
fragPosition,
|
||||||
|
fragNormal,
|
||||||
|
albedo,
|
||||||
|
fresnel,
|
||||||
|
metallic,
|
||||||
|
emissive,
|
||||||
|
roughness, opacity),
|
||||||
|
opacity);
|
||||||
|
|
||||||
|
// Apply standard tone mapping
|
||||||
|
_fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w);
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
// overlay3D-model_transparent_unlit.slf
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 2/28/2017.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include LightingModel.slh@>
|
||||||
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
|
<@include MaterialTextures.slh@>
|
||||||
|
<$declareMaterialTextures(ALBEDO)$>
|
||||||
|
|
||||||
|
in vec2 _texCoord0;
|
||||||
|
in vec3 _normal;
|
||||||
|
in vec3 _color;
|
||||||
|
in float _alpha;
|
||||||
|
|
||||||
|
out vec4 _fragColor;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
|
||||||
|
Material mat = getMaterial();
|
||||||
|
int matKey = getMaterialKey(mat);
|
||||||
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
|
||||||
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
|
albedo *= _color;
|
||||||
|
|
||||||
|
vec4 color = vec4(albedo * isUnlitEnabled(), opacity);
|
||||||
|
|
||||||
|
_fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w);
|
||||||
|
}
|
44
libraries/render-utils/src/overlay3D_model_unlit.slf
Normal file
44
libraries/render-utils/src/overlay3D_model_unlit.slf
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
// overlay3D-model_unlit.slf
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 2/28/2017.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include LightingModel.slh@>
|
||||||
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
|
<@include MaterialTextures.slh@>
|
||||||
|
<$declareMaterialTextures(ALBEDO)$>
|
||||||
|
|
||||||
|
in vec2 _texCoord0;
|
||||||
|
in vec3 _normal;
|
||||||
|
in vec3 _color;
|
||||||
|
in float _alpha;
|
||||||
|
|
||||||
|
out vec4 _fragColor;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
|
||||||
|
Material mat = getMaterial();
|
||||||
|
int matKey = getMaterialKey(mat);
|
||||||
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
|
albedo *= _color;
|
||||||
|
|
||||||
|
vec4 color = vec4(albedo * isUnlitEnabled(), opacity);
|
||||||
|
|
||||||
|
_fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w);
|
||||||
|
}
|
|
@ -20,8 +20,6 @@ void renderItems(const SceneContextPointer& sceneContext, const RenderContextPoi
|
||||||
void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePlumberPointer& shapeContext, const ItemBounds& inItems, int maxDrawnItems = -1);
|
void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePlumberPointer& shapeContext, const ItemBounds& inItems, int maxDrawnItems = -1);
|
||||||
void renderStateSortShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePlumberPointer& shapeContext, const ItemBounds& inItems, int maxDrawnItems = -1);
|
void renderStateSortShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePlumberPointer& shapeContext, const ItemBounds& inItems, int maxDrawnItems = -1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DrawLightConfig : public Job::Config {
|
class DrawLightConfig : public Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY numDrawnChanged)
|
Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY numDrawnChanged)
|
||||||
|
|
|
@ -39,6 +39,10 @@ void ShapePlumber::addPipelineHelper(const Filter& filter, ShapeKey key, int bit
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Add the brand new pipeline and cache its location in the lib
|
// Add the brand new pipeline and cache its location in the lib
|
||||||
|
auto precedent = _pipelineMap.find(key);
|
||||||
|
if (precedent != _pipelineMap.end()) {
|
||||||
|
qCDebug(renderlogging) << "Key already assigned: " << key;
|
||||||
|
}
|
||||||
_pipelineMap.insert(PipelineMap::value_type(key, pipeline));
|
_pipelineMap.insert(PipelineMap::value_type(key, pipeline));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,16 +69,11 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::BUFFER::LIGHT));
|
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::BUFFER::LIGHT));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("lightAmbientBuffer"), Slot::BUFFER::LIGHT_AMBIENT_BUFFER));
|
slotBindings.insert(gpu::Shader::Binding(std::string("lightAmbientBuffer"), Slot::BUFFER::LIGHT_AMBIENT_BUFFER));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), Slot::MAP::LIGHT_AMBIENT));
|
slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), Slot::MAP::LIGHT_AMBIENT));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), Slot::NORMAL_FITTING));
|
|
||||||
|
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
||||||
auto locations = std::make_shared<Locations>();
|
auto locations = std::make_shared<Locations>();
|
||||||
locations->normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap");
|
|
||||||
if (program->getTextures().findLocation("normalFittingMap") > -1) {
|
|
||||||
locations->normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap");
|
|
||||||
|
|
||||||
}
|
|
||||||
locations->albedoTextureUnit = program->getTextures().findLocation("albedoMap");
|
locations->albedoTextureUnit = program->getTextures().findLocation("albedoMap");
|
||||||
locations->roughnessTextureUnit = program->getTextures().findLocation("roughnessMap");
|
locations->roughnessTextureUnit = program->getTextures().findLocation("roughnessMap");
|
||||||
locations->normalTextureUnit = program->getTextures().findLocation("normalMap");
|
locations->normalTextureUnit = program->getTextures().findLocation("normalMap");
|
||||||
|
|
|
@ -22,13 +22,13 @@ namespace render {
|
||||||
class ShapeKey {
|
class ShapeKey {
|
||||||
public:
|
public:
|
||||||
enum FlagBit {
|
enum FlagBit {
|
||||||
TRANSLUCENT = 0,
|
MATERIAL = 0,
|
||||||
|
TRANSLUCENT,
|
||||||
LIGHTMAP,
|
LIGHTMAP,
|
||||||
TANGENTS,
|
TANGENTS,
|
||||||
SPECULAR,
|
SPECULAR,
|
||||||
UNLIT,
|
UNLIT,
|
||||||
SKINNED,
|
SKINNED,
|
||||||
STEREO,
|
|
||||||
DEPTH_ONLY,
|
DEPTH_ONLY,
|
||||||
DEPTH_BIAS,
|
DEPTH_BIAS,
|
||||||
WIREFRAME,
|
WIREFRAME,
|
||||||
|
@ -53,13 +53,13 @@ public:
|
||||||
|
|
||||||
ShapeKey build() const { return ShapeKey{_flags}; }
|
ShapeKey build() const { return ShapeKey{_flags}; }
|
||||||
|
|
||||||
|
Builder& withMaterial() { _flags.set(MATERIAL); return (*this); }
|
||||||
Builder& withTranslucent() { _flags.set(TRANSLUCENT); return (*this); }
|
Builder& withTranslucent() { _flags.set(TRANSLUCENT); return (*this); }
|
||||||
Builder& withLightmap() { _flags.set(LIGHTMAP); return (*this); }
|
Builder& withLightmap() { _flags.set(LIGHTMAP); return (*this); }
|
||||||
Builder& withTangents() { _flags.set(TANGENTS); return (*this); }
|
Builder& withTangents() { _flags.set(TANGENTS); return (*this); }
|
||||||
Builder& withSpecular() { _flags.set(SPECULAR); return (*this); }
|
Builder& withSpecular() { _flags.set(SPECULAR); return (*this); }
|
||||||
Builder& withUnlit() { _flags.set(UNLIT); return (*this); }
|
Builder& withUnlit() { _flags.set(UNLIT); return (*this); }
|
||||||
Builder& withSkinned() { _flags.set(SKINNED); return (*this); }
|
Builder& withSkinned() { _flags.set(SKINNED); return (*this); }
|
||||||
Builder& withStereo() { _flags.set(STEREO); return (*this); }
|
|
||||||
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); return (*this); }
|
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); return (*this); }
|
||||||
Builder& withDepthBias() { _flags.set(DEPTH_BIAS); return (*this); }
|
Builder& withDepthBias() { _flags.set(DEPTH_BIAS); return (*this); }
|
||||||
Builder& withWireframe() { _flags.set(WIREFRAME); return (*this); }
|
Builder& withWireframe() { _flags.set(WIREFRAME); return (*this); }
|
||||||
|
@ -89,6 +89,9 @@ public:
|
||||||
|
|
||||||
Filter build() const { return Filter(_flags, _mask); }
|
Filter build() const { return Filter(_flags, _mask); }
|
||||||
|
|
||||||
|
Builder& withMaterial() { _flags.set(MATERIAL); _mask.set(MATERIAL); return (*this); }
|
||||||
|
Builder& withoutMaterial() { _flags.reset(MATERIAL); _mask.set(MATERIAL); return (*this); }
|
||||||
|
|
||||||
Builder& withTranslucent() { _flags.set(TRANSLUCENT); _mask.set(TRANSLUCENT); return (*this); }
|
Builder& withTranslucent() { _flags.set(TRANSLUCENT); _mask.set(TRANSLUCENT); return (*this); }
|
||||||
Builder& withOpaque() { _flags.reset(TRANSLUCENT); _mask.set(TRANSLUCENT); return (*this); }
|
Builder& withOpaque() { _flags.reset(TRANSLUCENT); _mask.set(TRANSLUCENT); return (*this); }
|
||||||
|
|
||||||
|
@ -107,9 +110,6 @@ public:
|
||||||
Builder& withSkinned() { _flags.set(SKINNED); _mask.set(SKINNED); return (*this); }
|
Builder& withSkinned() { _flags.set(SKINNED); _mask.set(SKINNED); return (*this); }
|
||||||
Builder& withoutSkinned() { _flags.reset(SKINNED); _mask.set(SKINNED); return (*this); }
|
Builder& withoutSkinned() { _flags.reset(SKINNED); _mask.set(SKINNED); return (*this); }
|
||||||
|
|
||||||
Builder& withStereo() { _flags.set(STEREO); _mask.set(STEREO); return (*this); }
|
|
||||||
Builder& withoutStereo() { _flags.reset(STEREO); _mask.set(STEREO); return (*this); }
|
|
||||||
|
|
||||||
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
|
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
|
||||||
Builder& withoutDepthOnly() { _flags.reset(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
|
Builder& withoutDepthOnly() { _flags.reset(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
|
||||||
|
|
||||||
|
@ -128,19 +128,20 @@ public:
|
||||||
Flags _mask{0};
|
Flags _mask{0};
|
||||||
};
|
};
|
||||||
Filter(const Filter::Builder& builder) : Filter(builder._flags, builder._mask) {}
|
Filter(const Filter::Builder& builder) : Filter(builder._flags, builder._mask) {}
|
||||||
|
ShapeKey key() const { return ShapeKey(_flags); }
|
||||||
protected:
|
protected:
|
||||||
friend class ShapePlumber;
|
friend class ShapePlumber;
|
||||||
Flags _flags{0};
|
Flags _flags{0};
|
||||||
Flags _mask{0};
|
Flags _mask{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool useMaterial() const { return _flags[MATERIAL]; }
|
||||||
bool hasLightmap() const { return _flags[LIGHTMAP]; }
|
bool hasLightmap() const { return _flags[LIGHTMAP]; }
|
||||||
bool hasTangents() const { return _flags[TANGENTS]; }
|
bool hasTangents() const { return _flags[TANGENTS]; }
|
||||||
bool hasSpecular() const { return _flags[SPECULAR]; }
|
bool hasSpecular() const { return _flags[SPECULAR]; }
|
||||||
bool isUnlit() const { return _flags[UNLIT]; }
|
bool isUnlit() const { return _flags[UNLIT]; }
|
||||||
bool isTranslucent() const { return _flags[TRANSLUCENT]; }
|
bool isTranslucent() const { return _flags[TRANSLUCENT]; }
|
||||||
bool isSkinned() const { return _flags[SKINNED]; }
|
bool isSkinned() const { return _flags[SKINNED]; }
|
||||||
bool isStereo() const { return _flags[STEREO]; }
|
|
||||||
bool isDepthOnly() const { return _flags[DEPTH_ONLY]; }
|
bool isDepthOnly() const { return _flags[DEPTH_ONLY]; }
|
||||||
bool isDepthBiased() const { return _flags[DEPTH_BIAS]; }
|
bool isDepthBiased() const { return _flags[DEPTH_BIAS]; }
|
||||||
bool isWireFrame() const { return _flags[WIREFRAME]; }
|
bool isWireFrame() const { return _flags[WIREFRAME]; }
|
||||||
|
@ -170,13 +171,13 @@ inline QDebug operator<<(QDebug debug, const ShapeKey& key) {
|
||||||
debug << "[ShapeKey: OWN_PIPELINE]";
|
debug << "[ShapeKey: OWN_PIPELINE]";
|
||||||
} else {
|
} else {
|
||||||
debug << "[ShapeKey:"
|
debug << "[ShapeKey:"
|
||||||
|
<< "useMaterial:" << key.useMaterial()
|
||||||
<< "hasLightmap:" << key.hasLightmap()
|
<< "hasLightmap:" << key.hasLightmap()
|
||||||
<< "hasTangents:" << key.hasTangents()
|
<< "hasTangents:" << key.hasTangents()
|
||||||
<< "hasSpecular:" << key.hasSpecular()
|
<< "hasSpecular:" << key.hasSpecular()
|
||||||
<< "isUnlit:" << key.isUnlit()
|
<< "isUnlit:" << key.isUnlit()
|
||||||
<< "isTranslucent:" << key.isTranslucent()
|
<< "isTranslucent:" << key.isTranslucent()
|
||||||
<< "isSkinned:" << key.isSkinned()
|
<< "isSkinned:" << key.isSkinned()
|
||||||
<< "isStereo:" << key.isStereo()
|
|
||||||
<< "isDepthOnly:" << key.isDepthOnly()
|
<< "isDepthOnly:" << key.isDepthOnly()
|
||||||
<< "isDepthBiased:" << key.isDepthBiased()
|
<< "isDepthBiased:" << key.isDepthBiased()
|
||||||
<< "isWireFrame:" << key.isWireFrame()
|
<< "isWireFrame:" << key.isWireFrame()
|
||||||
|
@ -213,8 +214,6 @@ public:
|
||||||
OCCLUSION,
|
OCCLUSION,
|
||||||
SCATTERING,
|
SCATTERING,
|
||||||
LIGHT_AMBIENT,
|
LIGHT_AMBIENT,
|
||||||
|
|
||||||
NORMAL_FITTING = 10,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -226,7 +225,6 @@ public:
|
||||||
int metallicTextureUnit;
|
int metallicTextureUnit;
|
||||||
int emissiveTextureUnit;
|
int emissiveTextureUnit;
|
||||||
int occlusionTextureUnit;
|
int occlusionTextureUnit;
|
||||||
int normalFittingMapUnit;
|
|
||||||
int lightingModelBufferUnit;
|
int lightingModelBufferUnit;
|
||||||
int skinClusterBufferUnit;
|
int skinClusterBufferUnit;
|
||||||
int materialBufferUnit;
|
int materialBufferUnit;
|
||||||
|
|
|
@ -159,13 +159,33 @@ Column {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Column {
|
||||||
id: metas
|
id: metas
|
||||||
CheckBox {
|
CheckBox {
|
||||||
text: "Draw Meta Bounds"
|
text: "Metas"
|
||||||
checked: Render.getConfig("DrawMetaBounds")["enabled"]
|
checked: Render.getConfig("DrawMetaBounds")["enabled"]
|
||||||
onCheckedChanged: { Render.getConfig("DrawMetaBounds")["enabled"] = checked }
|
onCheckedChanged: { Render.getConfig("DrawMetaBounds")["enabled"] = checked }
|
||||||
}
|
}
|
||||||
|
CheckBox {
|
||||||
|
text: "Opaques"
|
||||||
|
checked: Render.getConfig("DrawOpaqueBounds")["enabled"]
|
||||||
|
onCheckedChanged: { Render.getConfig("DrawOpaqueBounds")["enabled"] = checked }
|
||||||
|
}
|
||||||
|
CheckBox {
|
||||||
|
text: "Transparents"
|
||||||
|
checked: Render.getConfig("DrawTransparentBounds")["enabled"]
|
||||||
|
onCheckedChanged: { Render.getConfig("DrawTransparentBounds")["enabled"] = checked }
|
||||||
|
}
|
||||||
|
CheckBox {
|
||||||
|
text: "Overlay Opaques"
|
||||||
|
checked: Render.getConfig("DrawOverlayOpaqueBounds")["enabled"]
|
||||||
|
onCheckedChanged: { Render.getConfig("DrawOverlayOpaqueBounds")["enabled"] = checked }
|
||||||
|
}
|
||||||
|
CheckBox {
|
||||||
|
text: "Overlay Transparents"
|
||||||
|
checked: Render.getConfig("DrawOverlayTransparentBounds")["enabled"]
|
||||||
|
onCheckedChanged: { Render.getConfig("DrawOverlayTransparentBounds")["enabled"] = checked }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue