* fading now works properly * web browsers are now fully opaque.
Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 7 files). Show all
Unified · Split
| @@ -35,7 +35,8 @@ · 34 unmodified lines | ||
| 35 | 35 | #include "simple_vert.h" |
| 36 | 36 | #include "simple_textured_frag.h" |
| 37 | 37 | #include "simple_textured_unlit_frag.h" |
| 38 | −#include "simple_srgb_textured_unlit_no_tex_alpha_frag.h" | |
| 38 | +#include "simple_opaque_web_browser_frag.h" | |
| 39 | +#include "simple_transparent_web_browser_frag.h" | |
| 39 | 40 | #include "glowLine_vert.h" |
| 40 | 41 | #include "glowLine_geom.h" |
| 41 | 42 | #include "glowLine_frag.h" |
| @@ -1763,25 +1764,55 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { · 1721 unmodified lines | ||
| 1763 | 1764 | return a.getRaw() == b.getRaw(); |
| 1764 | 1765 | } |
| 1765 | 1766 | |
| 1766 | −void GeometryCache::bindSimpleSRGBTexturedUnlitNoTexAlphaProgram(gpu::Batch& batch) { | |
| 1767 | − batch.setPipeline(getSimpleSRGBTexturedUnlitNoTexAlphaPipeline()); | |
| 1767 | +void GeometryCache::bindOpaqueWebBrowserProgram(gpu::Batch& batch) { | |
| 1768 | + batch.setPipeline(getOpaqueWebBrowserProgram()); | |
| 1768 | 1769 | // Set a default normal map |
| 1769 | 1770 | batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING, |
| 1770 | − DependencyManager::get<TextureCache>()->getNormalFittingTexture()); | |
| 1771 | + DependencyManager::get<TextureCache>()->getNormalFittingTexture()); | |
| 1772 | +} | |
| 1773 | + | |
| 1774 | +gpu::PipelinePointer GeometryCache::getOpaqueWebBrowserProgram() { | |
| 1775 | + static std::once_flag once; | |
| 1776 | + std::call_once(once, [&]() { | |
| 1777 | + auto VS = gpu::Shader::createVertex(std::string(simple_vert)); | |
| 1778 | + auto PS = gpu::Shader::createPixel(std::string(simple_opaque_web_browser_frag)); | |
| 1779 | + | |
| 1780 | + _simpleOpaqueWebBrowserShader = gpu::Shader::createProgram(VS, PS); | |
| 1781 | + | |
| 1782 | + gpu::Shader::BindingSet slotBindings; | |
| 1783 | + slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING)); | |
| 1784 | + gpu::Shader::makeProgram(*_simpleOpaqueWebBrowserShader, slotBindings); | |
| 1785 | + auto state = std::make_shared<gpu::State>(); | |
| 1786 | + state->setCullMode(gpu::State::CULL_NONE); | |
| 1787 | + state->setDepthTest(true, true, gpu::LESS_EQUAL); | |
| 1788 | + state->setBlendFunction(false, | |
| 1789 | + gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, | |
| 1790 | + gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); | |
| 1791 | + | |
| 1792 | + _simpleOpaqueWebBrowserPipeline = gpu::Pipeline::create(_simpleOpaqueWebBrowserShader, state); | |
| 1793 | + }); | |
| 1794 | + | |
| 1795 | + return _simpleOpaqueWebBrowserPipeline; | |
| 1796 | +} | |
| 1797 | + | |
| 1798 | +void GeometryCache::bindTransparentWebBrowserProgram(gpu::Batch& batch) { | |
| 1799 | + batch.setPipeline(getTransparentWebBrowserProgram()); | |
| 1800 | + // Set a default normal map | |
| 1801 | + batch.setResourceTexture(render::ShapePipeline::Slot::MAP::NORMAL_FITTING, | |
| 1802 | + DependencyManager::get<TextureCache>()->getNormalFittingTexture()); | |
| 1771 | 1803 | } |
| 1772 | 1804 | |
| 1773 | −gpu::PipelinePointer GeometryCache::getSimpleSRGBTexturedUnlitNoTexAlphaPipeline() { | |
| 1774 | − // Compile the shaders, once | |
| 1805 | +gpu::PipelinePointer GeometryCache::getTransparentWebBrowserProgram() { | |
| 1775 | 1806 | static std::once_flag once; |
| 1776 | 1807 | std::call_once(once, [&]() { |
| 1777 | 1808 | auto VS = gpu::Shader::createVertex(std::string(simple_vert)); |
| 1778 | − auto PS = gpu::Shader::createPixel(std::string(simple_srgb_textured_unlit_no_tex_alpha_frag)); | |
| 1809 | + auto PS = gpu::Shader::createPixel(std::string(simple_transparent_web_browser_frag)); | |
| 1779 | 1810 | |
| 1780 | − _simpleSRGBTexturedUnlitNoTexAlphaShader = gpu::Shader::createProgram(VS, PS); | |
| 1811 | + _simpleTransparentWebBrowserShader = gpu::Shader::createProgram(VS, PS); | |
| 1781 | 1812 | |
| 1782 | 1813 | gpu::Shader::BindingSet slotBindings; |
| 1783 | 1814 | slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING)); |
| 1784 | − gpu::Shader::makeProgram(*_simpleSRGBTexturedUnlitNoTexAlphaShader, slotBindings); | |
| 1815 | + gpu::Shader::makeProgram(*_simpleTransparentWebBrowserShader, slotBindings); | |
| 1785 | 1816 | auto state = std::make_shared<gpu::State>(); |
| 1786 | 1817 | state->setCullMode(gpu::State::CULL_NONE); |
| 1787 | 1818 | state->setDepthTest(true, true, gpu::LESS_EQUAL); |
| @@ -1789,10 +1820,10 @@ gpu::PipelinePointer GeometryCache::getSimpleSRGBTexturedUnlitNoTexAlphaPipeline · 1 unmodified line | ||
| 1789 | 1820 | gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, |
| 1790 | 1821 | gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); |
| 1791 | 1822 | |
| 1792 | − _simpleSRGBTexturedUnlitNoTexAlphaPipeline = gpu::Pipeline::create(_simpleSRGBTexturedUnlitNoTexAlphaShader, state); | |
| 1823 | + _simpleTransparentWebBrowserPipeline = gpu::Pipeline::create(_simpleTransparentWebBrowserShader, state); | |
| 1793 | 1824 | }); |
| 1794 | 1825 | |
| 1795 | − return _simpleSRGBTexturedUnlitNoTexAlphaPipeline; | |
| 1826 | + return _simpleTransparentWebBrowserPipeline; | |
| 1796 | 1827 | } |
| 1797 | 1828 | |
| 1798 | 1829 | void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) { |