Differential D10390 Diff 33913 source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl
| #ifndef VOLUMETRICS | #ifndef VOLUMETRICS | ||||
| CLOSURE_EVAL_FUNCTION_DECLARE_3(node_eevee_specular, Diffuse, Glossy, Glossy) | |||||
| void node_eevee_specular(vec4 diffuse, | void node_eevee_specular(vec4 diffuse, | ||||
| vec4 specular, | vec4 specular, | ||||
| float roughness, | float roughness, | ||||
| vec4 emissive, | vec4 emissive, | ||||
| float transp, | float transp, | ||||
| vec3 normal, | vec3 normal, | ||||
| float clearcoat, | float clearcoat, | ||||
| float clearcoat_roughness, | float clearcoat_roughness, | ||||
| vec3 clearcoat_normal, | vec3 clearcoat_normal, | ||||
| float occlusion, | float occlusion, | ||||
| float ssr_id, | float ssr_id, | ||||
| out Closure result) | out Closure result) | ||||
| { | { | ||||
| normal = normalize(normal); | CLOSURE_VARS_DECLARE_3(Diffuse, Glossy, Glossy); | ||||
| in_common.occlusion = occlusion; | |||||
| in_Diffuse_0.N = normal; /* Normalized during eval. */ | |||||
| in_Diffuse_0.albedo = diffuse.rgb; | |||||
| in_Glossy_1.N = normal; /* Normalized during eval. */ | |||||
| in_Glossy_1.roughness = roughness; | |||||
| vec3 out_diff, out_spec, ssr_spec; | in_Glossy_2.N = clearcoat_normal; /* Normalized during eval. */ | ||||
| eevee_closure_default_clearcoat(normal, | in_Glossy_2.roughness = clearcoat_roughness; | ||||
| diffuse.rgb, | |||||
| specular.rgb, | CLOSURE_EVAL_FUNCTION_3(node_eevee_specular, Diffuse, Glossy, Glossy); | ||||
| vec3(1.0), | |||||
| int(ssr_id), | |||||
| roughness, | |||||
| clearcoat_normal, | |||||
| clearcoat * 0.25, | |||||
| clearcoat_roughness, | |||||
| occlusion, | |||||
| true, | |||||
| out_diff, | |||||
| out_spec, | |||||
| ssr_spec); | |||||
| float alpha = 1.0 - transp; | |||||
| result = CLOSURE_DEFAULT; | result = CLOSURE_DEFAULT; | ||||
| result.radiance = render_pass_diffuse_mask(diffuse.rgb, out_diff * diffuse.rgb); | |||||
| result.radiance += render_pass_glossy_mask(vec3(1.0), out_spec); | |||||
| result.radiance += render_pass_emission_mask(emissive.rgb); | |||||
| result.radiance *= alpha; | |||||
| result.transmittance = vec3(transp); | |||||
| closure_load_ssr_data(ssr_spec * alpha, roughness, normal, viewCameraVec, int(ssr_id), result); | { | ||||
| /* Diffuse. */ | |||||
| out_Diffuse_0.radiance = render_pass_diffuse_mask(vec3(1), out_Diffuse_0.radiance); | |||||
| out_Diffuse_0.radiance *= in_Diffuse_0.albedo; | |||||
| result += out_Diffuse_0.radiance; | |||||
| } | |||||
| { | |||||
| /* Glossy. */ | |||||
| float NV = dot(in_Glossy_1.N, cameraVec); | |||||
| vec2 split_sum = brdf_lut(NV, in_Glossy_1.roughness); | |||||
| vec3 brdf = F_brdf_single_scatter(specular.rgb, vec3(1.0), split_sum); | |||||
| out_Glossy_1.radiance = closure_mask_ssr_radiance(out_Glossy_1.radiance, ssr_id); | |||||
| out_Glossy_1.radiance *= brdf; | |||||
| out_Glossy_1.radiance = render_pass_glossy_mask(spec_color, out_Glossy_1.radiance); | |||||
| closure_load_ssr_data( | |||||
| out_Glossy_1.radiance, in_Glossy_1.roughness, in_Glossy_1.N, ssr_id, result); | |||||
| } | |||||
| { | |||||
| /* Clearcoat. */ | |||||
| float NV = dot(in_Glossy_2.N, cameraVec); | |||||
| vec2 split_sum = brdf_lut(NV, in_Glossy_2.roughness); | |||||
| vec3 brdf = F_brdf_single_scatter(vec3(0.04), vec3(1.0), split_sum); | |||||
| out_Glossy_2.radiance *= brdf * clearcoat * 0.25; | |||||
| out_Glossy_2.radiance = render_pass_glossy_mask(vec3(1), out_Glossy_2.radiance); | |||||
| result.radiance += out_Glossy_2.radiance; | |||||
| } | |||||
| { | |||||
| /* Emission. */ | |||||
| vec3 out_emission_radiance = render_pass_emission_mask(emission.rgb); | |||||
| result.radiance += out_emission_radiance; | |||||
| } | |||||
| float trans = 1.0 - trans; | |||||
| result.transmittance = vec3(trans); | |||||
| result.radiance *= alpha; | |||||
| result.ssr_data.rgb *= alpha; | |||||
| } | } | ||||
| #else | #else | ||||
| /* Stub specular because it is not compatible with volumetrics. */ | /* Stub specular because it is not compatible with volumetrics. */ | ||||
| # define node_eevee_specular(a, b, c, d, e, f, g, h, i, j, k, result) (result = CLOSURE_DEFAULT) | # define node_eevee_specular(a, b, c, d, e, f, g, h, i, j, k, result) (result = CLOSURE_DEFAULT) | ||||
| #endif | #endif | ||||