aboutsummaryrefslogtreecommitdiff
path: root/scene/resources/material.cpp
diff options
context:
space:
mode:
authorChaosus2018-02-15 17:21:09 +0300
committerChaosus2018-02-15 17:21:09 +0300
commitb5e4f637fc6d2ef9d1dec28bfdb9df9e3515e759 (patch)
tree6fe6ecf917d74e199e9a5e77e40c0dcafc97a54a /scene/resources/material.cpp
parent133942cfeb0279ca03ab9943459c5140ab1f1725 (diff)
downloadgodot-b5e4f637fc6d2ef9d1dec28bfdb9df9e3515e759.tar.gz
godot-b5e4f637fc6d2ef9d1dec28bfdb9df9e3515e759.tar.zst
godot-b5e4f637fc6d2ef9d1dec28bfdb9df9e3515e759.zip
Added refraction possibility for triplanar uv mode
Diffstat (limited to 'scene/resources/material.cpp')
-rw-r--r--scene/resources/material.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 8a1978cf8..ceac65ffa 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -737,15 +737,18 @@ void SpatialMaterial::_update_shader() {
}
}
- if (features[FEATURE_REFRACTION] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //refraction not supported with triplanar
+ 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";
} else {
code += "\tvec3 ref_normal = NORMAL;\n";
}
-
- code += "\tvec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(texture(texture_refraction,base_uv),refraction_texture_channel) * refraction;\n";
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(triplanar_texture(texture_refraction,uv1_power_normal,uv1_triplanar_pos),refraction_texture_channel) * refraction;\n";
+ } else {
+ code += "\tvec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(texture(texture_refraction,base_uv),refraction_texture_channel) * refraction;\n";
+ }
code += "\tfloat ref_amount = 1.0 - albedo.a * albedo_tex.a;\n";
code += "\tEMISSION += textureLod(SCREEN_TEXTURE,ref_ofs,ROUGHNESS * 8.0).rgb * ref_amount;\n";
code += "\tALBEDO *= 1.0 - ref_amount;\n";