History

Improved web entity rendering

* fading now works properly * web browsers are now fully opaque.

Anthony J. Thibault committed 10 years ago

Commit e82f6a91 parent 8d5a8967 files · +112 −36Browse files

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

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+42−11
@@ -35,7 +35,8 @@ · 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_tex_alpha_frag.h"
38+#include "simple_opaque_web_browser_frag.h"
39+#include "simple_transparent_web_browser_frag.h"
3940 #include "glowLine_vert.h"
4041 #include "glowLine_geom.h"
4142 #include "glowLine_frag.h"
@@ -1763,25 +1764,55 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { · 1721 unmodified lines
17631764 return a.getRaw() == b.getRaw();
17641765 }
17651766
1766−void GeometryCache::bindSimpleSRGBTexturedUnlitNoTexAlphaProgram(gpu::Batch& batch) {
1767− batch.setPipeline(getSimpleSRGBTexturedUnlitNoTexAlphaPipeline());
1767+void GeometryCache::bindOpaqueWebBrowserProgram(gpu::Batch& batch) {
1768+ batch.setPipeline(getOpaqueWebBrowserProgram());
17681769 // Set a default normal map
17691770 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());
17711803 }
17721804
1773−gpu::PipelinePointer GeometryCache::getSimpleSRGBTexturedUnlitNoTexAlphaPipeline() {
1774− // Compile the shaders, once
1805+gpu::PipelinePointer GeometryCache::getTransparentWebBrowserProgram() {
17751806 static std::once_flag once;
17761807 std::call_once(once, [&]() {
17771808 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));
17791810
1780− _simpleSRGBTexturedUnlitNoTexAlphaShader = gpu::Shader::createProgram(VS, PS);
1811+ _simpleTransparentWebBrowserShader = gpu::Shader::createProgram(VS, PS);
17811812
17821813 gpu::Shader::BindingSet slotBindings;
17831814 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);
17851816 auto state = std::make_shared<gpu::State>();
17861817 state->setCullMode(gpu::State::CULL_NONE);
17871818 state->setDepthTest(true, true, gpu::LESS_EQUAL);
@@ -1789,10 +1820,10 @@ gpu::PipelinePointer GeometryCache::getSimpleSRGBTexturedUnlitNoTexAlphaPipeline · 1 unmodified line
17891820 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
17901821 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
17911822
1792− _simpleSRGBTexturedUnlitNoTexAlphaPipeline = gpu::Pipeline::create(_simpleSRGBTexturedUnlitNoTexAlphaShader, state);
1823+ _simpleTransparentWebBrowserPipeline = gpu::Pipeline::create(_simpleTransparentWebBrowserShader, state);
17931824 });
17941825
1795− return _simpleSRGBTexturedUnlitNoTexAlphaPipeline;
1826+ return _simpleTransparentWebBrowserPipeline;
17961827 }
17971828
17981829 void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) {

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