From e40a795a27f11479f0ff1623430daf90a71a22e6 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 10 May 2016 19:25:22 -0700 Subject: [PATCH] Trying to clean up for pr --- interface/src/ui/overlays/Image3DOverlay.cpp | 2 +- libraries/fbx/src/FBXReader.cpp | 1 - .../render-utils/src/MaterialTextures.slh | 2 +- .../render-utils/src/RenderPipelines.cpp | 24 +++++++------------ libraries/render-utils/src/model.slf | 2 +- .../render-utils/src/model_normal_map.slf | 2 +- .../render-utils/src/model_specular_map.slf | 2 +- .../render-utils/src/model_translucent.slf | 3 +-- .../src/model_translucent_unlit.slf | 11 ++------- libraries/render-utils/src/model_unlit.slf | 2 +- libraries/render-utils/src/overlay3D.slf | 4 +--- libraries/render/src/render/ShapePipeline.h | 7 ------ 12 files changed, 18 insertions(+), 44 deletions(-) diff --git a/interface/src/ui/overlays/Image3DOverlay.cpp b/interface/src/ui/overlays/Image3DOverlay.cpp index fe2fc5ddcd..fd0d2bcedf 100644 --- a/interface/src/ui/overlays/Image3DOverlay.cpp +++ b/interface/src/ui/overlays/Image3DOverlay.cpp @@ -104,7 +104,7 @@ void Image3DOverlay::render(RenderArgs* args) { const render::ShapeKey Image3DOverlay::getShapeKey() { auto builder = render::ShapeKey::Builder().withoutCullFace().withDepthBias(); if (_emissive) { - builder.withEmissive(); + builder.withUnlit(); } if (getAlpha() != 1.0f) { builder.withTranslucent(); diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index b7a4d4ec85..2322a808c7 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1132,7 +1132,6 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS ambientTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); } else if (type.contains("tex_ao_map")) { occlusionTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); - } else if (type == "lcl rotation") { localRotations.insert(getID(connection.properties, 2), getID(connection.properties, 1)); } else if (type == "lcl translation") { diff --git a/libraries/render-utils/src/MaterialTextures.slh b/libraries/render-utils/src/MaterialTextures.slh index 512b7a533c..f9b1c76104 100644 --- a/libraries/render-utils/src/MaterialTextures.slh +++ b/libraries/render-utils/src/MaterialTextures.slh @@ -157,7 +157,7 @@ vec3 fetchLightmapMap(vec2 uv) { } <@endfunc@> -<@func $discardTransparent(opacity)@> +<@func discardTransparent(opacity)@> { if (<$opacity$> < 1.0) { discard; diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index 62f93845bb..c6ae08cf9d 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -104,13 +104,13 @@ void initOverlay3DPipelines(ShapePlumber& plumber) { auto vertex = gpu::Shader::createVertex(std::string(overlay3D_vert)); auto pixel = gpu::Shader::createPixel(std::string(overlay3D_frag)); auto pixelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_translucent_frag)); - auto pixelEmissive = gpu::Shader::createPixel(std::string(overlay3D_unlit_frag)); - auto pixelTranslucentEmissive = gpu::Shader::createPixel(std::string(overlay3D_translucent_unlit_frag)); + auto pixelUnlit = gpu::Shader::createPixel(std::string(overlay3D_unlit_frag)); + auto pixelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_translucent_unlit_frag)); auto opaqueProgram = gpu::Shader::createProgram(vertex, pixel); auto translucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucent); - auto emissiveOpaqueProgram = gpu::Shader::createProgram(vertex, pixelEmissive); - auto emissiveTranslucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucentEmissive); + auto unlitOpaqueProgram = gpu::Shader::createProgram(vertex, pixelUnlit); + auto unlitTranslucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucentUnlit); for (int i = 0; i < 8; i++) { bool isCulled = (i & 1); @@ -140,9 +140,9 @@ void initOverlay3DPipelines(ShapePlumber& plumber) { isOpaque ? builder.withOpaque() : builder.withTranslucent(); auto simpleProgram = isOpaque ? opaqueProgram : translucentProgram; - auto emissiveProgram = isOpaque ? emissiveOpaqueProgram : emissiveTranslucentProgram; - plumber.addPipeline(builder.withoutEmissive().build(), simpleProgram, state, &lightBatchSetter); - plumber.addPipeline(builder.withEmissive().build(), emissiveProgram, state, &batchSetter); + auto unlitProgram = isOpaque ? unlitOpaqueProgram : unlitTranslucentProgram; + plumber.addPipeline(builder.withoutUnlit().build(), simpleProgram, state, &lightBatchSetter); + plumber.addPipeline(builder.withUnlit().build(), unlitProgram, state, &batchSetter); } } @@ -203,13 +203,11 @@ void initDeferredPipelines(render::ShapePlumber& plumber) { // Pixel shaders auto modelPixel = gpu::Shader::createPixel(std::string(model_frag)); - auto modelEmissivePixel = gpu::Shader::createPixel(std::string(model_emissive_frag)); auto modelUnlitPixel = gpu::Shader::createPixel(std::string(model_unlit_frag)); auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag)); auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(model_specular_map_frag)); auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_frag)); auto modelTranslucentPixel = gpu::Shader::createPixel(std::string(model_translucent_frag)); - auto modelTranslucentEmissivePixel = gpu::Shader::createPixel(std::string(model_translucent_emissive_frag)); auto modelTranslucentUnlitPixel = gpu::Shader::createPixel(std::string(model_translucent_unlit_frag)); auto modelShadowPixel = gpu::Shader::createPixel(std::string(model_shadow_frag)); auto modelLightmapPixel = gpu::Shader::createPixel(std::string(model_lightmap_frag)); @@ -222,9 +220,6 @@ void initDeferredPipelines(render::ShapePlumber& plumber) { addPipeline( Key::Builder(), modelVertex, modelPixel); - addPipeline( - Key::Builder().withEmissive(), - modelVertex, modelEmissivePixel); addPipeline( Key::Builder().withUnlit(), modelVertex, modelUnlitPixel); @@ -241,12 +236,9 @@ void initDeferredPipelines(render::ShapePlumber& plumber) { addPipeline( Key::Builder().withTranslucent(), modelVertex, modelTranslucentPixel); - addPipeline( - Key::Builder().withTranslucent().withEmissive(), - modelVertex, modelTranslucentEmissivePixel); addPipeline( Key::Builder().withTranslucent().withUnlit(), - modelVertex, modelTranslucentEmissivePixel); + modelVertex, modelTranslucentUnlitPixel); addPipeline( Key::Builder().withTranslucent().withTangents(), modelNormalMapVertex, modelTranslucentPixel); diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index ddfd83d1d4..f1dcc942c9 100755 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -30,7 +30,7 @@ void main(void) { <$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$> float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); diff --git a/libraries/render-utils/src/model_normal_map.slf b/libraries/render-utils/src/model_normal_map.slf index 10ae6ee880..519b41e17f 100755 --- a/libraries/render-utils/src/model_normal_map.slf +++ b/libraries/render-utils/src/model_normal_map.slf @@ -31,7 +31,7 @@ void main(void) { <$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, occlusionTex)$> float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); diff --git a/libraries/render-utils/src/model_specular_map.slf b/libraries/render-utils/src/model_specular_map.slf index 9b2f4ae640..3cbb060ab5 100755 --- a/libraries/render-utils/src/model_specular_map.slf +++ b/libraries/render-utils/src/model_specular_map.slf @@ -31,7 +31,7 @@ void main(void) { <$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, occlusionTex)$> float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); diff --git a/libraries/render-utils/src/model_translucent.slf b/libraries/render-utils/src/model_translucent.slf index 1a807c5703..27a22a9763 100755 --- a/libraries/render-utils/src/model_translucent.slf +++ b/libraries/render-utils/src/model_translucent.slf @@ -38,8 +38,7 @@ void main(void) { <$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$> float opacity = getMaterialOpacity(mat) * _alpha; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; - <$discardTransparent(opacity)$>; + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; diff --git a/libraries/render-utils/src/model_translucent_unlit.slf b/libraries/render-utils/src/model_translucent_unlit.slf index c982d68d64..b9d6c64d6f 100644 --- a/libraries/render-utils/src/model_translucent_unlit.slf +++ b/libraries/render-utils/src/model_translucent_unlit.slf @@ -29,18 +29,11 @@ void main(void) { <$fetchMaterialTextures(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$> float opacity = getMaterialOpacity(mat) * _alpha; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; - <$discardTransparent(opacity)$>; + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; albedo *= _color; - vec4 albedo = texture(albedoMap, _texCoord0); - - Material mat = getMaterial(); - vec3 fragColor = getMaterialAlbedo(mat) * albedo.rgb * _color; - float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha; - - _fragColor = vec4(fragColor, fragOpacity); + _fragColor = vec4(albedo, opacity); } diff --git a/libraries/render-utils/src/model_unlit.slf b/libraries/render-utils/src/model_unlit.slf index 5a081911b7..50778153fb 100644 --- a/libraries/render-utils/src/model_unlit.slf +++ b/libraries/render-utils/src/model_unlit.slf @@ -30,7 +30,7 @@ void main(void) { <$fetchMaterialTextures(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$> float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); diff --git a/libraries/render-utils/src/overlay3D.slf b/libraries/render-utils/src/overlay3D.slf index 44e4ac1fd0..38f236e0b3 100644 --- a/libraries/render-utils/src/overlay3D.slf +++ b/libraries/render-utils/src/overlay3D.slf @@ -71,9 +71,7 @@ void main(void) { fragRoughness, fragOpacity); - if (gl_FragCoord.x > 1000) { - color = vec4(fragAlbedo, color.w); - } + // Apply standard tone mapping _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); } diff --git a/libraries/render/src/render/ShapePipeline.h b/libraries/render/src/render/ShapePipeline.h index f7932f74e8..bed3bd7c68 100644 --- a/libraries/render/src/render/ShapePipeline.h +++ b/libraries/render/src/render/ShapePipeline.h @@ -26,7 +26,6 @@ public: LIGHTMAP, TANGENTS, SPECULAR, - EMISSIVE, UNLIT, SKINNED, STEREO, @@ -58,7 +57,6 @@ public: Builder& withLightmap() { _flags.set(LIGHTMAP); return (*this); } Builder& withTangents() { _flags.set(TANGENTS); return (*this); } Builder& withSpecular() { _flags.set(SPECULAR); return (*this); } - Builder& withEmissive() { _flags.set(EMISSIVE); return (*this); } Builder& withUnlit() { _flags.set(UNLIT); return (*this); } Builder& withSkinned() { _flags.set(SKINNED); return (*this); } Builder& withStereo() { _flags.set(STEREO); return (*this); } @@ -103,9 +101,6 @@ public: Builder& withSpecular() { _flags.set(SPECULAR); _mask.set(SPECULAR); return (*this); } Builder& withoutSpecular() { _flags.reset(SPECULAR); _mask.set(SPECULAR); return (*this); } - Builder& withEmissive() { _flags.set(EMISSIVE); _mask.set(EMISSIVE); return (*this); } - Builder& withoutEmissive() { _flags.reset(EMISSIVE); _mask.set(EMISSIVE); return (*this); } - Builder& withUnlit() { _flags.set(UNLIT); _mask.set(UNLIT); return (*this); } Builder& withoutUnlit() { _flags.reset(UNLIT); _mask.set(UNLIT); return (*this); } @@ -142,7 +137,6 @@ public: bool hasLightmap() const { return _flags[LIGHTMAP]; } bool hasTangents() const { return _flags[TANGENTS]; } bool hasSpecular() const { return _flags[SPECULAR]; } - bool hasEmissive() const { return _flags[EMISSIVE]; } bool isUnlit() const { return _flags[UNLIT]; } bool isTranslucent() const { return _flags[TRANSLUCENT]; } bool isSkinned() const { return _flags[SKINNED]; } @@ -179,7 +173,6 @@ inline QDebug operator<<(QDebug debug, const ShapeKey& key) { << "hasLightmap:" << key.hasLightmap() << "hasTangents:" << key.hasTangents() << "hasSpecular:" << key.hasSpecular() - << "hasEmissive:" << key.hasEmissive() << "isUnlit:" << key.isUnlit() << "isTranslucent:" << key.isTranslucent() << "isSkinned:" << key.isSkinned()