mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Merge pull request #48478 from brennengreen/normal-mapping-unpacked-fix
Fix refraction offset by manually unpacking normal mappings
This commit is contained in:
commit
99626d5b57
@ -1032,7 +1032,10 @@ void BaseMaterial3D::_update_shader() {
|
||||
|
||||
if (features[FEATURE_REFRACTION]) {
|
||||
if (features[FEATURE_NORMAL_MAPPING]) {
|
||||
code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMAL_MAP.x + BINORMAL * NORMAL_MAP.y + NORMAL * NORMAL_MAP.z,NORMAL_MAP_DEPTH) );\n";
|
||||
code += "\tvec3 unpacked_normal = NORMAL_MAP;\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,NORMAL_MAP_DEPTH) );\n";
|
||||
} else {
|
||||
code += "\tvec3 ref_normal = NORMAL;\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user