Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 4 files). Show all
Unified · Split
| @@ -35,6 +35,7 @@ · 34 unmodified lines | |||
| 35 | #include "simple_vert.h" | 35 | #include "simple_vert.h" |
| 36 | #include "simple_textured_frag.h" | 36 | #include "simple_textured_frag.h" |
| 37 | #include "simple_textured_unlit_frag.h" | 37 | #include "simple_textured_unlit_frag.h" |
| 38 | #include "simple_srgb_textured_unlit_no_dst_alpha_frag.h" | ||
| 38 | #include "glowLine_vert.h" | 39 | #include "glowLine_vert.h" |
| 39 | #include "glowLine_geom.h" | 40 | #include "glowLine_geom.h" |
| 40 | #include "glowLine_frag.h" | 41 | #include "glowLine_frag.h" |
| @@ -1748,6 +1749,46 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { · 1707 unmodified lines | |||
| 1748 | return a.getRaw() == b.getRaw(); | 1749 | return a.getRaw() == b.getRaw(); |
| 1749 | } | 1750 | } |
| 1750 | 1751 | ||
| 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 | |||
| 1751 | void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled, bool unlit, bool depthBiased) { | 1792 | void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled, bool unlit, bool depthBiased) { |
| 1752 | batch.setPipeline(getSimplePipeline(textured, culled, unlit, depthBiased)); | 1793 | batch.setPipeline(getSimplePipeline(textured, culled, unlit, depthBiased)); |
| 1753 | 1794 | ||