From aec72069019c79627607d63ecb4109137542e361 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 5 Jun 2018 14:44:44 -0700 Subject: [PATCH 01/14] get rid of overlay pipelines and just use forward rendering --- interface/src/ui/overlays/Overlays.cpp | 2 - .../render-utils/src/RenderCommonTask.cpp | 4 +- .../render-utils/src/RenderDeferredTask.cpp | 1 - .../render-utils/src/RenderForwardTask.cpp | 8 +- .../render-utils/src/RenderPipelines.cpp | 101 ++++-------------- libraries/render-utils/src/overlay3D.slf | 92 ---------------- libraries/render-utils/src/overlay3D.slv | 36 ------- .../render-utils/src/overlay3D_model.slf | 79 -------------- .../src/overlay3D_model_translucent.slf | 72 ------------- .../src/overlay3D_model_translucent_unlit.slf | 41 ------- .../src/overlay3D_model_unlit.slf | 42 -------- .../src/overlay3D_translucent.slf | 87 --------------- .../src/overlay3D_translucent_unlit.slf | 27 ----- .../render-utils/src/overlay3D_unlit.slf | 32 ------ tests-manual/shaders/src/main.cpp | 5 - 15 files changed, 25 insertions(+), 604 deletions(-) delete mode 100644 libraries/render-utils/src/overlay3D.slf delete mode 100644 libraries/render-utils/src/overlay3D.slv delete mode 100644 libraries/render-utils/src/overlay3D_model.slf delete mode 100644 libraries/render-utils/src/overlay3D_model_translucent.slf delete mode 100644 libraries/render-utils/src/overlay3D_model_translucent_unlit.slf delete mode 100644 libraries/render-utils/src/overlay3D_model_unlit.slf delete mode 100644 libraries/render-utils/src/overlay3D_translucent.slf delete mode 100644 libraries/render-utils/src/overlay3D_translucent_unlit.slf delete mode 100644 libraries/render-utils/src/overlay3D_unlit.slf diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 85041aad4e..7a9ff648fb 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -41,8 +41,6 @@ Q_LOGGING_CATEGORY(trace_render_overlays, "trace.render.overlays") -extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false); - Overlays::Overlays() { auto pointerManager = DependencyManager::get(); connect(pointerManager.data(), &PointerManager::hoverBeginOverlay, this, &Overlays::hoverEnterPointerEvent); diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 293393550b..24715f0afb 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -14,7 +14,7 @@ #include "RenderUtilsLogging.h" using namespace render; -extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false); +extern void initForwardPipelines(ShapePlumber& plumber); void BeginGPURangeTimer::run(const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) { timer = _gpuTimer; @@ -35,7 +35,7 @@ void EndGPURangeTimer::run(const render::RenderContextPointer& renderContext, co DrawOverlay3D::DrawOverlay3D(bool opaque) : _shapePlumber(std::make_shared()), _opaquePass(opaque) { - initOverlay3DPipelines(*_shapePlumber); + initForwardPipelines(*_shapePlumber); } void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& inputs) { diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 47cab54d09..dc12c0f781 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -53,7 +53,6 @@ #include using namespace render; -extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false); extern void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter); RenderDeferredTask::RenderDeferredTask() diff --git a/libraries/render-utils/src/RenderForwardTask.cpp b/libraries/render-utils/src/RenderForwardTask.cpp index 09a2afb711..d2933627f4 100755 --- a/libraries/render-utils/src/RenderForwardTask.cpp +++ b/libraries/render-utils/src/RenderForwardTask.cpp @@ -37,10 +37,7 @@ #include "nop_frag.h" using namespace render; -extern void initForwardPipelines(ShapePlumber& plumber, - const render::ShapePipeline::BatchSetter& batchSetter, - const render::ShapePipeline::ItemSetter& itemSetter); -extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false); +extern void initForwardPipelines(ShapePlumber& plumber); void RenderForwardTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { auto items = input.get(); @@ -48,8 +45,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend // Prepare the ShapePipelines ShapePlumberPointer shapePlumber = std::make_shared(); - initForwardPipelines(*shapePlumber, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); - initOverlay3DPipelines(*shapePlumber); + initForwardPipelines(*shapePlumber); // Extract opaques / transparents / lights / metas / overlays / background const auto& opaques = items.get0()[RenderFetchCullSortTask::OPAQUE_SHAPE]; diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index b02266e67b..39da386dc4 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -80,16 +80,6 @@ #include "model_translucent_unlit_fade_frag.h" #include "model_translucent_normal_map_fade_frag.h" -#include "overlay3D_vert.h" -#include "overlay3D_frag.h" -#include "overlay3D_model_frag.h" -#include "overlay3D_model_translucent_frag.h" -#include "overlay3D_translucent_frag.h" -#include "overlay3D_unlit_frag.h" -#include "overlay3D_translucent_unlit_frag.h" -#include "overlay3D_model_unlit_frag.h" -#include "overlay3D_model_translucent_unlit_frag.h" - #include "model_shadow_vert.h" #include "skin_model_shadow_vert.h" #include "skin_model_shadow_dq_vert.h" @@ -104,12 +94,16 @@ #include "model_shadow_fade_frag.h" #include "skin_model_shadow_fade_frag.h" +#include "simple_vert.h" +#include "forward_simple_textured_frag.h" +#include "forward_simple_textured_transparent_frag.h" +#include "forward_simple_textured_unlit_frag.h" + using namespace render; using namespace std::placeholders; -void initOverlay3DPipelines(ShapePlumber& plumber, bool depthTest = false); void initDeferredPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter); -void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter); +void initForwardPipelines(ShapePlumber& plumber); void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state); void addPlumberPipeline(ShapePlumber& plumber, @@ -120,71 +114,6 @@ void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* a void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* args); static bool forceLightBatchSetter{ false }; -void initOverlay3DPipelines(ShapePlumber& plumber, bool depthTest) { - auto vertex = overlay3D_vert::getShader(); - auto vertexModel = model_vert::getShader(); - auto pixel = overlay3D_frag::getShader(); - auto pixelTranslucent = overlay3D_translucent_frag::getShader(); - auto pixelUnlit = overlay3D_unlit_frag::getShader(); - auto pixelTranslucentUnlit = overlay3D_translucent_unlit_frag::getShader(); - auto pixelModel = overlay3D_model_frag::getShader(); - auto pixelModelTranslucent = overlay3D_model_translucent_frag::getShader(); - auto pixelModelUnlit = overlay3D_model_unlit_frag::getShader(); - auto pixelModelTranslucentUnlit = overlay3D_model_translucent_unlit_frag::getShader(); - - auto opaqueProgram = gpu::Shader::createProgram(vertex, pixel); - auto translucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucent); - auto unlitOpaqueProgram = gpu::Shader::createProgram(vertex, pixelUnlit); - auto unlitTranslucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucentUnlit); - auto materialOpaqueProgram = gpu::Shader::createProgram(vertexModel, pixelModel); - auto materialTranslucentProgram = gpu::Shader::createProgram(vertexModel, pixelModelTranslucent); - auto materialUnlitOpaqueProgram = gpu::Shader::createProgram(vertexModel, pixelModel); - auto materialUnlitTranslucentProgram = gpu::Shader::createProgram(vertexModel, pixelModelTranslucent); - - for (int i = 0; i < 8; i++) { - bool isCulled = (i & 1); - bool isBiased = (i & 2); - bool isOpaque = (i & 4); - - auto state = std::make_shared(); - if (depthTest) { - state->setDepthTest(true, true, gpu::LESS_EQUAL); - } else { - state->setDepthTest(false); - } - state->setCullMode(isCulled ? gpu::State::CULL_BACK : gpu::State::CULL_NONE); - if (isBiased) { - state->setDepthBias(1.0f); - state->setDepthBiasSlopeScale(1.0f); - } - if (isOpaque) { - // Soft edges - state->setBlendFunction(true, - gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA); - } else { - state->setBlendFunction(true, - gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - } - - ShapeKey::Filter::Builder builder; - - isCulled ? builder.withCullFace() : builder.withoutCullFace(); - isBiased ? builder.withDepthBias() : builder.withoutDepthBias(); - isOpaque ? builder.withOpaque() : builder.withTranslucent(); - - auto simpleProgram = isOpaque ? opaqueProgram : translucentProgram; - auto unlitProgram = isOpaque ? unlitOpaqueProgram : unlitTranslucentProgram; - auto materialProgram = isOpaque ? materialOpaqueProgram : materialTranslucentProgram; - auto materialUnlitProgram = isOpaque ? materialUnlitOpaqueProgram : materialUnlitTranslucentProgram; - - plumber.addPipeline(builder.withMaterial().build().key(), materialProgram, state, &lightBatchSetter); - plumber.addPipeline(builder.withMaterial().withUnlit().build().key(), materialUnlitProgram, state, &batchSetter); - plumber.addPipeline(builder.withoutUnlit().withoutMaterial().build().key(), simpleProgram, state, &lightBatchSetter); - plumber.addPipeline(builder.withUnlit().withoutMaterial().build().key(), unlitProgram, state, &batchSetter); - } -} - void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) { // Vertex shaders auto simpleVertex = simple_vert::getShader(); @@ -432,8 +361,9 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip skinModelShadowFadeDualQuatVertex, modelShadowFadePixel, batchSetter, itemSetter); } -void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) { +void initForwardPipelines(ShapePlumber& plumber) { // Vertex shaders + auto simpleVertex = simple_vert::getShader(); auto modelVertex = model_vert::getShader(); auto modelNormalMapVertex = model_normal_map_vert::getShader(); auto skinModelVertex = skin_model_vert::getShader(); @@ -443,6 +373,10 @@ void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::Ba auto skinModelNormalMapDualQuatVertex = skin_model_normal_map_dq_vert::getShader(); // Pixel shaders + auto simplePixel = forward_simple_textured_frag::getShader(); + auto simpleTranslucentPixel = forward_simple_textured_transparent_frag::getShader(); + auto simpleUnlitPixel = forward_simple_textured_unlit_frag::getShader(); + auto simpleTranslucentUnlitPixel = simple_transparent_textured_unlit_frag::getShader(); auto modelPixel = forward_model_frag::getShader(); auto modelUnlitPixel = forward_model_unlit_frag::getShader(); auto modelNormalMapPixel = forward_model_normal_map_frag::getShader(); @@ -458,8 +392,15 @@ void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::Ba }; // Forward pipelines need the lightBatchSetter for opaques and transparents - // forceLightBatchSetter = true; - forceLightBatchSetter = false; + forceLightBatchSetter = true; + + // Simple Opaques + addPipeline(Key::Builder(), simpleVertex, simplePixel); + addPipeline(Key::Builder().withUnlit(), simpleVertex, simpleUnlitPixel); + + // Simple Translucents + addPipeline(Key::Builder().withTranslucent(), simpleVertex, simpleTranslucentPixel); + addPipeline(Key::Builder().withTranslucent().withUnlit(), simpleVertex, simpleTranslucentUnlitPixel); // Opaques addPipeline(Key::Builder().withMaterial(), modelVertex, modelPixel); diff --git a/libraries/render-utils/src/overlay3D.slf b/libraries/render-utils/src/overlay3D.slf deleted file mode 100644 index 83cee88790..0000000000 --- a/libraries/render-utils/src/overlay3D.slf +++ /dev/null @@ -1,92 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// overlay3D.slf -// fragment shader -// -// Created by Sam Gateau on 6/16/15. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - - -<@include graphics/Light.slh@> -<$declareLightBuffer()$> -<$declareLightAmbientBuffer()$> - -<@include LightingModel.slh@> - -<@include LightDirectional.slh@> -<$declareLightingDirectional()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 fresnel, float roughness, float opacity) { - - // Need the light now - Light light = getKeyLight(); - vec3 lightDirection = getLightDirection(light); - vec3 lightIrradiance = getLightIrradiance(light); - - LightAmbient ambient = getLightAmbient(); - - TransformCamera cam = getTransformCamera(); - vec3 fragEyeVectorView = normalize(-position); - vec3 fragEyeDir; - <$transformEyeToWorldDir(cam, fragEyeVectorView, fragEyeDir)$> - - SurfaceData surface = initSurfaceData(roughness, normal, fragEyeDir); - - vec3 color = opacity * albedo * getLightColor(light) * getLightAmbientIntensity(ambient); - - // Directional - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation); - color += directionalDiffuse * isDiffuseEnabled() * isDirectionalEnabled(); - color += directionalSpecular * isSpecularEnabled() * isDirectionalEnabled(); - - return vec4(color, opacity); -} - -uniform sampler2D originalTexture; - -in vec2 _texCoord0; -in vec4 _positionES; -in vec3 _normalWS; -in vec3 _color; -in float _alpha; - -out vec4 _fragColor; - -void main(void) { - vec4 albedo = texture(originalTexture, _texCoord0); - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal = normalize(_normalWS); - vec3 fragAlbedo = albedo.rgb * _color; - float fragMetallic = 0.0; - vec3 fragSpecular = vec3(0.1); - float fragRoughness = 0.9; - float fragOpacity = albedo.a; - - if (fragOpacity <= 0.1) { - discard; - } - - vec4 color = evalGlobalColor(1.0, - fragPosition, - fragNormal, - fragAlbedo, - fragMetallic, - fragSpecular, - fragRoughness, - fragOpacity); - - - // Apply standard tone mapping - _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); -} diff --git a/libraries/render-utils/src/overlay3D.slv b/libraries/render-utils/src/overlay3D.slv deleted file mode 100644 index 9e13fb3776..0000000000 --- a/libraries/render-utils/src/overlay3D.slv +++ /dev/null @@ -1,36 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// overlay3D.slv -// vertex shader -// -// Created by Sam Gateau on 6/16/15. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include gpu/Inputs.slh@> -<@include gpu/Color.slh@> -<@include gpu/Transform.slh@> -<$declareStandardTransform()$> - -out vec3 _color; -out float _alpha; -out vec2 _texCoord0; -out vec4 _positionES; -out vec3 _normalWS; - -void main(void) { - _color = color_sRGBToLinear(inColor.xyz); - _alpha = inColor.w; - - _texCoord0 = inTexCoord0.st; - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> - <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> -} diff --git a/libraries/render-utils/src/overlay3D_model.slf b/libraries/render-utils/src/overlay3D_model.slf deleted file mode 100644 index fd6470efb2..0000000000 --- a/libraries/render-utils/src/overlay3D_model.slf +++ /dev/null @@ -1,79 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// overlay3D.slf -// fragment shader -// -// Created by Sam Gateau on 6/16/15. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include DeferredGlobalLight.slh@> -<$declareEvalSkyboxGlobalColor()$> - -<@include graphics/Material.slh@> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include MaterialTextures.slh@> -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$> - -in vec2 _texCoord0; -in vec2 _texCoord1; -in vec4 _positionES; -in vec3 _normalWS; -in vec3 _color; -in float _alpha; - -out vec4 _fragColor; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; - - float metallic = getMaterialMetallic(mat); - vec3 fresnel = getFresnelF0(metallic, albedo); - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - - vec3 fragPosition = _positionES.xyz; - - TransformCamera cam = getTransformCamera(); - - vec4 color = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - occlusionTex, - fragPosition, - normalize(_normalWS), - albedo, - fresnel, - metallic, - roughness), - opacity); - - // And emissive - color.rgb += emissive * isEmissiveEnabled(); - - // Apply standard tone mapping - _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); -} \ No newline at end of file diff --git a/libraries/render-utils/src/overlay3D_model_translucent.slf b/libraries/render-utils/src/overlay3D_model_translucent.slf deleted file mode 100644 index 0c5b922d34..0000000000 --- a/libraries/render-utils/src/overlay3D_model_translucent.slf +++ /dev/null @@ -1,72 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// overlay3D_model_transparent.slf -// -// Created by Sam Gateau on 2/27/2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include graphics/Material.slh@> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include MaterialTextures.slh@> -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$> - -in vec2 _texCoord0; -in vec2 _texCoord1; -in vec4 _positionES; -in vec3 _normalWS; -in vec3 _color; - -out vec4 _fragColor; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; - - float metallic = getMaterialMetallic(mat); - vec3 fresnel = getFresnelF0(metallic, albedo); - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - vec3 fragPosition = _positionES.xyz; - TransformCamera cam = getTransformCamera(); - - vec4 color = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - occlusionTex, - fragPosition, - normalize(_normalWS), - albedo, - fresnel, - metallic, - emissive, - roughness, opacity), - opacity); - - // Apply standard tone mapping - _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); -} \ No newline at end of file diff --git a/libraries/render-utils/src/overlay3D_model_translucent_unlit.slf b/libraries/render-utils/src/overlay3D_model_translucent_unlit.slf deleted file mode 100644 index b1822a645a..0000000000 --- a/libraries/render-utils/src/overlay3D_model_translucent_unlit.slf +++ /dev/null @@ -1,41 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// overlay3D-model_transparent_unlit.slf -// fragment shader -// -// Created by Sam Gateau on 2/28/2017. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include LightingModel.slh@> -<@include graphics/Material.slh@> - -<@include MaterialTextures.slh@> -<$declareMaterialTextures(ALBEDO)$> - -in vec2 _texCoord0; -in vec3 _color; - -out vec4 _fragColor; - -void main(void) { - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; - - vec4 color = vec4(albedo * isUnlitEnabled(), opacity); - - _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); -} \ No newline at end of file diff --git a/libraries/render-utils/src/overlay3D_model_unlit.slf b/libraries/render-utils/src/overlay3D_model_unlit.slf deleted file mode 100644 index cc16d0751d..0000000000 --- a/libraries/render-utils/src/overlay3D_model_unlit.slf +++ /dev/null @@ -1,42 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// overlay3D-model_unlit.slf -// fragment shader -// -// Created by Sam Gateau on 2/28/2017. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include LightingModel.slh@> -<@include graphics/Material.slh@> - -<@include MaterialTextures.slh@> -<$declareMaterialTextures(ALBEDO)$> - -in vec2 _texCoord0; -in vec3 _color; - -out vec4 _fragColor; - -void main(void) { - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; - - vec4 color = vec4(albedo * isUnlitEnabled(), opacity); - - _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); -} diff --git a/libraries/render-utils/src/overlay3D_translucent.slf b/libraries/render-utils/src/overlay3D_translucent.slf deleted file mode 100644 index b93550a63d..0000000000 --- a/libraries/render-utils/src/overlay3D_translucent.slf +++ /dev/null @@ -1,87 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// overlay3D_translucent.slf -// fragment shader -// -// Created by Sam Gateau on 6/16/15. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include graphics/Light.slh@> -<$declareLightBuffer()$> -<$declareLightAmbientBuffer()$> - -<@include LightingModel.slh@> - -<@include LightDirectional.slh@> -<$declareLightingDirectional()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 fresnel, float roughness, float opacity) { - - // Need the light now - Light light = getKeyLight(); - vec3 lightDirection = getLightDirection(light); - vec3 lightIrradiance = getLightIrradiance(light); - - LightAmbient ambient = getLightAmbient(); - - TransformCamera cam = getTransformCamera(); - vec3 fragEyeVectorView = normalize(-position); - vec3 fragEyeDir; - <$transformEyeToWorldDir(cam, fragEyeVectorView, fragEyeDir)$> - - SurfaceData surface = initSurfaceData(roughness, normal, fragEyeDir); - - vec3 color = opacity * albedo * getLightColor(light) * getLightAmbientIntensity(ambient); - - // Directional - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation); - color += directionalDiffuse; - color += directionalSpecular / opacity; - - return vec4(color, opacity); -} - -uniform sampler2D originalTexture; - -in vec2 _texCoord0; -in vec4 _positionES; -in vec3 _normalWS; -in vec3 _color; -in float _alpha; - -out vec4 _fragColor; - -void main(void) { - vec4 albedo = texture(originalTexture, _texCoord0); - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal = normalize(_normalWS); - vec3 fragAlbedo = albedo.rgb * _color; - float fragMetallic = 0.0; - vec3 fragSpecular = vec3(0.1); - float fragRoughness = 0.9; - float fragOpacity = albedo.a * _alpha; - - vec4 color = evalGlobalColor(1.0, - fragPosition, - fragNormal, - fragAlbedo, - fragMetallic, - fragSpecular, - fragRoughness, - fragOpacity); - - // Apply standard tone mapping - _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); -} diff --git a/libraries/render-utils/src/overlay3D_translucent_unlit.slf b/libraries/render-utils/src/overlay3D_translucent_unlit.slf deleted file mode 100644 index 18a26d0790..0000000000 --- a/libraries/render-utils/src/overlay3D_translucent_unlit.slf +++ /dev/null @@ -1,27 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// overlay3D_translucent_unlit.frag -// fragment shader -// -// Created by Zach Pomerantz on 2/2/2016. -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -uniform sampler2D originalTexture; - -in vec2 _texCoord0; -in vec3 _color; -in float _alpha; - -out vec4 _fragColor; - -void main(void) { - vec4 albedo = texture(originalTexture, _texCoord0); - - _fragColor = vec4(albedo.rgb * _color, albedo.a * _alpha); -} diff --git a/libraries/render-utils/src/overlay3D_unlit.slf b/libraries/render-utils/src/overlay3D_unlit.slf deleted file mode 100644 index 42e51bdc25..0000000000 --- a/libraries/render-utils/src/overlay3D_unlit.slf +++ /dev/null @@ -1,32 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// overlay3D_unlit.frag -// fragment shader -// -// Created by Zach Pomerantz on 2/2/2016. -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -uniform sampler2D originalTexture; - -in vec2 _texCoord0; -in vec3 _color; - -out vec4 _fragColor; - -void main(void) { - vec4 albedo = texture(originalTexture, _texCoord0); - - if (albedo.a <= 0.1) { - discard; - } - vec4 color = vec4(albedo.rgb * _color, albedo.a); - - // Apply standard tone mapping - _fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w); -} diff --git a/tests-manual/shaders/src/main.cpp b/tests-manual/shaders/src/main.cpp index 67cb58182c..6e117b33cb 100644 --- a/tests-manual/shaders/src/main.cpp +++ b/tests-manual/shaders/src/main.cpp @@ -57,9 +57,6 @@ #include #include -#include -#include - #include #include @@ -195,8 +192,6 @@ void QTestWindow::draw() { testShaderBuild(ambient_occlusion_vert::getSource(), occlusion_blend_frag::getSource()); */ - testShaderBuild(overlay3D_vert::getSource(), overlay3D_frag::getSource()); - testShaderBuild(paintStroke_vert::getSource(),paintStroke_frag::getSource()); testShaderBuild(polyvox_vert::getSource(), polyvox_frag::getSource()); From d2f8ee327d75793e8f7135a63a561d434872cd68 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 5 Jun 2018 18:18:24 -0700 Subject: [PATCH 02/14] properly reset highlight framebuffer --- libraries/render-utils/src/HighlightEffect.cpp | 12 ++++++++++-- libraries/render-utils/src/HighlightEffect.h | 4 ++-- libraries/render-utils/src/RenderCommonTask.cpp | 2 +- libraries/render-utils/src/RenderPipelines.cpp | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libraries/render-utils/src/HighlightEffect.cpp b/libraries/render-utils/src/HighlightEffect.cpp index 3905d3a54c..20d0cc39be 100644 --- a/libraries/render-utils/src/HighlightEffect.cpp +++ b/libraries/render-utils/src/HighlightEffect.cpp @@ -286,6 +286,7 @@ void DrawHighlight::run(const render::RenderContextPointer& renderContext, const shaderParameters._size.y = size; } + auto primaryFramebuffer = inputs.get4(); gpu::doInBatch("DrawHighlight::run", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(destinationFrameBuffer); @@ -301,6 +302,9 @@ void DrawHighlight::run(const render::RenderContextPointer& renderContext, const batch.setResourceTexture(SCENE_DEPTH_MAP_SLOT, sceneDepthBuffer->getPrimaryDepthTexture()); batch.setResourceTexture(HIGHLIGHTED_DEPTH_MAP_SLOT, highlightedDepthTexture); batch.draw(gpu::TRIANGLE_STRIP, 4); + + // Reset the framebuffer for overlay drawing + batch.setFramebuffer(primaryFramebuffer); }); } } @@ -360,6 +364,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons RenderArgs* args = renderContext->args; const auto jitter = input.get2(); + auto primaryFramebuffer = input.get3(); gpu::doInBatch("DebugHighlight::run", args->_context, [&](gpu::Batch& batch) { batch.setViewportTransform(args->_viewport); batch.setFramebuffer(highlightRessources->getColorFramebuffer()); @@ -384,6 +389,9 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons geometryBuffer->renderQuad(batch, bottomLeft, topRight, color, _geometryDepthId); batch.setResourceTexture(0, nullptr); + + // Reset the framebuffer for overlay drawing + batch.setFramebuffer(primaryFramebuffer); }); } } @@ -532,12 +540,12 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren stream << "HighlightEffect" << i; name = stream.str(); } - const auto drawHighlightInputs = DrawHighlight::Inputs(deferredFrameTransform, highlightRessources, sceneFrameBuffer, highlightedRect).asVarying(); + const auto drawHighlightInputs = DrawHighlight::Inputs(deferredFrameTransform, highlightRessources, sceneFrameBuffer, highlightedRect, primaryFramebuffer).asVarying(); task.addJob(name, drawHighlightInputs, i, sharedParameters); } // Debug highlight - const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast(highlight0Rect), jitter).asVarying(); + const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast(highlight0Rect), jitter, primaryFramebuffer).asVarying(); task.addJob("HighlightDebug", debugInputs); } diff --git a/libraries/render-utils/src/HighlightEffect.h b/libraries/render-utils/src/HighlightEffect.h index 7c1db795fb..8af11da237 100644 --- a/libraries/render-utils/src/HighlightEffect.h +++ b/libraries/render-utils/src/HighlightEffect.h @@ -135,7 +135,7 @@ protected: class DrawHighlight { public: - using Inputs = render::VaryingSet4; + using Inputs = render::VaryingSet5; using Config = render::Job::Config; using JobModel = render::Job::ModelI; @@ -182,7 +182,7 @@ signals: class DebugHighlight { public: - using Inputs = render::VaryingSet3; + using Inputs = render::VaryingSet4; using Config = DebugHighlightConfig; using JobModel = render::Job::ModelI; diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 24715f0afb..63d07af1c2 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -60,7 +60,7 @@ void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& if (_opaquePass) { gpu::doInBatch("DrawOverlay3D::run::clear", args->_context, [&](gpu::Batch& batch){ batch.enableStereo(false); - batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(), 1.f, 0, false); + batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTHSTENCIL, glm::vec4(), 1.f, 0, false); }); } diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index 39da386dc4..6a653bb192 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -442,7 +442,7 @@ void addPlumberPipeline(ShapePlumber& plumber, bool isWireframed = (i & 4); auto state = std::make_shared(); - PrepareStencil::testMaskDrawShape(*state); + key.isTranslucent() ? PrepareStencil::testMask(*state) : PrepareStencil::testMaskDrawShape(*state); // Depth test depends on transparency state->setDepthTest(true, !key.isTranslucent(), gpu::LESS_EQUAL); From 84601446bf8cfda54f9e4b02f77bcb95a4d122bf Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 14 Jun 2018 12:57:30 -0700 Subject: [PATCH 03/14] Add main thread id & machine fingerprint to crashpad annotations --- interface/src/Application.cpp | 4 ++++ .../src/display-plugins/OpenGLDisplayPlugin.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index acdcdef2cf..57058c46fc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -283,7 +283,9 @@ public: private: void initialize() { + setObjectName("Render"); PROFILE_SET_THREAD_NAME("Render"); + setCrashAnnotation("render_thread_id", std::to_string((size_t)QThread::currentThreadId())); if (!_renderContext->makeCurrent()) { qFatal("Unable to make rendering context current on render thread"); } @@ -1099,6 +1101,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _logger->setSessionID(accountManager->getSessionID()); setCrashAnnotation("metaverse_session_id", accountManager->getSessionID().toString().toStdString()); + setCrashAnnotation("main_thread_id", std::to_string((size_t)QThread::currentThreadId())); if (steamClient) { qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID(); @@ -1440,6 +1443,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo Setting::Handle firstRun { Settings::firstRun, true }; QString machineFingerPrint = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint()); + setCrashAnnotation("machine_fingerprint", machineFingerPrint.toStdString()); auto& userActivityLogger = UserActivityLogger::getInstance(); if (userActivityLogger.isEnabled()) { diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 513f955e9e..0d556544bb 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -83,6 +83,7 @@ public: connect(qApp, &QCoreApplication::aboutToQuit, [this] { shutdown(); }); + setObjectName("Present"); } ~PresentThread() { From 24689224ceba3298a7d4b3629c9229d8e9ec8478 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Fri, 15 Jun 2018 11:40:45 -0700 Subject: [PATCH 04/14] removed redundant machine_fingerprent crashpad annotation. --- interface/src/Application.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 57058c46fc..a8662b95d1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1443,7 +1443,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo Setting::Handle firstRun { Settings::firstRun, true }; QString machineFingerPrint = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint()); - setCrashAnnotation("machine_fingerprint", machineFingerPrint.toStdString()); auto& userActivityLogger = UserActivityLogger::getInstance(); if (userActivityLogger.isEnabled()) { From 551bfac85e793cc1a0919b4fa74641e288dbc7a2 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 15 Jun 2018 14:30:59 -0700 Subject: [PATCH 05/14] fix crash mode for Animation::_geometry access before ready --- libraries/animation/src/AnimationCache.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/animation/src/AnimationCache.cpp b/libraries/animation/src/AnimationCache.cpp index 9aa315beb8..f30d5605d7 100644 --- a/libraries/animation/src/AnimationCache.cpp +++ b/libraries/animation/src/AnimationCache.cpp @@ -105,8 +105,10 @@ QStringList Animation::getJointNames() const { return result; } QStringList names; - foreach (const FBXJoint& joint, _geometry->joints) { - names.append(joint.name); + if (_geometry) { + foreach (const FBXJoint& joint, _geometry->joints) { + names.append(joint.name); + } } return names; } @@ -114,11 +116,15 @@ QStringList Animation::getJointNames() const { QVector Animation::getFrames() const { if (QThread::currentThread() != thread()) { QVector result; - BLOCKING_INVOKE_METHOD(const_cast(this), "getFrames", + BLOCKING_INVOKE_METHOD(const_cast(this), "getFrames", Q_RETURN_ARG(QVector, result)); return result; } - return _geometry->animationFrames; + if (_geometry) { + return _geometry->animationFrames; + } else { + return QVector(); + } } const QVector& Animation::getFramesReference() const { From 670e07bbf5ea1e785e5bf68ee683bc1f58887854 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 15 Jun 2018 14:31:51 -0700 Subject: [PATCH 06/14] fix crash for computing inertia for btBvhTriangleMeshShape --- libraries/physics/src/ObjectMotionState.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 64d2368207..161d6bd636 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -92,7 +92,7 @@ void ObjectMotionState::setMass(float mass) { } float ObjectMotionState::getMass() const { - if (_shape) { + if (_shape && _shape->getShapeType() != TRIANGLE_MESH_SHAPE_PROXYTYPE) { // scale the density by the current Aabb volume to get mass btTransform transform; transform.setIdentity(); @@ -348,8 +348,10 @@ void ObjectMotionState::updateLastKinematicStep() { void ObjectMotionState::updateBodyMassProperties() { float mass = getMass(); - btVector3 inertia(0.0f, 0.0f, 0.0f); - _body->getCollisionShape()->calculateLocalInertia(mass, inertia); + btVector3 inertia(1.0f, 1.0f, 1.0f); + if (mass > 0.0f) { + _body->getCollisionShape()->calculateLocalInertia(mass, inertia); + } _body->setMassProps(mass, inertia); _body->updateInertiaTensor(); } From 8ddcff6070d44958383c6bdaf77232ff2f4d365d Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Fri, 15 Jun 2018 14:47:02 -0700 Subject: [PATCH 07/14] Set username annotation more reliably. --- interface/src/Application.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a8662b95d1..df86ed80ee 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6176,6 +6176,8 @@ void Application::updateWindowTitle() const { QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED)"; QString username = accountManager->getAccountInfo().getUsername(); + setCrashAnnotation("username", username.toStdString()); + QString currentPlaceName; if (isServerlessMode()) { currentPlaceName = "serverless: " + DependencyManager::get()->getDomainURL().toString(); From cdce598c35bcd61fbeb2098b25474964e889de0d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 15 Jun 2018 14:49:07 -0700 Subject: [PATCH 08/14] protect against misuse of Sysmem::setSubData() --- libraries/gpu/src/gpu/Sysmem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu/src/gpu/Sysmem.cpp b/libraries/gpu/src/gpu/Sysmem.cpp index a642d40478..d942c3fd27 100644 --- a/libraries/gpu/src/gpu/Sysmem.cpp +++ b/libraries/gpu/src/gpu/Sysmem.cpp @@ -124,7 +124,7 @@ Size Sysmem::setData( Size size, const Byte* bytes ) { } Size Sysmem::setSubData( Size offset, Size size, const Byte* bytes) { - if (size && ((offset + size) <= getSize()) && bytes) { + if (_data && size && ((offset + size) <= getSize()) && bytes) { memcpy( _data + offset, bytes, size ); return size; } From 4880492d058d6ea609c23bf9baf4b7494dd35df3 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 15 Jun 2018 14:49:46 -0700 Subject: [PATCH 09/14] protect against bad menu pointer --- libraries/ui/src/ui/Menu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/ui/src/ui/Menu.cpp b/libraries/ui/src/ui/Menu.cpp index 16af862324..848b2362ee 100644 --- a/libraries/ui/src/ui/Menu.cpp +++ b/libraries/ui/src/ui/Menu.cpp @@ -402,8 +402,10 @@ MenuWrapper* Menu::addMenu(const QString& menuName, const QString& grouping) { // hook our show/hide for popup menus, so we can keep track of whether or not one // of our submenus is currently showing. - connect(menu->_realMenu, &QMenu::aboutToShow, []() { _isSomeSubmenuShown = true; }); - connect(menu->_realMenu, &QMenu::aboutToHide, []() { _isSomeSubmenuShown = false; }); + if (menu && menu->_realMenu) { + connect(menu->_realMenu, &QMenu::aboutToShow, []() { _isSomeSubmenuShown = true; }); + connect(menu->_realMenu, &QMenu::aboutToHide, []() { _isSomeSubmenuShown = false; }); + } return menu; } From 2feecf6db8c7bd1893c1cc8d6de79b178fecd0b8 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Fri, 15 Jun 2018 14:56:10 -0700 Subject: [PATCH 10/14] removed unnecessary setting of 'username' annotation. --- interface/src/Application.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index df86ed80ee..e00275591b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1247,9 +1247,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); #endif connect(accountManager.data(), &AccountManager::usernameChanged, this, &Application::updateWindowTitle); - connect(accountManager.data(), &AccountManager::usernameChanged, [](QString username){ - setCrashAnnotation("username", username.toStdString()); - }); // set the account manager's root URL and trigger a login request if we don't have the access token accountManager->setIsAgent(true); From b60e3c6c7b13d165d4e21003c3f5dd5766221650 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 15 Jun 2018 17:09:32 -0700 Subject: [PATCH 11/14] fix etclib link when building RelWithDebInfo on OSX --- cmake/externals/etc2comp/CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/externals/etc2comp/CMakeLists.txt b/cmake/externals/etc2comp/CMakeLists.txt index d6d21d6703..d8396404dd 100644 --- a/cmake/externals/etc2comp/CMakeLists.txt +++ b/cmake/externals/etc2comp/CMakeLists.txt @@ -40,16 +40,22 @@ if (WIN32) set(_LIB_FOLDER "$<$:build/EtcLib/RelWithDebInfo>") set(_LIB_FOLDER "${_LIB_FOLDER}$<$:build/EtcLib/MinSizeRel>") set(_LIB_FOLDER "${_LIB_FOLDER}$<$,$>:build/EtcLib/Release>") - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/${_LIB_FOLDER}/EtcLib.lib CACHE FILEPATH "Path to Etc2Comp release library") + elseif (APPLE) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/build/EtcLib/Debug/libEtcLib.a CACHE FILEPATH "Path to EtcLib debug library") - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/build/EtcLib/Release/libEtcLib.a CACHE FILEPATH "Path to EtcLib release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/build/EtcLib/Debug/libEtcLib.a CACHE FILEPATH "Path to EtcLib debug library") + + set(_LIB_FOLDER "$<$:build/EtcLib/RelWithDebInfo>") + set(_LIB_FOLDER "${_LIB_FOLDER}$<$:build/EtcLib/MinSizeRel>") + set(_LIB_FOLDER "${_LIB_FOLDER}$<$,$>:build/EtcLib/Release>") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/${_LIB_FOLDER}/libEtcLib.a CACHE FILEPATH "Path to Etc2Comp release library") + else () set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG "" CACHE FILEPATH "Path to EtcLib debug library") set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/build/EtcLib/libEtcLib.a CACHE FILEPATH "Path to EtcLib release library") + endif () set(ETC_INCLUDE_DIR ${SOURCE_DIR}/EtcLib/Etc CACHE FILEPATH "Path to Etc2Comp/Etc include directory") set(ETCCODEC_INCLUDE_DIR ${SOURCE_DIR}/EtcLib/EtcCodec CACHE FILEPATH "Path to Etc2Comp/EtcCodec include directory") -# ETC2COMP_INCLUDE_DIRS will be set later by FindEtc2Comp \ No newline at end of file +# ETC2COMP_INCLUDE_DIRS will be set later by FindEtc2Comp From f307f1d97ab8aa4ee87c0866879c41b285389403 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 18 Jun 2018 10:19:00 -0700 Subject: [PATCH 12/14] Fix MS15545: Fix PAL/GoTo WebView's Back Button --- interface/resources/qml/controls/TabletWebView.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/controls/TabletWebView.qml b/interface/resources/qml/controls/TabletWebView.qml index 477422cfa1..bc958aa876 100644 --- a/interface/resources/qml/controls/TabletWebView.qml +++ b/interface/resources/qml/controls/TabletWebView.qml @@ -11,7 +11,6 @@ Item { height: parent !== null ? parent.height : undefined property var parentStackItem: null property int headerHeight: 70 - property string url property string scriptURL property bool keyboardEnabled: false property bool keyboardRaised: false @@ -23,6 +22,7 @@ Item { property bool punctuationMode: false property bool passwordField: false property bool isDesktop: false + property alias url: web.url property alias webView: web.webViewCore property alias profile: web.webViewCoreProfile property bool remove: false @@ -81,7 +81,7 @@ Item { color: hifi.colors.baseGray font.pixelSize: 12 verticalAlignment: Text.AlignLeft - text: root.url + text: web.url anchors { top: nav.bottom horizontalCenter: parent.horizontalCenter; @@ -131,11 +131,11 @@ Item { function loadUrl(url) { web.webViewCore.url = url - root.url = web.webViewCore.url; } - onUrlChanged: { - loadUrl(url); + Rectangle { + anchors.fill: web; + color: hifi.colors.white; } FlickableWebViewCore { From 085130e3c92506eeaba72f60fd4aa76544fee16d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 18 Jun 2018 13:17:32 -0700 Subject: [PATCH 13/14] avatars collide again again --- interface/src/avatar/AvatarMotionState.cpp | 47 ++++++++++++++----- interface/src/avatar/AvatarMotionState.h | 6 +++ .../src/avatars-renderer/Avatar.cpp | 13 +++-- libraries/physics/src/ObjectMotionState.h | 4 +- libraries/physics/src/PhysicsEngine.cpp | 6 +-- libraries/shared/src/AvatarConstants.h | 1 + 6 files changed, 54 insertions(+), 23 deletions(-) diff --git a/interface/src/avatar/AvatarMotionState.cpp b/interface/src/avatar/AvatarMotionState.cpp index 4c5aaacb95..6fc1bd8196 100644 --- a/interface/src/avatar/AvatarMotionState.cpp +++ b/interface/src/avatar/AvatarMotionState.cpp @@ -21,6 +21,17 @@ AvatarMotionState::AvatarMotionState(AvatarSharedPointer avatar, const btCollisi _type = MOTIONSTATE_TYPE_AVATAR; } +void AvatarMotionState::handleEasyChanges(uint32_t& flags) { + ObjectMotionState::handleEasyChanges(flags); + if (flags & Simulation::DIRTY_PHYSICS_ACTIVATION && !_body->isActive()) { + _body->activate(); + } +} + +bool AvatarMotionState::handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) { + return ObjectMotionState::handleHardAndEasyChanges(flags, engine); +} + AvatarMotionState::~AvatarMotionState() { assert(_avatar); _avatar = nullptr; @@ -46,6 +57,9 @@ PhysicsMotionType AvatarMotionState::computePhysicsMotionType() const { const btCollisionShape* AvatarMotionState::computeNewShape() { ShapeInfo shapeInfo; std::static_pointer_cast(_avatar)->computeShapeInfo(shapeInfo); + glm::vec3 halfExtents = shapeInfo.getHalfExtents(); + halfExtents.y = 0.0f; + _diameter = 2.0f * glm::length(halfExtents); return getShapeManager()->getShape(shapeInfo); } @@ -60,25 +74,31 @@ void AvatarMotionState::getWorldTransform(btTransform& worldTrans) const { worldTrans.setRotation(glmToBullet(getObjectRotation())); if (_body) { _body->setLinearVelocity(glmToBullet(getObjectLinearVelocity())); - _body->setAngularVelocity(glmToBullet(getObjectLinearVelocity())); + _body->setAngularVelocity(glmToBullet(getObjectAngularVelocity())); } } // virtual void AvatarMotionState::setWorldTransform(const btTransform& worldTrans) { - // HACK: The PhysicsEngine does not actually move OTHER avatars -- instead it slaves their local RigidBody to the transform - // as specified by a remote simulation. However, to give the remote simulation time to respond to our own objects we tie - // the other avatar's body to its true position with a simple spring. This is a HACK that will have to be improved later. const float SPRING_TIMESCALE = 0.5f; float tau = PHYSICS_ENGINE_FIXED_SUBSTEP / SPRING_TIMESCALE; btVector3 currentPosition = worldTrans.getOrigin(); - btVector3 targetPosition = glmToBullet(getObjectPosition()); - btTransform newTransform; - newTransform.setOrigin((1.0f - tau) * currentPosition + tau * targetPosition); - newTransform.setRotation(glmToBullet(getObjectRotation())); - _body->setWorldTransform(newTransform); - _body->setLinearVelocity(glmToBullet(getObjectLinearVelocity())); - _body->setAngularVelocity(glmToBullet(getObjectLinearVelocity())); + btVector3 offsetToTarget = glmToBullet(getObjectPosition()) - currentPosition; + float distance = offsetToTarget.length(); + if ((1.0f - tau) * distance > _diameter) { + // the avatar body is far from its target --> slam position + btTransform newTransform; + newTransform.setOrigin(currentPosition + offsetToTarget); + newTransform.setRotation(glmToBullet(getObjectRotation())); + _body->setWorldTransform(newTransform); + _body->setLinearVelocity(glmToBullet(getObjectLinearVelocity())); + _body->setAngularVelocity(glmToBullet(getObjectAngularVelocity())); + } else { + // the avatar body is near its target --> slam velocity + btVector3 velocity = glmToBullet(getObjectLinearVelocity()) + (1.0f / SPRING_TIMESCALE) * offsetToTarget; + _body->setLinearVelocity(velocity); + _body->setAngularVelocity(glmToBullet(getObjectAngularVelocity())); + } } // These pure virtual methods must be implemented for each MotionState type @@ -145,3 +165,8 @@ void AvatarMotionState::computeCollisionGroupAndMask(int32_t& group, int32_t& ma mask = Physics::getDefaultCollisionMask(group); } +// virtual +float AvatarMotionState::getMass() const { + return std::static_pointer_cast(_avatar)->computeMass(); +} + diff --git a/interface/src/avatar/AvatarMotionState.h b/interface/src/avatar/AvatarMotionState.h index 07e8102752..2738aba8ee 100644 --- a/interface/src/avatar/AvatarMotionState.h +++ b/interface/src/avatar/AvatarMotionState.h @@ -23,6 +23,9 @@ class AvatarMotionState : public ObjectMotionState { public: AvatarMotionState(AvatarSharedPointer avatar, const btCollisionShape* shape); + virtual void handleEasyChanges(uint32_t& flags) override; + virtual bool handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) override; + virtual PhysicsMotionType getMotionType() const override { return _motionType; } virtual uint32_t getIncomingDirtyFlags() override; @@ -64,6 +67,8 @@ public: virtual void computeCollisionGroupAndMask(int32_t& group, int32_t& mask) const override; + virtual float getMass() const override; + friend class AvatarManager; friend class Avatar; @@ -76,6 +81,7 @@ protected: virtual const btCollisionShape* computeNewShape() override; AvatarSharedPointer _avatar; + float _diameter { 0.0f }; uint32_t _dirtyFlags; }; diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 9682c81697..615f11e897 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -861,7 +861,6 @@ bool Avatar::shouldRenderHead(const RenderArgs* renderArgs) const { return true; } -// virtual void Avatar::simulateAttachments(float deltaTime) { assert(_attachmentModels.size() == _attachmentModelsTexturesLoaded.size()); PerformanceTimer perfTimer("attachments"); @@ -1544,12 +1543,13 @@ void Avatar::updateDisplayNameAlpha(bool showDisplayName) { } } -// virtual void Avatar::computeShapeInfo(ShapeInfo& shapeInfo) { float uniformScale = getModelScale(); - shapeInfo.setCapsuleY(uniformScale * _skeletonModel->getBoundingCapsuleRadius(), - 0.5f * uniformScale * _skeletonModel->getBoundingCapsuleHeight()); - shapeInfo.setOffset(uniformScale * _skeletonModel->getBoundingCapsuleOffset()); + float radius = glm::max(MIN_AVATAR_RADIUS, uniformScale * _skeletonModel->getBoundingCapsuleRadius()); + float height = glm::max(MIN_AVATAR_HEIGHT, uniformScale * _skeletonModel->getBoundingCapsuleHeight()); + shapeInfo.setCapsuleY(radius, 0.5f * height); + glm::vec3 offset = uniformScale * _skeletonModel->getBoundingCapsuleOffset(); + shapeInfo.setOffset(offset); } void Avatar::getCapsule(glm::vec3& start, glm::vec3& end, float& radius) { @@ -1572,9 +1572,8 @@ float Avatar::computeMass() { return _density * TWO_PI * radius * radius * (glm::length(end - start) + 2.0f * radius / 3.0f); } -// virtual void Avatar::rebuildCollisionShape() { - addPhysicsFlags(Simulation::DIRTY_SHAPE); + addPhysicsFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS); } void Avatar::setPhysicsCallback(AvatarPhysicsCallback cb) { diff --git a/libraries/physics/src/ObjectMotionState.h b/libraries/physics/src/ObjectMotionState.h index 0ca28d6b09..4a3b200559 100644 --- a/libraries/physics/src/ObjectMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -110,8 +110,8 @@ public: MotionStateType getType() const { return _type; } virtual PhysicsMotionType getMotionType() const { return _motionType; } - void setMass(float mass); - float getMass() const; + virtual void setMass(float mass); + virtual float getMass() const; void setBodyLinearVelocity(const glm::vec3& velocity) const; void setBodyAngularVelocity(const glm::vec3& velocity) const; diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index ee87cab8e8..66a4edb486 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -105,9 +105,9 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) { } case MOTION_TYPE_DYNAMIC: { mass = motionState->getMass(); - if (mass != mass || mass < 1.0f) { - qCDebug(physics) << "mass is too low, setting to 1.0 Kg --" << mass; - mass = 1.0f; + const float MIN_DYNAMIC_MASS = 0.01f; + if (mass != mass || mass < MIN_DYNAMIC_MASS) { + mass = MIN_DYNAMIC_MASS; } btCollisionShape* shape = const_cast(motionState->getShape()); assert(shape); diff --git a/libraries/shared/src/AvatarConstants.h b/libraries/shared/src/AvatarConstants.h index e90e25d5b0..58cbff6669 100644 --- a/libraries/shared/src/AvatarConstants.h +++ b/libraries/shared/src/AvatarConstants.h @@ -69,6 +69,7 @@ static const float MIN_AVATAR_SCALE = 0.005f; static const float MAX_AVATAR_HEIGHT = 1000.0f * DEFAULT_AVATAR_HEIGHT; // meters static const float MIN_AVATAR_HEIGHT = 0.005f * DEFAULT_AVATAR_HEIGHT; // meters +static const float MIN_AVATAR_RADIUS = 0.5f * MIN_AVATAR_HEIGHT; static const float AVATAR_WALK_SPEED_SCALAR = 1.0f; static const float AVATAR_SPRINT_SPEED_SCALAR = 3.0f; From 3ef41664dc4e5d18d5e7288f50cd3dad9ac60d7f Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 19 Jun 2018 10:32:01 -0700 Subject: [PATCH 14/14] Implement MS16052: Use quality '50' when saving PNG Snapshots --- interface/src/ui/Snapshot.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 8c759ea998..efcc85b23e 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -365,15 +365,23 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot, // DON'T append ".jpg" to the filename. QT will save the image in the format associated with the // filename's suffix. // If you want lossless Snapshots, supply a `.png` filename. Otherwise, use `.jpeg` or `.jpg`. + // For PNGs, we use a "quality" of "50". The output image quality is the same as "100" + // is the same as "0" -- the difference lies in the amount of compression applied to the PNG, + // which slightly affects the time it takes to save the image. // Otherwise, ".jpg" is appended to the user's requested filename so that the image is saved in JPG format. // If the user hasn't supplied a specific filename for the snapshot: - // Save the snapshot in JPG format according to FILENAME_PATH_FORMAT + // Save the snapshot in JPG format at "100" quality according to FILENAME_PATH_FORMAT + int imageQuality = 100; QString filename; if (!userSelectedFilename.isNull()) { QFileInfo snapshotFileInfo(userSelectedFilename); QString userSelectedFilenameSuffix = snapshotFileInfo.suffix(); + userSelectedFilenameSuffix = userSelectedFilenameSuffix.toLower(); if (SUPPORTED_IMAGE_FORMATS.contains(userSelectedFilenameSuffix)) { filename = userSelectedFilename; + if (userSelectedFilenameSuffix == "png") { + imageQuality = 50; + } } else { filename = userSelectedFilename + ".jpg"; } @@ -381,8 +389,6 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot, filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT)); } - const int IMAGE_QUALITY = 100; - if (!isTemporary) { // If user has requested specific path then use it, else use the application value QString snapshotFullPath; @@ -432,7 +438,7 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot, imageFile = new QFile(snapshotFullPath); } - shot.save(imageFile, 0, IMAGE_QUALITY); + shot.save(imageFile, 0, imageQuality); imageFile->close(); return imageFile; @@ -447,7 +453,7 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot, } imageTempFile->setAutoRemove(isTemporary); - shot.save(imageTempFile, 0, IMAGE_QUALITY); + shot.save(imageTempFile, 0, imageQuality); imageTempFile->close(); return imageTempFile;