History

Fix alpha cut-outs and incorrect gamma on Web3DOverlays

Anthony J. Thibault committed 10 years ago

Commit fb84f051 parent cb848364 files · +85 −1Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 4 files). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+41−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include "simple_vert.h"
3636 #include "simple_textured_frag.h"
3737 #include "simple_textured_unlit_frag.h"
38+#include "simple_srgb_textured_unlit_no_dst_alpha_frag.h"
3839 #include "glowLine_vert.h"
3940 #include "glowLine_geom.h"
4041 #include "glowLine_frag.h"
@@ -1748,6 +1749,46 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { · 1707 unmodified lines
17481749 return a.getRaw() == b.getRaw();
17491750 }
17501751
1752+void GeometryCache::bindSimpleSRGBTexturedUnlitNoDstAlphaProgram(gpu::Batch& batch) {
1753+ batch.setPipeline(getSimpleSRGBTexturedUnlitNoDstAlphaPipeline());
1754+ // Set a default normal map
1755+ batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING,
1756+ DependencyManager::get<TextureCache>()->getNormalFittingTexture());
1757+}
1758+
1759+gpu::PipelinePointer GeometryCache::getSimpleSRGBTexturedUnlitNoDstAlphaPipeline() {
1760+ // Compile the shaders, once
1761+ static std::once_flag once;
1762+ std::call_once(once, [&]() {
1763+ auto VS = gpu::Shader::createVertex(std::string(simple_vert));
1764+ auto PS = gpu::Shader::createPixel(std::string(simple_srgb_textured_unlit_no_dst_alpha_frag));
1765+
1766+ _simpleSRGBTexturedUnlitNoDstAlphaShader = gpu::Shader::createProgram(VS, PS);
1767+
1768+ gpu::Shader::BindingSet slotBindings;
1769+ slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
1770+ gpu::Shader::makeProgram(*_simpleSRGBTexturedUnlitNoDstAlphaShader, slotBindings);
1771+ });
1772+
1773+ if (_simpleSRGBTexturedUnlitNoDstAlphaPipeline) {
1774+ return _simpleSRGBTexturedUnlitNoDstAlphaPipeline;
1775+ }
1776+
1777+ // If the pipeline did not exist, make it
1778+ auto state = std::make_shared<gpu::State>();
1779+ state->setCullMode(gpu::State::CULL_NONE);
1780+
1781+ state->setDepthTest(true, true, gpu::LESS_EQUAL);
1782+ state->setBlendFunction(false,
1783+ gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
1784+ gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
1785+
1786+ gpu::ShaderPointer program = _simpleSRGBTexturedUnlitNoDstAlphaShader;
1787+ gpu::PipelinePointer pipeline = gpu::Pipeline::create(program, state);
1788+ _simpleSRGBTexturedUnlitNoDstAlphaPipeline = pipeline;
1789+ return pipeline;
1790+}
1791+
17511792 void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled, bool unlit, bool depthBiased) {
17521793 batch.setPipeline(getSimplePipeline(textured, culled, unlit, depthBiased));
17531794

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t