summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-09-03 10:29:56 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-09-03 10:30:37 -0300
commit281fb4e4fb2af81536b75328861aa93899cc9f45 (patch)
tree219f8df4cdec716442ee526177fecdba742f595b
parent0da386a9eae15c313bfe2f90c30bfaef8c0e23f1 (diff)
Added transmission shader parameter.
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp6
-rw-r--r--drivers/gles3/shaders/scene.glsl43
-rw-r--r--editor/project_settings_editor.cpp7
-rw-r--r--editor/project_settings_editor.h2
-rw-r--r--scene/resources/material.cpp44
-rw-r--r--scene/resources/material.h11
-rw-r--r--servers/visual/shader_types.cpp3
7 files changed, 94 insertions, 22 deletions
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index c308e9eddb..bdd54543d2 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -751,8 +751,9 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
actions[VS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
actions[VS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
- actions[VS::SHADER_SPATIAL].renames["SSS_SPREAD"] = "sss_spread";
+ //actions[VS::SHADER_SPATIAL].renames["SSS_SPREAD"] = "sss_spread";
actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
+ actions[VS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
actions[VS::SHADER_SPATIAL].renames["AO"] = "ao";
actions[VS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
//actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"]=ShaderLanguage::TYPE_VEC2;
@@ -782,6 +783,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
actions[VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
+ actions[VS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
@@ -792,7 +794,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_half_lambert"] = "#define DIFFUSE_HALF_LAMBERT\n";
+ actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index ef4925895c..7c60a8ee97 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -887,7 +887,7 @@ float GTR1(float NdotH, float a)
-void light_compute(vec3 N, vec3 L,vec3 V,vec3 B, vec3 T,vec3 light_color,vec3 diffuse_color, float specular_blob_intensity, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse, inout vec3 specular) {
+void light_compute(vec3 N, vec3 L,vec3 V,vec3 B, vec3 T,vec3 light_color,vec3 diffuse_color, vec3 transmission, float specular_blob_intensity, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse, inout vec3 specular) {
#if defined(USE_LIGHT_SHADER_CODE)
//light is written by the light shader
@@ -900,10 +900,16 @@ LIGHT_SHADER_CODE
float dotNL = max(dot(N,L), 0.0 );
-#if defined(DIFFUSE_HALF_LAMBERT)
+#if defined(DIFFUSE_OREN_NAYAR)
+ vec3 light_amount;
+#else
+ float light_amount;
+#endif
+
- float hl = dot(N,L) * 0.5 + 0.5;
- diffuse += hl * light_color * diffuse_color;
+#if defined(DIFFUSE_LAMBERT_WRAP)
+ //energy conserving lambert wrap shader
+ light_amount = max(0.0,(dot(N,L) + roughness) / ((1.0 + roughness) * (1.0 + roughness)));
#elif defined(DIFFUSE_OREN_NAYAR)
@@ -919,12 +925,12 @@ LIGHT_SHADER_CODE
vec3 A = 1.0 + sigma2 * (diffuse_color / (sigma2 + 0.13) + 0.5 / (sigma2 + 0.33));
float B = 0.45 * sigma2 / (sigma2 + 0.09);
- diffuse += diffuse_color * max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI;
+ light_amount = max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI;
}
#elif defined(DIFFUSE_TOON)
- diffuse += smoothstep(-roughness,max(roughness,0.01),dot(N,L)) * light_color * diffuse_color;
+ light_amount = smoothstep(-roughness,max(roughness,0.01),dot(N,L));
#elif defined(DIFFUSE_BURLEY)
@@ -939,11 +945,17 @@ LIGHT_SHADER_CODE
float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NdotL, 5.0);
float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NdotV, 5.0);
- diffuse+= light_color * diffuse_color * lightScatter * viewScatter * energyFactor;
+ light_amount = lightScatter * viewScatter * energyFactor;
}
#else
//lambert
- diffuse += dotNL * light_color * diffuse_color;
+ light_amount = dotNL;
+#endif
+
+#if defined(TRANSMISSION_USED)
+ diffuse += light_color * diffuse_color * mix(vec3(light_amount),vec3(1.0),transmission);
+#else
+ diffuse += light_color * diffuse_color * light_amount;
#endif
@@ -1116,7 +1128,7 @@ vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 po
}
#endif
-void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity,inout vec3 diffuse_light, inout vec3 specular_light) {
+void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, vec3 transmission, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity,inout vec3 diffuse_light, inout vec3 specular_light) {
vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex;
float light_length = length( light_rel_vec );
@@ -1170,11 +1182,11 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino
light_attenuation*=mix(omni_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow);
}
- light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,omni_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+ light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,transmission,omni_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
}
-void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light) {
+void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, vec3 transmission,float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light) {
vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz-vertex;
float light_length = length( light_rel_vec );
@@ -1204,7 +1216,7 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
light_attenuation*=mix(spot_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow);
}
- light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,spot_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+ light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,transmission,spot_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
}
@@ -1499,6 +1511,7 @@ void main() {
//lay out everything, whathever is unused is optimized away anyway
highp vec3 vertex = vertex_interp;
vec3 albedo = vec3(0.8,0.8,0.8);
+ vec3 transmission = vec3(0.0);
float metallic = 0.0;
float specular = 0.5;
vec3 emission = vec3(0.0,0.0,0.0);
@@ -1822,7 +1835,7 @@ FRAGMENT_SHADER_CODE
specular_light*=mix(vec3(1.0),light_attenuation,specular_light_interp.a);
#else
- light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,light_params.z*specular_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
+ light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,transmission,light_params.z*specular_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
#endif
@@ -1860,11 +1873,11 @@ FRAGMENT_SHADER_CODE
#else
for(int i=0;i<omni_light_count;i++) {
- light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
+ light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,transmission,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
}
for(int i=0;i<spot_light_count;i++) {
- light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
+ light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,transmission,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light);
}
#endif //USE_VERTEX_LIGHTING
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 2cd0221ab6..9fd31f818e 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -1321,6 +1321,11 @@ void ProjectSettingsEditor::set_plugins_page() {
tab_container->set_current_tab(plugin_settings->get_index());
}
+TabContainer *ProjectSettingsEditor::get_tabs() {
+
+ return tab_container;
+}
+
void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected);
@@ -1361,6 +1366,8 @@ void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar);
ClassDB::bind_method(D_METHOD("_copy_to_platform_about_to_show"), &ProjectSettingsEditor::_copy_to_platform_about_to_show);
+
+ ClassDB::bind_method(D_METHOD("get_tabs"), &ProjectSettingsEditor::get_tabs);
}
ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index ceec089953..e58ba9b1c0 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -159,6 +159,8 @@ public:
void popup_project_settings();
void set_plugins_page();
+ TabContainer *get_tabs();
+
void queue_save();
ProjectSettingsEditor(EditorData *p_data);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index f3d790eef5..3d6a10ffc7 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -239,6 +239,7 @@ void SpatialMaterial::init_shaders() {
shader_names->anisotropy = "anisotropy_ratio";
shader_names->depth_scale = "depth_scale";
shader_names->subsurface_scattering_strength = "subsurface_scattering_strength";
+ shader_names->transmission = "transmission";
shader_names->refraction = "refraction";
shader_names->point_size = "point_size";
shader_names->uv1_scale = "uv1_scale";
@@ -276,6 +277,7 @@ void SpatialMaterial::init_shaders() {
shader_names->texture_names[TEXTURE_AMBIENT_OCCLUSION] = "texture_ambient_occlusion";
shader_names->texture_names[TEXTURE_DEPTH] = "texture_depth";
shader_names->texture_names[TEXTURE_SUBSURFACE_SCATTERING] = "texture_subsurface_scattering";
+ shader_names->texture_names[TEXTURE_TRANSMISSION] = "texture_transmission";
shader_names->texture_names[TEXTURE_REFRACTION] = "texture_refraction";
shader_names->texture_names[TEXTURE_DETAIL_MASK] = "texture_detail_mask";
shader_names->texture_names[TEXTURE_DETAIL_ALBEDO] = "texture_detail_albedo";
@@ -352,7 +354,7 @@ void SpatialMaterial::_update_shader() {
}
switch (diffuse_mode) {
case DIFFUSE_LAMBERT: code += ",diffuse_lambert"; break;
- case DIFFUSE_HALF_LAMBERT: code += ",diffuse_half_lambert"; break;
+ case DIFFUSE_LAMBERT_WRAP: code += ",diffuse_lambert_wrap"; break;
case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break;
case DIFFUSE_BURLEY: code += ",diffuse_burley"; break;
case DIFFUSE_TOON: code += ",diffuse_toon"; break;
@@ -451,6 +453,12 @@ void SpatialMaterial::_update_shader() {
code += "uniform sampler2D texture_subsurface_scattering : hint_white;\n";
}
+ if (features[FEATURE_TRANSMISSION]) {
+
+ code += "uniform vec4 transmission : hint_color;\n";
+ code += "uniform sampler2D texture_transmission : hint_black;\n";
+ }
+
if (features[FEATURE_DEPTH_MAPPING]) {
code += "uniform sampler2D texture_depth : hint_black;\n";
code += "uniform float depth_scale;\n";
@@ -766,6 +774,15 @@ void SpatialMaterial::_update_shader() {
code += "\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n";
}
+ if (features[FEATURE_TRANSMISSION]) {
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec3 transmission_tex = triplanar_texture(texture_transmission,uv1_power_normal,uv1_triplanar_pos).rgb;\n";
+ } else {
+ code += "\tvec3 transmission_tex = texture(texture_transmission,base_uv).rgb;\n";
+ }
+ code += "\tTRANSMISSION = (transmission.rgb+transmission_tex);\n";
+ }
+
if (features[FEATURE_DETAIL]) {
bool triplanar = (flags[FLAG_UV1_USE_TRIPLANAR] && detail_uv == DETAIL_UV_1) || (flags[FLAG_UV2_USE_TRIPLANAR] && detail_uv == DETAIL_UV_2);
@@ -1015,6 +1032,17 @@ float SpatialMaterial::get_subsurface_scattering_strength() const {
return subsurface_scattering_strength;
}
+void SpatialMaterial::set_transmission(const Color &p_transmission) {
+
+ transmission = p_transmission;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission);
+}
+
+Color SpatialMaterial::get_transmission() const {
+
+ return transmission;
+}
+
void SpatialMaterial::set_refraction(float p_refraction) {
refraction = p_refraction;
@@ -1180,6 +1208,7 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const {
_validate_feature("ao", FEATURE_AMBIENT_OCCLUSION, property);
_validate_feature("depth", FEATURE_DEPTH_MAPPING, property);
_validate_feature("subsurf_scatter", FEATURE_SUBSURACE_SCATTERING, property);
+ _validate_feature("transmission", FEATURE_TRANSMISSION, property);
_validate_feature("refraction", FEATURE_REFRACTION, property);
_validate_feature("detail", FEATURE_DETAIL, property);
@@ -1530,6 +1559,9 @@ void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &SpatialMaterial::set_subsurface_scattering_strength);
ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &SpatialMaterial::get_subsurface_scattering_strength);
+ ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &SpatialMaterial::set_transmission);
+ ClassDB::bind_method(D_METHOD("get_transmission"), &SpatialMaterial::get_transmission);
+
ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &SpatialMaterial::set_refraction);
ClassDB::bind_method(D_METHOD("get_refraction"), &SpatialMaterial::get_refraction);
@@ -1721,6 +1753,11 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "subsurf_scatter_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_subsurface_scattering_strength", "get_subsurface_scattering_strength");
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING);
+ ADD_GROUP("Transmission", "transmission_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transmission_enabled"), "set_feature", "get_feature", FEATURE_TRANSMISSION);
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "transmission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_transmission", "get_transmission");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_TRANSMISSION);
+
ADD_GROUP("Refraction", "refraction_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "refraction_enabled"), "set_feature", "get_feature", FEATURE_REFRACTION);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "refraction_scale", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_refraction", "get_refraction");
@@ -1758,6 +1795,7 @@ void SpatialMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(TEXTURE_AMBIENT_OCCLUSION);
BIND_ENUM_CONSTANT(TEXTURE_DEPTH);
BIND_ENUM_CONSTANT(TEXTURE_SUBSURFACE_SCATTERING);
+ BIND_ENUM_CONSTANT(TEXTURE_TRANSMISSION);
BIND_ENUM_CONSTANT(TEXTURE_REFRACTION);
BIND_ENUM_CONSTANT(TEXTURE_DETAIL_MASK);
BIND_ENUM_CONSTANT(TEXTURE_DETAIL_ALBEDO);
@@ -1776,6 +1814,7 @@ void SpatialMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(FEATURE_AMBIENT_OCCLUSION);
BIND_ENUM_CONSTANT(FEATURE_DEPTH_MAPPING);
BIND_ENUM_CONSTANT(FEATURE_SUBSURACE_SCATTERING);
+ BIND_ENUM_CONSTANT(FEATURE_TRANSMISSION);
BIND_ENUM_CONSTANT(FEATURE_REFRACTION);
BIND_ENUM_CONSTANT(FEATURE_DETAIL);
BIND_ENUM_CONSTANT(FEATURE_MAX);
@@ -1809,7 +1848,7 @@ void SpatialMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT);
- BIND_ENUM_CONSTANT(DIFFUSE_HALF_LAMBERT);
+ BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT_WRAP);
BIND_ENUM_CONSTANT(DIFFUSE_OREN_NAYAR);
BIND_ENUM_CONSTANT(DIFFUSE_BURLEY);
BIND_ENUM_CONSTANT(DIFFUSE_TOON);
@@ -1850,6 +1889,7 @@ SpatialMaterial::SpatialMaterial()
set_anisotropy(0);
set_depth_scale(0.05);
set_subsurface_scattering_strength(0);
+ set_transmission(Color(0, 0, 0));
set_refraction(0.05);
set_line_width(1);
set_point_size(1);
diff --git a/scene/resources/material.h b/scene/resources/material.h
index d560d7af55..4e77ab1ed6 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -112,6 +112,7 @@ public:
TEXTURE_AMBIENT_OCCLUSION,
TEXTURE_DEPTH,
TEXTURE_SUBSURFACE_SCATTERING,
+ TEXTURE_TRANSMISSION,
TEXTURE_REFRACTION,
TEXTURE_DETAIL_MASK,
TEXTURE_DETAIL_ALBEDO,
@@ -135,6 +136,7 @@ public:
FEATURE_AMBIENT_OCCLUSION,
FEATURE_DEPTH_MAPPING,
FEATURE_SUBSURACE_SCATTERING,
+ FEATURE_TRANSMISSION,
FEATURE_REFRACTION,
FEATURE_DETAIL,
FEATURE_MAX
@@ -179,7 +181,7 @@ public:
enum DiffuseMode {
DIFFUSE_LAMBERT,
- DIFFUSE_HALF_LAMBERT,
+ DIFFUSE_LAMBERT_WRAP,
DIFFUSE_OREN_NAYAR,
DIFFUSE_BURLEY,
DIFFUSE_TOON,
@@ -212,7 +214,7 @@ private:
union MaterialKey {
struct {
- uint64_t feature_mask : 11;
+ uint64_t feature_mask : 12;
uint64_t detail_uv : 1;
uint64_t blend_mode : 2;
uint64_t depth_draw_mode : 2;
@@ -286,6 +288,7 @@ private:
StringName anisotropy;
StringName depth_scale;
StringName subsurface_scattering_strength;
+ StringName transmission;
StringName refraction;
StringName point_size;
StringName uv1_scale;
@@ -337,6 +340,7 @@ private:
float anisotropy;
float depth_scale;
float subsurface_scattering_strength;
+ Color transmission;
float refraction;
float line_width;
float point_size;
@@ -443,6 +447,9 @@ public:
void set_subsurface_scattering_strength(float p_subsurface_scattering_strength);
float get_subsurface_scattering_strength() const;
+ void set_transmission(const Color &p_transmission);
+ Color get_transmission() const;
+
void set_refraction(float p_refraction);
float get_refraction() const;
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
index ef0d063f83..91c5d430f5 100644
--- a/servers/visual/shader_types.cpp
+++ b/servers/visual/shader_types.cpp
@@ -102,6 +102,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["TRANSMISSION"] = ShaderLanguage::TYPE_VEC3;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["AO"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
@@ -137,7 +138,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].modes.insert("unshaded");
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert");
- shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_half_lambert");
+ shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert_wrap");
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_oren_nayar");
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_burley");
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_toon");