Manually unpacked normal mapping to fix issue with refraction being offset rather than distorted.
(cherry picked from commit 31f2d946ad
)
This commit is contained in:
parent
fc67ff3d0a
commit
fac2e5dc67
1 changed files with 4 additions and 1 deletions
|
@ -861,7 +861,10 @@ void SpatialMaterial::_update_shader() {
|
|||
|
||||
if (features[FEATURE_REFRACTION]) {
|
||||
if (features[FEATURE_NORMAL_MAPPING]) {
|
||||
code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) );\n";
|
||||
code += "\tvec3 unpacked_normal = NORMALMAP;\n";
|
||||
code += "\tunpacked_normal.xy = unpacked_normal.xy * 2.0 - 1.0;\n";
|
||||
code += "\tunpacked_normal.z = sqrt(max(0.0, 1.0 - dot(unpacked_normal.xy, unpacked_normal.xy)));\n";
|
||||
code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * unpacked_normal.x + BINORMAL * unpacked_normal.y + NORMAL * unpacked_normal.z,NORMALMAP_DEPTH) );\n";
|
||||
} else {
|
||||
code += "\tvec3 ref_normal = NORMAL;\n";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue