Differential D15852 Diff 55231 source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
| Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | void node_bsdf_principled(vec4 base_color, | ||||
| float btdf = (do_multiscatter != 0.0) ? 1.0 : btdf_lut(NV, roughness, ior).x; | float btdf = (do_multiscatter != 0.0) ? 1.0 : btdf_lut(NV, roughness, ior).x; | ||||
| refraction_data.color = base_color.rgb * btdf; | refraction_data.color = base_color.rgb * btdf; | ||||
| refraction_data.N = N; | refraction_data.N = N; | ||||
| refraction_data.roughness = do_multiscatter != 0.0 ? roughness : | refraction_data.roughness = do_multiscatter != 0.0 ? roughness : | ||||
| max(roughness, transmission_roughness); | max(roughness, transmission_roughness); | ||||
| refraction_data.ior = ior; | refraction_data.ior = ior; | ||||
| /* Ref. T98190: Defines are optimizations for old compilers. | |||||
| * Might become unecessary with EEVEE-Next. */ | |||||
| if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat != 0.0) { | if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat != 0.0) { | ||||
| #ifdef PRINCIPLED_CLEARCOAT | |||||
| /* Metallic & Clearcoat case. */ | /* Metallic & Clearcoat case. */ | ||||
| result = closure_eval(reflection_data, clearcoat_data); | result = closure_eval(reflection_data, clearcoat_data); | ||||
| #endif | |||||
| } | } | ||||
| else if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) { | else if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) { | ||||
| #ifdef PRINCIPLED_METALLIC | |||||
| /* Metallic case. */ | /* Metallic case. */ | ||||
| result = closure_eval(reflection_data); | result = closure_eval(reflection_data); | ||||
| #endif | |||||
| } | } | ||||
| else if (do_diffuse != 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) { | else if (do_diffuse != 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) { | ||||
| #ifdef PRINCIPLED_DIELECTRIC | |||||
| /* Dielectric case. */ | /* Dielectric case. */ | ||||
| result = closure_eval(diffuse_data, reflection_data); | result = closure_eval(diffuse_data, reflection_data); | ||||
| #endif | |||||
| } | } | ||||
| else if (do_diffuse == 0.0 && do_refraction != 0.0 && do_clearcoat == 0.0) { | else if (do_diffuse == 0.0 && do_refraction != 0.0 && do_clearcoat == 0.0) { | ||||
| #ifdef PRINCIPLED_GLASS | |||||
| /* Glass case. */ | /* Glass case. */ | ||||
| result = closure_eval(reflection_data, refraction_data); | result = closure_eval(reflection_data, refraction_data); | ||||
| #endif | |||||
| } | } | ||||
| else { | else { | ||||
| #ifdef PRINCIPLED_ANY | |||||
| /* Un-optimized case. */ | /* Un-optimized case. */ | ||||
| result = closure_eval(diffuse_data, reflection_data, clearcoat_data, refraction_data); | result = closure_eval(diffuse_data, reflection_data, clearcoat_data, refraction_data); | ||||
| #endif | |||||
| } | } | ||||
| Closure emission_cl = closure_eval(emission_data); | Closure emission_cl = closure_eval(emission_data); | ||||
| Closure transparency_cl = closure_eval(transparency_data); | Closure transparency_cl = closure_eval(transparency_data); | ||||
| result = closure_add(result, emission_cl); | result = closure_add(result, emission_cl); | ||||
| result = closure_add(result, transparency_cl); | result = closure_add(result, transparency_cl); | ||||
| } | } | ||||