mirror of
https://github.com/godotengine/godot-blender-exporter.git
synced 2026-01-04 14:09:56 +03:00
Merge pull request #165 from Jason0214/support_transmission
Support transmission
This commit is contained in:
@@ -135,10 +135,16 @@ def visit_bsdf_node(shader, node):
|
||||
new_var = shader.define_variable(
|
||||
var_type, 'out_' + attr_name
|
||||
)
|
||||
|
||||
output.set_attribute(attr_name, new_var)
|
||||
out_arguments.append(new_var)
|
||||
|
||||
if attr_name == "transmission" and "Transmission" in node.inputs:
|
||||
# due to different implementation of transmission between
|
||||
# godot and blender, only export it when it is set.
|
||||
socket = node.inputs["Transmission"]
|
||||
if not socket.is_linked and socket.default_value == 0.0:
|
||||
continue
|
||||
output.set_attribute(attr_name, new_var)
|
||||
|
||||
shader.add_function_call(function, in_arguments, out_arguments)
|
||||
|
||||
# normal and tangent don't go to bsdf functions
|
||||
|
||||
@@ -79,7 +79,6 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
transmission = clamp(transmission, 0.0, 1.0);
|
||||
|
||||
subsurface = subsurface * (1.0 - metallic);
|
||||
transmission = transmission * (1.0 - metallic);
|
||||
|
||||
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
|
||||
sss_strength_out = subsurface;
|
||||
@@ -89,7 +88,7 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
clearcoat_out = clearcoat * (1.0 - transmission);
|
||||
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
|
||||
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
|
||||
transmission_out = transmission;
|
||||
transmission_out = (1.0 - transmission) * (1.0 - metallic);
|
||||
ior = IOR;
|
||||
}
|
||||
""",
|
||||
|
||||
@@ -390,12 +390,11 @@ class FragmentShader(BaseShader):
|
||||
self.code_array.append(
|
||||
'{} = {};'.format(name.upper(), str(var))
|
||||
)
|
||||
# XXX: transmission for thick object is not supported in godot
|
||||
|
||||
transmission_var = bsdf_output.get_attribute('transmission')
|
||||
if transmission_var is not None:
|
||||
self.append_comment_line("transmission usually does not work..")
|
||||
self.append_code_line(
|
||||
'// TRANSMISSION = vec3(1.0, 1.0, 1.0) * {};',
|
||||
'TRANSMISSION = vec3(1.0, 1.0, 1.0) * {};',
|
||||
(transmission_var,)
|
||||
)
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class GodotExporter:
|
||||
|
||||
is_bone_attachment = False
|
||||
if ("ARMATURE" in self.config['object_types'] and
|
||||
obj.parent_bone != ''):
|
||||
obj.parent and obj.parent_bone != ''):
|
||||
is_bone_attachment = True
|
||||
parent_gd_node = converters.BONE_ATTACHMENT_EXPORTER(
|
||||
self.escn_file,
|
||||
|
||||
@@ -52,7 +52,7 @@ auto_exposure_scale = 0.4
|
||||
auto_exposure_min_luma = 0.05
|
||||
auto_exposure_max_luma = 8.0
|
||||
auto_exposure_speed = 0.5
|
||||
ss_reflections_enabled = false
|
||||
ss_reflections_enabled = false
|
||||
ss_reflections_max_steps = 64
|
||||
ss_reflections_fade_in = 0.15
|
||||
ss_reflections_fade_out = 2.0
|
||||
|
||||
@@ -20,7 +20,6 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
transmission = clamp(transmission, 0.0, 1.0);
|
||||
|
||||
subsurface = subsurface * (1.0 - metallic);
|
||||
transmission = transmission * (1.0 - metallic);
|
||||
|
||||
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
|
||||
sss_strength_out = subsurface;
|
||||
@@ -30,7 +29,7 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
clearcoat_out = clearcoat * (1.0 - transmission);
|
||||
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
|
||||
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
|
||||
transmission_out = transmission;
|
||||
transmission_out = (1.0 - transmission) * (1.0 - metallic);
|
||||
ior = IOR;
|
||||
}
|
||||
|
||||
@@ -92,8 +91,6 @@ void fragment() {
|
||||
ROUGHNESS = var16_out_roughness;
|
||||
CLEARCOAT = var17_out_clearcoat;
|
||||
CLEARCOAT_GLOSS = var18_out_clearcoat_gloss;
|
||||
// transmission usually does not work..
|
||||
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * var20_out_transmission;
|
||||
// uncomment it only when you set diffuse mode to oren nayar
|
||||
// ROUGHNESS = oren_nayar_rougness
|
||||
ANISOTROPY = var19_out_anisotropy;
|
||||
@@ -147,7 +144,6 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
transmission = clamp(transmission, 0.0, 1.0);
|
||||
|
||||
subsurface = subsurface * (1.0 - metallic);
|
||||
transmission = transmission * (1.0 - metallic);
|
||||
|
||||
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
|
||||
sss_strength_out = subsurface;
|
||||
@@ -157,7 +153,7 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
clearcoat_out = clearcoat * (1.0 - transmission);
|
||||
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
|
||||
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
|
||||
transmission_out = transmission;
|
||||
transmission_out = (1.0 - transmission) * (1.0 - metallic);
|
||||
ior = IOR;
|
||||
}
|
||||
|
||||
@@ -229,8 +225,6 @@ void fragment() {
|
||||
ROUGHNESS = var17_out_roughness;
|
||||
CLEARCOAT = var18_out_clearcoat;
|
||||
CLEARCOAT_GLOSS = var19_out_clearcoat_gloss;
|
||||
// transmission usually does not work..
|
||||
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * var21_out_transmission;
|
||||
// uncomment it only when you set diffuse mode to oren nayar
|
||||
// ROUGHNESS = oren_nayar_rougness
|
||||
ANISOTROPY = var20_out_anisotropy;
|
||||
|
||||
@@ -364,8 +364,7 @@ void fragment() {
|
||||
ALBEDO = var4_out_albedo;
|
||||
SPECULAR = var6_out_specular;
|
||||
ROUGHNESS = var7_out_roughness;
|
||||
// transmission usually does not work..
|
||||
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * var8_out_transmission;
|
||||
TRANSMISSION = vec3(1.0, 1.0, 1.0) * var8_out_transmission;
|
||||
// uncomment it only when you set diffuse mode to oren nayar
|
||||
// ROUGHNESS = oren_nayar_rougness
|
||||
refraction_fresnel(VERTEX, NORMAL, var9_out_ior, var5_out_alpha);
|
||||
@@ -472,7 +471,6 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
transmission = clamp(transmission, 0.0, 1.0);
|
||||
|
||||
subsurface = subsurface * (1.0 - metallic);
|
||||
transmission = transmission * (1.0 - metallic);
|
||||
|
||||
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
|
||||
sss_strength_out = subsurface;
|
||||
@@ -482,7 +480,7 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
clearcoat_out = clearcoat * (1.0 - transmission);
|
||||
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
|
||||
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
|
||||
transmission_out = transmission;
|
||||
transmission_out = (1.0 - transmission) * (1.0 - metallic);
|
||||
ior = IOR;
|
||||
}
|
||||
|
||||
@@ -550,8 +548,6 @@ void fragment() {
|
||||
ROUGHNESS = var17_out_roughness;
|
||||
CLEARCOAT = var18_out_clearcoat;
|
||||
CLEARCOAT_GLOSS = var19_out_clearcoat_gloss;
|
||||
// transmission usually does not work..
|
||||
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * var21_out_transmission;
|
||||
// uncomment it only when you set diffuse mode to oren nayar
|
||||
// ROUGHNESS = oren_nayar_rougness
|
||||
}
|
||||
@@ -1124,7 +1120,6 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
transmission = clamp(transmission, 0.0, 1.0);
|
||||
|
||||
subsurface = subsurface * (1.0 - metallic);
|
||||
transmission = transmission * (1.0 - metallic);
|
||||
|
||||
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
|
||||
sss_strength_out = subsurface;
|
||||
@@ -1134,7 +1129,7 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
|
||||
clearcoat_out = clearcoat * (1.0 - transmission);
|
||||
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
|
||||
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
|
||||
transmission_out = transmission;
|
||||
transmission_out = (1.0 - transmission) * (1.0 - metallic);
|
||||
ior = IOR;
|
||||
}
|
||||
|
||||
@@ -1212,8 +1207,6 @@ void fragment() {
|
||||
ROUGHNESS = var19_out_roughness;
|
||||
CLEARCOAT = var20_out_clearcoat;
|
||||
CLEARCOAT_GLOSS = var21_out_clearcoat_gloss;
|
||||
// transmission usually does not work..
|
||||
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * var23_out_transmission;
|
||||
// uncomment it only when you set diffuse mode to oren nayar
|
||||
// ROUGHNESS = oren_nayar_rougness
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user