mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 13:33:26 +02:00
REmove the crappy solution for drawing transparent texture into overlay by a proper shader
This commit is contained in:
parent
8421aafe33
commit
66cd17ec66
6 changed files with 50 additions and 9 deletions
interface/src/ui
libraries
gpu/src/gpu
model/src/model
render-utils/src
|
@ -92,12 +92,12 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
|
|||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, color, depth, stencil);
|
||||
|
||||
// Now render the overlay components together into a single texture
|
||||
renderRearView(renderArgs); // renders the mirror view selfie
|
||||
renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
|
||||
renderAudioScope(renderArgs); // audio scope in the very back
|
||||
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
|
||||
renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
|
||||
renderStatsAndLogs(renderArgs); // currently renders nothing
|
||||
renderRearView(renderArgs); // renders the mirror view selfie
|
||||
|
||||
renderArgs->_context->syncCache();
|
||||
renderArgs->_context->render(batch);
|
||||
|
@ -195,12 +195,12 @@ void ApplicationOverlay::renderRearView(RenderArgs* renderArgs) {
|
|||
glm::vec2 texCoordMinCorner(0.0f, 0.0f);
|
||||
glm::vec2 texCoordMaxCorner(viewport.width() * renderRatio / float(selfieTexture->getWidth()), viewport.height() * renderRatio / float(selfieTexture->getHeight()));
|
||||
|
||||
geometryCache->useSimpleDrawPipeline(batch, false);
|
||||
batch.setResourceTexture(0, renderArgs->_whiteTexture);
|
||||
geometryCache->renderQuad(batch, bottomLeft, topRight, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
geometryCache->useSimpleDrawPipeline(batch, true);
|
||||
batch.setResourceTexture(0, selfieTexture);
|
||||
geometryCache->renderQuad(batch, bottomLeft, topRight, texCoordMinCorner, texCoordMaxCorner, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
|
||||
batch.setResourceTexture(0, renderArgs->_whiteTexture);
|
||||
geometryCache->useSimpleDrawPipeline(batch, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
22
libraries/gpu/src/gpu/DrawTextureOpaque.slf
Executable file
22
libraries/gpu/src/gpu/DrawTextureOpaque.slf
Executable file
|
@ -0,0 +1,22 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// Draw texture 0 fetched at texcoord.xy
|
||||
// Alpha is 1
|
||||
//
|
||||
// Created by Sam Gateau on 6/22/2015
|
||||
// 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
|
||||
//
|
||||
|
||||
|
||||
uniform sampler2D colorMap;
|
||||
|
||||
varying vec2 varTexcoord;
|
||||
|
||||
void main(void) {
|
||||
gl_FragColor = vec4(texture2D(colorMap, varTexcoord).xyz, 1.0);
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
#include "DrawTexcoordRectTransformUnitQuad_vert.h"
|
||||
#include "DrawViewportQuadTransformTexcoord_vert.h"
|
||||
#include "DrawTexture_frag.h"
|
||||
#include "DrawTextureOpaque_frag.h"
|
||||
#include "DrawColoredTexture_frag.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
@ -24,6 +25,7 @@ ShaderPointer StandardShaderLib::_drawTransformUnitQuadVS;
|
|||
ShaderPointer StandardShaderLib::_drawTexcoordRectTransformUnitQuadVS;
|
||||
ShaderPointer StandardShaderLib::_drawViewportQuadTransformTexcoordVS;
|
||||
ShaderPointer StandardShaderLib::_drawTexturePS;
|
||||
ShaderPointer StandardShaderLib::_drawTextureOpaquePS;
|
||||
ShaderPointer StandardShaderLib::_drawColoredTexturePS;
|
||||
StandardShaderLib::ProgramMap StandardShaderLib::_programs;
|
||||
|
||||
|
@ -82,6 +84,15 @@ ShaderPointer StandardShaderLib::getDrawTexturePS() {
|
|||
return _drawTexturePS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawTextureOpaquePS() {
|
||||
if (!_drawTextureOpaquePS) {
|
||||
_drawTextureOpaquePS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(DrawTextureOpaque_frag)));
|
||||
}
|
||||
return _drawTextureOpaquePS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawColoredTexturePS() {
|
||||
if (!_drawColoredTexturePS) {
|
||||
_drawColoredTexturePS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(DrawColoredTexture_frag)));
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
static ShaderPointer getDrawViewportQuadTransformTexcoordVS();
|
||||
|
||||
static ShaderPointer getDrawTexturePS();
|
||||
static ShaderPointer getDrawTextureOpaquePS();
|
||||
static ShaderPointer getDrawColoredTexturePS();
|
||||
|
||||
// The shader program combining the shaders available above, so they are unique
|
||||
|
@ -47,6 +48,7 @@ protected:
|
|||
static ShaderPointer _drawTexcoordRectTransformUnitQuadVS;
|
||||
static ShaderPointer _drawViewportQuadTransformTexcoordVS;
|
||||
static ShaderPointer _drawTexturePS;
|
||||
static ShaderPointer _drawTextureOpaquePS;
|
||||
static ShaderPointer _drawColoredTexturePS;
|
||||
|
||||
typedef std::map<std::pair<GetShader, GetShader>, ShaderPointer> ProgramMap;
|
||||
|
|
|
@ -110,7 +110,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
|
|||
} else {
|
||||
// skybox has no cubemap, just clear the color buffer
|
||||
auto color = skybox.getColor();
|
||||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(color, 0.0f), 0.0f, 0);
|
||||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(color, 0.0f), 0.0f, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "standardTransformPNTC_vert.h"
|
||||
#include "standardDrawTexture_frag.h"
|
||||
|
||||
#include "gpu/StandardShaderLib.h"
|
||||
|
||||
//#define WANT_DEBUG
|
||||
|
||||
const int GeometryCache::UNKNOWN_ID = -1;
|
||||
|
@ -1660,16 +1662,20 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
|
|||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
||||
|
||||
// enable decal blend
|
||||
state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
|
||||
|
||||
_standardDrawPipeline.reset(gpu::Pipeline::create(program, state));
|
||||
|
||||
auto stateNoBlend = std::make_shared<gpu::State>();
|
||||
stateNoBlend->setColorWriteMask(true, true, true, false);
|
||||
stateNoBlend->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
|
||||
|
||||
_standardDrawPipelineNoBlend.reset(gpu::Pipeline::create(program, stateNoBlend));
|
||||
auto stateNoBlend = std::make_shared<gpu::State>();
|
||||
// stateNoBlend->setColorWriteMask(true, true, true, false);
|
||||
// stateNoBlend->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
|
||||
|
||||
auto programNoBlend = gpu::ShaderPointer(gpu::Shader::createProgram(vs, gpu::StandardShaderLib::getDrawTextureOpaquePS()));
|
||||
gpu::Shader::makeProgram((*programNoBlend));
|
||||
_standardDrawPipelineNoBlend.reset(gpu::Pipeline::create(programNoBlend, stateNoBlend));
|
||||
}
|
||||
if (noBlend) {
|
||||
batch.setPipeline(_standardDrawPipelineNoBlend);
|
||||
|
|
Loading…
Reference in a new issue