Skip to content

Commit

Permalink
fix: built-in renderpipeline normal sampling was normalizing at the w…
Browse files Browse the repository at this point in the history
…rong point, resulting in incorrect scaled normals

fix: wrong default sampler on export for linear sampling
  • Loading branch information
hybridherbst committed Apr 24, 2021
1 parent 8be8565 commit a6b45eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ private SamplerId ExportSampler(Texture texture)
sampler.MagFilter = MagFilterMode.Nearest;
break;
case FilterMode.Bilinear:
sampler.MinFilter = MinFilterMode.LinearMipmapNearest;
sampler.MinFilter = MinFilterMode.NearestMipmapLinear;
sampler.MagFilter = MagFilterMode.Linear;
break;
case FilterMode.Trilinear:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,12 @@ half3 Emission(float2 uv)
}

// see this link regarding unpacking instructions:
// https://github.com/KhronosGroup/glTF/blob/2.0/specification/2.0/schema/material.normalTextureInfo.schema.json#L13
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/material.normalTextureInfo.schema.json#L13
half3 UnpackScaleNormalGLTF(half4 packednormal, half bumpScale)
{
float3 normal = normalize(packednormal.xyz);
normal = (normal*2.0 - 1.0);
float3 normal = packednormal.xyz * 2.0 - 1.0;
normal.xy *= bumpScale;
return LinearToGammaSpace(normalize(normal));
return normalize(normal);
}

#ifdef _NORMALMAP
Expand Down

0 comments on commit a6b45eb

Please sign in to comment.