Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gpu_shader_material_eevee_specular.glsl « material « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0941482df4588a87c6cc057b621b1a594a6cc807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef VOLUMETRICS

CLOSURE_EVAL_FUNCTION_DECLARE_3(node_eevee_specular, Diffuse, Glossy, Glossy)

void node_eevee_specular(vec4 diffuse,
                         vec4 specular,
                         float roughness,
                         vec4 emissive,
                         float transp,
                         vec3 normal,
                         float clearcoat,
                         float clearcoat_roughness,
                         vec3 clearcoat_normal,
                         float occlusion,
                         float ssr_id,
                         out Closure result)
{
  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;

  in_Glossy_2.N = clearcoat_normal; /* Normalized during eval. */
  in_Glossy_2.roughness = clearcoat_roughness;

  CLOSURE_EVAL_FUNCTION_3(node_eevee_specular, Diffuse, Glossy, Glossy);

  result = CLOSURE_DEFAULT;

  vec3 V = cameraVec(worldPosition);

  {
    /* Diffuse. */
    out_Diffuse_0.radiance = render_pass_diffuse_mask(vec3(1), out_Diffuse_0.radiance);
    out_Diffuse_0.radiance *= in_Diffuse_0.albedo;
    result.radiance += out_Diffuse_0.radiance;
  }
  {
    /* Glossy. */
    float NV = dot(in_Glossy_1.N, V);
    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(specular.rgb, 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, V);
    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(emissive.rgb);
    result.radiance += out_emission_radiance;
  }

  float alpha = 1.0 - transp;
  result.transmittance = vec3(transp);
  result.radiance *= alpha;
  result.ssr_data.rgb *= alpha;
}

#else
/* 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)
#endif