From be4839d46c2ae373ab4a17493f22cf2ad543abd1 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 18 Jul 2016 12:26:04 -0700 Subject: [PATCH 1/2] a better depth filter --- .../surfaceGeometry_downsampleDepthNormal.slf | 37 +++++++++++++++---- .../src/surfaceGeometry_makeCurvature.slf | 2 +- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf b/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf index 049a357776..6bd9850d1a 100644 --- a/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf +++ b/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf @@ -45,23 +45,46 @@ out vec4 outLinearDepth; out vec4 outNormal; void main(void) { - float Zeye = texture(linearDepthMap, varTexCoord0).x; +#if __VERSION__ == 450 + // Gather 2 by 2 quads from texture + vec4 Zeyes = textureGather(linearDepthMap, varTexCoord0, 0); + vec4 rawNormalsX = textureGather(normalMap, varTexCoord0, 0); + vec4 rawNormalsY = textureGather(normalMap, varTexCoord0, 1); + vec4 rawNormalsZ = textureGather(normalMap, varTexCoord0, 2); + + float Zeye = min(min(Zeyes.x, Zeyes.y), min(Zeyes.z, Zeyes.w)); + + vec3 normal = vec3(0.0); + normal += unpackNormal(vec3(rawNormalsX[0], rawNormalsY[0], rawNormalsZ[0])); + normal += unpackNormal(vec3(rawNormalsX[1], rawNormalsY[1], rawNormalsZ[1])); + normal += unpackNormal(vec3(rawNormalsX[2], rawNormalsY[2], rawNormalsZ[2])); + normal += unpackNormal(vec3(rawNormalsX[3], rawNormalsY[3], rawNormalsZ[3])); +#else ivec2 texpos = ivec2(gl_FragCoord.xy) * 2; - + + vec4 Zeyes; + Zeyes[0] = texelFetch(linearDepthMap, texpos, 0).x; + Zeyes[1] = texelFetch(linearDepthMap, texpos + ivec2(0, 1), 0).x; + Zeyes[2] = texelFetch(linearDepthMap, texpos + ivec2(1, 0), 0).x; + Zeyes[3] = texelFetch(linearDepthMap, texpos + ivec2(1, 1), 0).x; + vec3 rawNormals[4]; rawNormals[0] = texelFetch(normalMap, texpos, 0).xyz; rawNormals[1] = texelFetch(normalMap, texpos + ivec2(0, 1), 0).xyz; rawNormals[2] = texelFetch(normalMap, texpos + ivec2(1, 0), 0).xyz; rawNormals[3] = texelFetch(normalMap, texpos + ivec2(1, 1), 0).xyz; + float Zeye = min(min(Zeyes.x, Zeyes.y), min(Zeyes.z, Zeyes.w)); + vec3 normal = vec3(0.0); - normal += unpackNormal( rawNormals[0] ); - normal += unpackNormal( rawNormals[1] ); - normal += unpackNormal( rawNormals[2] ); - normal += unpackNormal( rawNormals[3] ); - + normal += unpackNormal(rawNormals[0]); + normal += unpackNormal(rawNormals[1]); + normal += unpackNormal(rawNormals[2]); + normal += unpackNormal(rawNormals[3]); +#endif + normal = normalize(normal); outLinearDepth = vec4(Zeye, 0.0, 0.0, 0.0); diff --git a/libraries/render-utils/src/surfaceGeometry_makeCurvature.slf b/libraries/render-utils/src/surfaceGeometry_makeCurvature.slf index 09836f2ab0..bf8ca6abf3 100644 --- a/libraries/render-utils/src/surfaceGeometry_makeCurvature.slf +++ b/libraries/render-utils/src/surfaceGeometry_makeCurvature.slf @@ -112,7 +112,7 @@ void main(void) { // Fetch the z under the pixel (stereo or not) float Zeye = getZEye(framePixelPos); if (Zeye <= -getPosLinearDepthFar()) { - outFragColor = vec4(0.0); + outFragColor = vec4(1.0, 0.0, 0.0, 0.0); return; } From 80587ca8a355c78563f7cade7e84d055f97a9766 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 18 Jul 2016 12:52:21 -0700 Subject: [PATCH 2/2] using the textureGather lookup --- libraries/render-utils/src/SurfaceGeometryPass.h | 2 +- .../src/surfaceGeometry_downsampleDepthNormal.slf | 5 ++--- .../utilities/render/deferredLighting.qml | 14 +------------- .../utilities/render/surfaceGeometryPass.qml | 2 +- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/libraries/render-utils/src/SurfaceGeometryPass.h b/libraries/render-utils/src/SurfaceGeometryPass.h index 5b9b64a11c..14c8316d9e 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.h +++ b/libraries/render-utils/src/SurfaceGeometryPass.h @@ -146,7 +146,7 @@ class SurfaceGeometryPassConfig : public render::Job::Config { public: SurfaceGeometryPassConfig() : render::Job::Config(true) {} - float depthThreshold{ 0.02f }; // meters + float depthThreshold{ 0.005f }; // meters float basisScale{ 1.0f }; float curvatureScale{ 10.0f }; int resolutionLevel{ 0 }; diff --git a/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf b/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf index 6bd9850d1a..af371d53a8 100644 --- a/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf +++ b/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf @@ -45,7 +45,6 @@ out vec4 outLinearDepth; out vec4 outNormal; void main(void) { -#if __VERSION__ == 450 // Gather 2 by 2 quads from texture vec4 Zeyes = textureGather(linearDepthMap, varTexCoord0, 0); @@ -60,7 +59,7 @@ void main(void) { normal += unpackNormal(vec3(rawNormalsX[1], rawNormalsY[1], rawNormalsZ[1])); normal += unpackNormal(vec3(rawNormalsX[2], rawNormalsY[2], rawNormalsZ[2])); normal += unpackNormal(vec3(rawNormalsX[3], rawNormalsY[3], rawNormalsZ[3])); -#else + /* ivec2 texpos = ivec2(gl_FragCoord.xy) * 2; vec4 Zeyes; @@ -83,7 +82,7 @@ void main(void) { normal += unpackNormal(rawNormals[1]); normal += unpackNormal(rawNormals[2]); normal += unpackNormal(rawNormals[3]); -#endif +*/ normal = normalize(normal); diff --git a/scripts/developer/utilities/render/deferredLighting.qml b/scripts/developer/utilities/render/deferredLighting.qml index 12f21ed366..fedb99fc74 100644 --- a/scripts/developer/utilities/render/deferredLighting.qml +++ b/scripts/developer/utilities/render/deferredLighting.qml @@ -58,19 +58,7 @@ Column { "Ambient:LightingModel:enableAmbientLight", "Directional:LightingModel:enableDirectionalLight", "Point:LightingModel:enablePointLight", - "Spot:LightingModel:enableSpotLight" - ] - CheckBox { - text: modelData.split(":")[0] - checked: Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] - onCheckedChanged: { Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] = checked } - } - } - } - Column { - spacing: 10 - Repeater { - model: [ + "Spot:LightingModel:enableSpotLight", "Light Contour:LightingModel:showLightContour" ] CheckBox { diff --git a/scripts/developer/utilities/render/surfaceGeometryPass.qml b/scripts/developer/utilities/render/surfaceGeometryPass.qml index 0021ecc96c..23a846ee79 100644 --- a/scripts/developer/utilities/render/surfaceGeometryPass.qml +++ b/scripts/developer/utilities/render/surfaceGeometryPass.qml @@ -20,7 +20,7 @@ Column { Column{ Repeater { model: [ - "Depth Threshold:depthThreshold:0.1:false", + "Depth Threshold:depthThreshold:0.05:false", "Basis Scale:basisScale:2.0:false", "Curvature Scale:curvatureScale:100.0:false", "Downscale:resolutionLevel:4:true"