31#include "gpu_shader_codegen_lib.glsl"
132 float additional_weight)
const
135 ClosureUndetermined cl = r.
data;
182 return id.resource_id<64>();
191 return id.view_id<64>();
256 cl.color = in_cl.color;
267 ClosureThinRefraction);
273 ClosureUndetermined cl;
292 ClosureUndetermined cl;
294 cl.data.rgb = subsurface.sss_radius;
304 ClosureUndetermined cl;
315 ClosureUndetermined cl;
317 cl.data.r = reflection.roughness;
372 ClosureUndetermined cl;
374 cl.data.r = refraction.roughness;
375 cl.data.g = refraction.ior;
385 ClosureUndetermined cl;
387 cl.data.r = refraction.roughness;
403 sd.
holdout += transparency.holdout;
416 ClosureVolumeAbsorption volume_absorption)
431 ClosureReflection reflection,
432 ClosureRefraction refraction)
442 ClosureDiffuse diffuse,
443 ClosureReflection reflection)
453 ClosureReflection reflection,
454 ClosureReflection coat)
464 ClosureVolumeScatter volume_scatter,
465 ClosureVolumeAbsorption volume_absorption,
466 ClosureEmission emission)
477 ClosureDiffuse diffuse,
478 ClosureReflection reflection,
479 ClosureReflection coat)
490 ClosureDiffuse diffuse,
491 ClosureReflection reflection,
492 ClosureReflection coat,
493 ClosureRefraction refraction)
517 const float sample_count)
519#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
531 float3 vN = view.normal_world_to_view(normal);
549 int(sample_count / 2.0f),
575 hit_distance = max_distance;
576 hit_position =
float3(0.0f);
577 hit_normal =
float3(0.0f);
609 ws_start += direction * offset_delta;
621 view.normal_world_to_view(direction),
622 raycast.raycast_depth_tx,
626 raycast.object_id_tx,
627 self_only ? self_id : 0u,
629 if (result >= 0.0f) {
631 hit_position = ws_start + direction * result;
633 hit_normal =
normalize(
texture(raycast.prepass_normal_tx, hit_uv).xyz * 2.0f - 1.0f);
635 uint hit_id =
texelFetch(raycast.object_id_tx, hit_texel, 0).x;
636 self_hit = self_only || (hit_id == self_id);
652 return (eta - 1.0f) / (eta + 1.0f);
674 return f0 * lut.scale + f90 * lut.bias;
690 float Ess = lut.scale + lut.bias;
691 float Ems = 1.0f - Ess;
692 float3 Favg = f0 + (f90 - f0) / 21.0f;
701 return FssEss / (1.0f - Ems * Favg);
715 bool do_multiscatter,
732 constexpr float f = 6.0f / 7.0f;
733 constexpr float f5 = (f * f) * (f * f) * f;
734 constexpr float f6 = (f * f) * (f * f) * (f * f);
736 float3 b = F_schlick * (7.0f / f6) * (1.0f - F82);
750 bool do_multiscatter,
756 reflectance =
float3(0.0f);
791 if (do_multiscatter) {
794 const float Ems = 1.0f - Ess;
800 reflectance *=
scale;
801 transmittance *=
scale;
811 float3 reflectance, transmittance;
822 return float2(reflectance.r, transmittance.r);
830 bool do_multiscatter)
877#if defined(MAT_DISPLACEMENT_BUMP) || defined(GLSL_CPP_STUBS)
884 constexpr float bump_filter_width = 0.1f;
899 float3 surfgrad = dHd.
x * Rx + dHd.
y * Ry;
901 float facing = FrontFacing ? 1.0f : -1.0f;
902 return normalize(bump_filter_width *
abs(det) * sd.
N - facing *
sign(det) * surfgrad);
912#ifdef MAT_DISPLACEMENT_BUMP
949 coords.
camera = camera_matrices.normal_world_to_view(
P);
950 if (is_panoramic(cam.type)) {
955 coords.
screen.xy = coords.
screen.xy * cam.uv_scale + cam.uv_bias;
960 if (is_panoramic(cam.type)) {
963 float3 dir =
P - cam.viewinv[3].xyz;
969 coords.
screen.xy = coords.
screen.xy * cam.uv_scale + cam.uv_bias;
1004 attr = (attr > 0.01f) ?
1035 const uint attr_hash)
1044 return vl_attributes.
get(attr_hash);
1060#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1063 const float linear_view_z =
dot(forward, sd.
P) -
dot(forward, view.
position());
1073#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1083#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1090#if (defined(GPU_FRAGMENT_SHADER) && defined(SRT_CONSTANT_use_lighting_nodes)) || \
1091 defined(GLSL_CPP_STUBS)
1093# define LIGHT_ITER_BEGIN(light_index) \
1095 eevee_light_VisibleLightIterator iter; \
1096 light_iter_init(kg, sd, iter); \
1097 while (light_iter_next(kg, iter)) { \
1098 if (light_iter_should_skip(kg, iter, sd.P)) { \
1101 light_index = iter.index;
1106# ifdef LIGHT_ITER_BEGIN
1107# undef LIGHT_ITER_BEGIN
1110# define LIGHT_ITER_BEGIN(light_index) \
1116#define LIGHT_ITER_END() \
1127 LightData light = lrd.
light_buf[light_index];
1129 color =
float4(light.color, 1.0f);
1149 LightData light = lrd.
light_buf[light_index];
1150 const bool is_directional = (light.type ==
LIGHT_SUN) || (light.type == LIGHT_SUN_ORTHO);
1159template<
bool use_diffuse>
1172 LightData light = lrd.
light_buf[light_index];
1173 const bool is_directional = (light.type ==
LIGHT_SUN) || (light.type == LIGHT_SUN_ORTHO);
1182 if constexpr (use_diffuse) {
1190 factor *= light.shape_power;
1193 factor /= (light.point_power *
M_1_PI);
1205 const int light_index,
1213#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1227 (light.type ==
LIGHT_SUN) || (light.type == LIGHT_SUN_ORTHO),
1241 color.rgb =
float3(shadow);
1247 const int light_index,
1251 LightData light = kg.lrd.light_buf[light_index];
1252 return kg.ob_attr.get(kg.infos.get(light.resource_id), attr_hash);
1261 return is_sun_light(light.type);
1270 return is_point_light(light.type) && !is_spot_light(light.type);
1279 return is_spot_light(light.type);
1288 return is_area_light(light.type);
1297 if (is_sun_light(light.type)) {
1300 return inversesqrt(light.local.local.influence_radius_invsqr_surface);
1307 const int light_index,
1312 float3 transmission_light,
1313 float3 transmission_color,
1317#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1320 float3 diffuse_color_weight = diffuse_color * weight;
1321 float3 glossy_color_weight = glossy_color * weight;
1322 float3 transmission_color_weight = transmission_color * weight;
1324 light.power_factor[LIGHT_DIFFUSE];
1326 light.power_factor[LIGHT_SPECULAR];
1328 light.power_factor[LIGHT_TRANSMISSION];
1349#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1353 uint total_len = render_pass.aovs.color_len + render_pass.aovs.value_len;
1357 for (hash_index = 0u; hash_index < AOV_MAX && hash_index < total_len; hash_index += 4u) {
1359 if (
any(cmp_mask)) {
1361 hash_index += (cmp_mask[0] ? 0u : (cmp_mask[1] ? 1u : (cmp_mask[2] ? 2u : 3u)));
1367 if (hash_index < total_len) {
1375 bool is_value = hash_index >= uint(render_pass.aovs.color_len);
1376 uint aov_index = hash_index - (is_value ? render_pass.aovs.color_len : 0u);
1380 out_aov *= 1.0f - holdout;
1384 rp_out.
store_value(texel,
int(render_pass.value_len + aov_index), out_aov.r);
1387 rp_out.
store_color(texel,
int(render_pass.color_len + aov_index), out_aov);
ccl_device_inline float cos_theta(const float3 w)
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
uint receiver_light_set_get(ObjectInfos object_infos)
#define OBJECT_ID_TEX_SLOT
#define RAYCAST_DEPTH_TEX_SLOT
#define PREPASS_NORMAL_TEX_SLOT
#define UTIL_BLUE_NOISE_LAYER
float light_attenuation_surface(LightData light, const bool is_directional, LightVector lv)
void closure_select(Reservoir< ClosureUndetermined > &reservoir, ClosureUndetermined candidate)
ClosureType closure_type_get(ClosureDiffuse)
float3 nodetree_displacement(KernelGlobals &, ShadingData &)
template float3 F_brdf_single_scatter< eevee::lut::GGXBrdfData >(float3, float3, eevee::lut::GGXBrdfData)
float4 node_attribute_light_impl(KernelGlobals &kg, const int light_index, uint attr_hash)
bool light_iter_next(KernelGlobals &kg, eevee::light::VisibleLightIterator &iter)
void fragment_displacement(KernelGlobals &kg, ShadingData &sd)
void output_aov(KernelGlobals &kg, int2 texel, float4 color, float value, uint hash, float holdout, eObjectInfoFlag ob_flag)
float4 attr_load_uniform(KernelGlobals &kg, const ShadingData &sd, float4, const uint attr_hash)
float attr_load_temperature_post(KernelGlobals &kg, float attr)
void raycast_eval(KernelGlobals &kg, const ShadingData &sd, float3 position, float3 direction, float max_distance, bool self_only, bool &is_hit, bool &self_hit, float &hit_distance, float3 &hit_position, float3 &hit_normal)
template float3 F_brdf_multi_scatter< eevee::lut::GGXBrdfData >(float3, float3, eevee::lut::GGXBrdfData)
void scene_time_uniforms(KernelGlobals &kg, float &seconds, float &frame)
float texture_lod_bias_get(KernelGlobals &kg)
void node_shadow_raycast_impl(KernelGlobals &kg, const ShadingData &sd, const int light_index, float3 position, float softness, float4 &color)
Closure closure_mix(Closure, Closure, float)
bool node_attribute_light_is_sun_impl(KernelGlobals &kg, const int light_index)
bool node_attribute_light_is_point_impl(KernelGlobals &kg, const int light_index)
void light_iter_init(KernelGlobals &kg, const ShadingData &sd, eevee::light::VisibleLightIterator &iter)
float derivative_scale_get(KernelGlobals &kg)
Closure closure_add(Closure, Closure)
float F0_from_f0(float f0)
bool node_attribute_light_is_spot_impl(KernelGlobals &kg, const int light_index)
void closure_weights_reset(KernelGlobals &kg, ShadingData &sd, float closure_rand)
void node_light_info_impl(KernelGlobals &kg, const int light_index, float4 &color, float &power, float3 &position)
template float3 F_brdf_multi_scatter< eevee::lut::GGXBsdfData >(float3, float3, eevee::lut::GGXBsdfData)
float3 brdf_lut(KernelGlobals &kg, float3 F0, float3 F90, float cos_theta, float roughness, bool do_multiscatter)
float ambient_occlusion_eval(const KernelGlobals &kg, const ShadingData &sd, float3 normal, float max_distance, const float inverted, const float sample_count)
void node_light_evaluation_impl(KernelGlobals &kg, const ShadingData &sd, int light_index, float3 position, float3 normal, float roughness, float &factor)
float3 F_brdf_multi_scatter(float3 f0, float3 f90, T lut)
void node_light_evaluation_common_impl(KernelGlobals &kg, int light_index, float3 position, float3 &direction, float &distance, float &mask)
void bsdf_lut(KernelGlobals &kg, float3 F0, float3 F90, float3 transmission_tint, float cos_theta, float roughness, float ior, bool do_multiscatter, float3 &reflectance, float3 &transmittance)
bool node_attribute_light_is_area_impl(KernelGlobals &kg, const int light_index)
void brdf_f82_tint_lut(KernelGlobals &kg, float3 F0, float3 F82, float cos_theta, float roughness, bool do_multiscatter, float3 &reflectance)
float3 displacement_bump(KernelGlobals &kg, ShadingData &sd)
void node_light_accumulation_impl(KernelGlobals &kg, ShadingData &sd, const int light_index, float3 diffuse_light, float3 diffuse_color, float3 glossy_light, float3 glossy_color, float3 transmission_light, float3 transmission_color, float weight, Closure &result)
float3 F_brdf_single_scatter(float3 f0, float3 f90, T lut)
float4 attr_load_color_post(KernelGlobals &kg, float4 attr)
void closure_base_copy(ClosureUndetermined &cl, T in_cl)
float4 node_attribute_layer_impl(KernelGlobals &kg, const uint attr_hash)
float F0_from_ior(float eta)
Coordinates coordinate_impl(KernelGlobals &kg, const ShadingData &sd, float3 P, float3 N)
bool light_iter_should_skip(KernelGlobals &kg, eevee::light::VisibleLightIterator &iter, float3 P)
Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureDiffuse diffuse)
float4 closure_to_rgba(KernelGlobals &kg, ShadingData &sd, Closure cl)
float f0_from_ior(float eta)
float node_attribute_light_cutoff_distance_impl(KernelGlobals &kg, const int light_index)
template float3 F_brdf_single_scatter< eevee::lut::GGXBsdfData >(float3, float3, eevee::lut::GGXBsdfData)
bool clip_ray(float3 &start, float3 &end, const float3 direction, const float max_distance, const float4 frustum_planes[6])
float raytrace_screen_2(ViewMatrices view, const float3 vs_origin, const float3 vs_end, const float3 vs_direction, sampler2D depth_tx, const RayTraceData rt_data, const int max_steps, const float jitter, usampler2D ob_id_tx, const uint object_id, float2 &r_hit_uv)
#define assert(assertion)
bool any(VecOp< bool, D >) RET
VecBase< T, D > reflect(VecOp< T, D >, VecOp< T, D >) RET
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
constexpr T inversesqrt(T) RET
float distance(float, float) RET
VecBase< uint, D > floatBitsToUint(VecOp< float, D >) RET
bool all(VecOp< bool, D >) RET
VecBase< float, D > uintBitsToFloat(VecOp< uint, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) RET
SamplerBase< float, 2 > sampler2D
TEX_TEMPLATE SizeVec textureSize(T, int) RET
SamplerBase< uint, 2 > usampler2D
float3x3 scale(float3x3 mat, float2 scale)
bool flag_test(uint flag, uint val)
ccl_device_inline float2 power(const float2 v, const float e)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
ccl_device_inline float3x3 inverted(const float3x3 m)
float2 uv_from_world(CameraData cam, float3 P)
template float eval< float >(const Uniform &, const ViewMatrices, ScreenThicknessParameters, sampler2D, sampler2D, sampler2D, float3, float3, float4, float2, float, float, int, int, bool, bool)
float evaluate(sampler2DArray util_tx, LightData light, LightShape shape, LightVector lv, LTCData ltc_data)
float shadow_eval(ShadowRenderData &srd, LightData light, const bool is_directional, const bool is_transmission, bool is_translucent_with_thickness, float2 frag_co, Thickness thickness, float3 P, float3 Ng, float3 N, float terminator_normal_offset, float terminator_geometry_offset, float soft_shadow_scale, int ray_count, int ray_step_count)
float interleaved_gradient(float2 pixel, float seed, float offset)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ViewMatrices view_matrices_get(const ShadingData &sd)
eevee::RenderPassOutput renderpass_out
uint resource_id_get(const ShadingData &sd)
ViewMatrices camera_matrices_get(const ShadingData &)
ObjectMatrices light_matrices_get(int light_index)
eevee::LightprobePlaneRenderData lightprobe_planes
ObjectMatrices object_matrices_get(const ShadingData &sd)
eevee::PipelineConstants pipe
eevee::PreviousLayerHiZ previous_layer_hiz
ObjectInfos object_infos_get(const ShadingData &sd)
eevee::PreviousLayerRadiance previous_layer_radiance
eevee::ShadowRenderData srd
eevee::LightEvalIterator light_eval
eevee::LightprobeRenderData lightprobes
draw::ViewCulling view_culling
eevee::LightRenderData lrd
uint view_id_get(const ShadingData &sd)
draw::ViewLayerAttributes vl_attr
packed_float3 diffuse_light
packed_float3 transmission_light
packed_float3 glossy_color
packed_float3 glossy_light
packed_float3 diffuse_color
packed_float3 transmission_color
int light_accumulation_count
static LightShape get(LightData light, LightVector lv)
static LightVector get(LightData light, const bool is_directional, float3 P)
float shadow_terminator_normal_offset
float shadow_terminator_geometry_offset
float get_final_weight() const
Reservoir< ClosureUndetermined > closure_get(const eevee::PipelineConstants &pipe, uchar i) const
packed_float3 barycentric_dists
packed_float2 barycentric_coords
packed_float3 transmittance
ClosureUndetermined closure_get_resolved(const eevee::PipelineConstants &pipe, uchar i, float additional_weight) const
packed_float3 volume_absorption
bool closure_reflection_bin
Reservoir< ClosureUndetermined > closure_bins[3]
LightAccumulation light_accum
packed_float3 point_position
packed_float3 volume_scattering
sampler2DArray utility_tx
float4 fetch(float2 texel, float layer) const
struct FrustumPlanes frustum_planes
float3 point_world_to_view(float3 P) const
float depth_screen_to_view(float ss_depth) const
float depth_view_to_screen(float v_depth) const
float3 world_incident_vector(float3 P) const
float3 point_world_to_screen(float3 vP) const
float4 get(ObjectInfos infos, const uint attr_hash) const
ObjectInfos get(uint resource_id) const
ObjectMatrices get(uint resource_id) const
ViewCullingData get(uint view_id) const
float4 get(const uint attr_hash) const
ViewMatrices get(uint view_id) const
static LTCData identity(float3 N, float3 V)
static LTCData sample_ltc_lut(const UtilityTexture &util_tx, float3 N, float3 V, float cos_theta, float roughness)
const LightData(& light_buf)[]
bool use_ambient_occlusion
sampler2D prepass_normal_tx
sampler2D raycast_depth_tx
void store_value(int2 texel, int id, float value)
void store_color(int2 texel, int id, float4 color)
float3 rng_3D_get(const eSamplingDimension dim) const
float rng_1D_get(const eSamplingDimension dim) const
bool should_skip(const eevee::LightRenderData &lrd, float3 P)
void init(const eevee::LightRenderData &lrd, float2 pixel, float linear_view_z, uint receiver_light_set)
bool next(const eevee::LightRenderData &lrd)
static GGXBrdfData sample_utility_tx(const UtilityTexture &util_tx, float cos_theta, float roughness)
float transmission_factor
static GGXBsdfData sample_utility_tx(const UtilityTexture &util_tx, float cos_theta, float roughness, float ior)
float transmission_factor
static GGXBtdfGt1Data sample_utility_tx(const UtilityTexture &util_tx, float cos_theta, float roughness, float f0)
CCL_NAMESPACE_BEGIN struct Window V