Skip to content

Commit

Permalink
Updated depth shader gl_FragDepth to use range from 1.0 to -1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
zirman committed Nov 18, 2021
1 parent b274675 commit ac935dd
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
Binary file modified app/src/main/assets/materials/depth.filamat
Binary file not shown.
Binary file modified app/src/main/assets/materials/flat.filamat
Binary file not shown.
5 changes: 2 additions & 3 deletions app/src/main/materials/depth.mat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ material {
shadingModel : unlit,
blending : opaque,
vertexDomain : device,
depthWrite : false,
depthCulling : false,
parameters : [
{
type : samplerExternal,
Expand All @@ -30,8 +30,7 @@ fragment {
vec2 packed_depth = texture(materialParams_depthTexture, getUV0()).xy;
float depth_mm = dot(packed_depth, vec2(255.f, 256.f * 255.f));
vec4 view = mulMat4x4Float3(getClipFromViewMatrix(), vec3(0.f, 0.f, -depth_mm / 1000.f));
float ndc_depth = view.z / view.w;
gl_FragDepth = 1.f - ((ndc_depth + 1.f) / 2.f);
gl_FragDepth = view.z / view.w;
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/materials/flat.mat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ material {
shadingModel : unlit,
blending : opaque,
depthWrite : false,
depthCulling : false,
parameters : [
{
type : samplerExternal,
Expand Down

0 comments on commit ac935dd

Please sign in to comment.