Blender  V3.3
eevee_material_info.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
4 
5 /* -------------------------------------------------------------------- */
9 /* TODO(@fclem): This is a bit out of place at the moment. */
10 GPU_SHADER_CREATE_INFO(eevee_shared)
11  .typedef_source("eevee_defines.hh")
12  .typedef_source("eevee_shader_shared.hh");
13 
14 GPU_SHADER_CREATE_INFO(eevee_sampling_data)
15  .additional_info("eevee_shared")
16  .uniform_buf(14, "SamplingData", "sampling_buf");
17 
20 /* -------------------------------------------------------------------- */
24 GPU_SHADER_CREATE_INFO(eevee_geom_mesh)
25  .additional_info("eevee_shared")
26  .define("MAT_GEOM_MESH")
27  .vertex_in(0, Type::VEC3, "pos")
28  .vertex_in(1, Type::VEC3, "nor")
29  .vertex_source("eevee_geom_mesh_vert.glsl")
30  .additional_info("draw_mesh", "draw_resource_id_varying", "draw_resource_handle");
31 
32 GPU_SHADER_CREATE_INFO(eevee_geom_gpencil)
33  .additional_info("eevee_shared")
34  .define("MAT_GEOM_GPENCIL")
35  .vertex_source("eevee_geom_gpencil_vert.glsl")
36  .additional_info("draw_gpencil", "draw_resource_id_varying", "draw_resource_handle");
37 
38 GPU_SHADER_CREATE_INFO(eevee_geom_curves)
39  .additional_info("eevee_shared")
40  .define("MAT_GEOM_CURVES")
41  .vertex_source("eevee_geom_curves_vert.glsl")
42  .additional_info("draw_hair",
43  "draw_curves_infos",
44  "draw_resource_id_varying",
45  "draw_resource_handle");
46 
47 GPU_SHADER_CREATE_INFO(eevee_geom_world)
48  .additional_info("eevee_shared")
49  .define("MAT_GEOM_WORLD")
50  .builtins(BuiltinBits::VERTEX_ID)
51  .vertex_source("eevee_geom_world_vert.glsl")
52  .additional_info("draw_modelmat", "draw_resource_id_varying", "draw_resource_handle");
53 
56 /* -------------------------------------------------------------------- */
60 GPU_SHADER_INTERFACE_INFO(eevee_surf_iface, "interp")
61  .smooth(Type::VEC3, "P")
62  .smooth(Type::VEC3, "N")
63  .smooth(Type::VEC2, "barycentric_coords")
64  .smooth(Type::VEC3, "curves_tangent")
65  .smooth(Type::VEC3, "curves_binormal")
66  .smooth(Type::FLOAT, "curves_time")
67  .smooth(Type::FLOAT, "curves_time_width")
68  .smooth(Type::FLOAT, "curves_thickness")
69  .flat(Type::INT, "curves_strand_id");
70 
71 #define image_out(slot, qualifier, format, name) \
72  image(slot, format, qualifier, ImageType::FLOAT_2D, name, Frequency::PASS)
73 #define image_array_out(slot, qualifier, format, name) \
74  image(slot, format, qualifier, ImageType::FLOAT_2D_ARRAY, name, Frequency::PASS)
75 
76 GPU_SHADER_CREATE_INFO(eevee_aov_out)
77  .define("MAT_AOV_SUPPORT")
78  .image_array_out(6, Qualifier::WRITE, GPU_RGBA16F, "aov_color_img")
79  .image_array_out(7, Qualifier::WRITE, GPU_R16F, "aov_value_img")
80  .storage_buf(7, Qualifier::READ, "AOVsInfoData", "aov_buf");
81 
82 GPU_SHADER_CREATE_INFO(eevee_surf_deferred)
83  .vertex_out(eevee_surf_iface)
84  /* NOTE: This removes the possibility of using gl_FragDepth. */
85  // .early_fragment_test(true)
86  /* Direct output. */
87  .fragment_out(0, Type::VEC4, "out_radiance", DualBlend::SRC_0)
88  .fragment_out(0, Type::VEC4, "out_transmittance", DualBlend::SRC_1)
89  /* Gbuffer. */
90  // .image_out(0, Qualifier::WRITE, GPU_R11F_G11F_B10F, "gbuff_transmit_color")
91  // .image_out(1, Qualifier::WRITE, GPU_R11F_G11F_B10F, "gbuff_transmit_data")
92  // .image_out(2, Qualifier::WRITE, GPU_RGBA16F, "gbuff_transmit_normal")
93  // .image_out(3, Qualifier::WRITE, GPU_R11F_G11F_B10F, "gbuff_reflection_color")
94  // .image_out(4, Qualifier::WRITE, GPU_RGBA16F, "gbuff_reflection_normal")
95  // .image_out(5, Qualifier::WRITE, GPU_R11F_G11F_B10F, "gbuff_emission")
96  /* Render-passes. */
97  // .image_out(6, Qualifier::READ_WRITE, GPU_RGBA16F, "rpass_volume_light")
98  /* TODO: AOVs maybe? */
99  .fragment_source("eevee_surf_deferred_frag.glsl")
100  // .additional_info("eevee_aov_out", "eevee_sampling_data", "eevee_utility_texture")
101  ;
102 
103 GPU_SHADER_CREATE_INFO(eevee_surf_forward)
104  .auto_resource_location(true)
105  .vertex_out(eevee_surf_iface)
106  /* Early fragment test is needed for render passes support for forward surfaces. */
107  /* NOTE: This removes the possibility of using gl_FragDepth. */
108  .early_fragment_test(true)
109  .fragment_out(0, Type::VEC4, "out_radiance", DualBlend::SRC_0)
110  .fragment_out(0, Type::VEC4, "out_transmittance", DualBlend::SRC_1)
111  .fragment_source("eevee_surf_forward_frag.glsl")
112  .image_out(0, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_normal_img")
113  .image_out(1, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_light_img")
114  .image_out(2, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_color_img")
115  .image_out(3, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_light_img")
116  .image_out(4, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_color_img")
117  .image_out(5, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_emission_img")
118  .additional_info("eevee_aov_out"
119  // "eevee_sampling_data",
120  // "eevee_lightprobe_data",
121  /* Optionally added depending on the material. */
122  // "eevee_raytrace_data",
123  // "eevee_transmittance_data",
124  // "eevee_utility_texture",
125  // "eevee_light_data",
126  // "eevee_shadow_data"
127  );
128 
129 GPU_SHADER_CREATE_INFO(eevee_surf_depth)
130  .vertex_out(eevee_surf_iface)
131  .fragment_source("eevee_surf_depth_frag.glsl")
132  // .additional_info("eevee_sampling_data", "eevee_utility_texture")
133  ;
134 
135 GPU_SHADER_CREATE_INFO(eevee_surf_world)
136  .vertex_out(eevee_surf_iface)
137  .image_out(0, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_normal_img")
138  .image_out(1, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_light_img")
139  .image_out(2, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_color_img")
140  .image_out(3, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_light_img")
141  .image_out(4, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_color_img")
142  .image_out(5, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_emission_img")
143  .push_constant(Type::FLOAT, "world_opacity_fade")
144  .fragment_out(0, Type::VEC4, "out_background")
145  .fragment_source("eevee_surf_world_frag.glsl")
146  .additional_info("eevee_aov_out"
147  //"eevee_utility_texture"
148  );
149 
150 #undef image_out
151 #undef image_array_out
152 
155 /* -------------------------------------------------------------------- */
159 #if 0 /* TODO */
160 GPU_SHADER_INTERFACE_INFO(eevee_volume_iface, "interp")
161  .smooth(Type::VEC3, "P_start")
162  .smooth(Type::VEC3, "P_end");
163 
164 GPU_SHADER_CREATE_INFO(eevee_volume_deferred)
165  .sampler(0, ImageType::DEPTH_2D, "depth_max_tx")
166  .vertex_in(0, Type::VEC3, "pos")
167  .vertex_out(eevee_volume_iface)
168  .fragment_out(0, Type::UVEC4, "out_volume_data")
169  .fragment_out(1, Type::VEC4, "out_transparency_data")
170  .additional_info("eevee_shared")
171  .vertex_source("eevee_volume_vert.glsl")
172  .fragment_source("eevee_volume_deferred_frag.glsl")
173  .additional_info("draw_fullscreen");
174 #endif
175 
178 /* -------------------------------------------------------------------- */
184 #ifdef DEBUG
185 
186 /* Stub functions defined by the material evaluation. */
187 GPU_SHADER_CREATE_INFO(eevee_material_stub).define("EEVEE_MATERIAL_STUBS");
188 
189 # define EEVEE_MAT_FINAL_VARIATION(name, ...) \
190  GPU_SHADER_CREATE_INFO(name) \
191  .additional_info(__VA_ARGS__) \
192  .auto_resource_location(true) \
193  .do_static_compilation(true);
194 
195 # define EEVEE_MAT_GEOM_VARIATIONS(prefix, ...) \
196  EEVEE_MAT_FINAL_VARIATION(prefix##_world, "eevee_geom_world", __VA_ARGS__) \
197  EEVEE_MAT_FINAL_VARIATION(prefix##_gpencil, "eevee_geom_gpencil", __VA_ARGS__) \
198  EEVEE_MAT_FINAL_VARIATION(prefix##_curves, "eevee_geom_curves", __VA_ARGS__) \
199  EEVEE_MAT_FINAL_VARIATION(prefix##_mesh, "eevee_geom_mesh", __VA_ARGS__)
200 
201 # define EEVEE_MAT_PIPE_VARIATIONS(name, ...) \
202  EEVEE_MAT_GEOM_VARIATIONS(name##_world, "eevee_surf_world", __VA_ARGS__) \
203  EEVEE_MAT_GEOM_VARIATIONS(name##_depth, "eevee_surf_depth", __VA_ARGS__) \
204  EEVEE_MAT_GEOM_VARIATIONS(name##_deferred, "eevee_surf_deferred", __VA_ARGS__) \
205  EEVEE_MAT_GEOM_VARIATIONS(name##_forward, "eevee_surf_forward", __VA_ARGS__)
206 
207 EEVEE_MAT_PIPE_VARIATIONS(eevee_surface, "eevee_material_stub")
208 
209 #endif
210 
@ GPU_R16F
Definition: GPU_texture.h:113
#define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name)
#define GPU_SHADER_CREATE_INFO(_info)
@ FLOAT