Merge pull request #8267 from samcake/skin

Better depth filter
This commit is contained in:
samcake 2016-07-18 12:56:08 -07:00 committed by GitHub
commit 3d57a3a86a
5 changed files with 33 additions and 23 deletions

View file

@ -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 };

View file

@ -45,23 +45,45 @@ out vec4 outLinearDepth;
out vec4 outNormal;
void main(void) {
float Zeye = texture(linearDepthMap, varTexCoord0).x;
// 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]));
/*
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]);
*/
normal = normalize(normal);
outLinearDepth = vec4(Zeye, 0.0, 0.0, 0.0);

View file

@ -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;
}

View file

@ -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 {

View file

@ -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"