29 if (is_area_light(
light.type)) {
33 float radius =
light.local.local.shape_radius;
44 if (is_sphere_light(
light.type)) {
53 return center + (view_right * quad_pos.
x + view_up * quad_pos.
y) * radius;
64 float x = (quad_vertex_id == 0 || quad_vertex_id == 2 || quad_vertex_id == 5) ? -1.0f : 1.0f;
65 float y = (quad_vertex_id == 0 || quad_vertex_id == 1 || quad_vertex_id == 3) ? -1.0f : 1.0f;
78 v_out.radiance =
float3(0.0f);
79 v_out.light_index = 0;
80 v_out.light_type = uint(LIGHT_RECT);
81 out_position =
float4(0.0f, 0.0f, 0.0f, 1.0f);
84 int visible_count = int(lrd.light_cull_buf.visible_count + lrd.light_cull_buf.sun_lights_len);
86 if (draw_index >= visible_count) {
91 if (draw_index <
int(lrd.light_cull_buf.visible_count)) {
92 light_index = draw_index;
95 int offset = draw_index - int(lrd.light_cull_buf.visible_count);
96 light_index = int(lrd.light_cull_buf.local_lights_len) + offset;
99 LightData
light = lrd.light_buf[light_index];
100 if ((
light.flags & LIGHT_CAMERA_HIDDEN) != 0u) {
104 v_out.light_type = uint(
light.type);
105 v_out.light_index = light_index;
106 v_out.radiance =
light.color *
light.shape_power;
109 if (is_sun_light(
light.type)) {
128 eLightType light_type = eLightType(v_out.light_type);
129 LightData
light = lrd.light_buf[v_out.light_index];
135 if (is_sun_light(light_type)) {
144 if (is_area_light(light_type) &&
dot(
V,
light.z_axis()) > 0.0f) {
149 bool is_circle = light_type == LIGHT_ELLIPSE || is_point_light(light_type);
150 if (is_circle &&
dot(v_out.lP, v_out.lP) > 1.0f) {
158 float2 uvs = frag_co.xy * uni.uniform_buf.volumes.main_view_extent_inv;
159 float3 radiance = v_out.radiance;
160 if (is_spot_light(light_type)) {
void make_orthonormal_basis(float3 N, float3 &T, float3 &B)
float light_spot_attenuation(LightData light, float3 L)
float light_sphere_disk_radius(float sphere_radius, float distance_to_sphere)
void gpu_discard_fragment()
float dot(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
float cos_from_tan(float t)
void shape_display_frag(const draw::View &views, const LightRenderData &lrd, const UnifiedVolumeData &volumes, const Uniform &uni, const float4 frag_co, const ShapeDisplayVertOut &v_out, ShapeDisplayFragOut &frag_out)
float3 shape_display_far_plane_position_get(const ViewMatrices view, float2 ndc_pos)
void shape_display_vert(const draw::View &views, const LightRenderData &lrd, const int vertex_id, ShapeDisplayVertOut &v_out, float4 &out_position)
float3 shape_display_light_position_get(const ViewMatrices view, LightData light, float2 quad_pos)
PipelineGraphic shape_display(shape_display_vert, shape_display_frag)
float2 shape_display_quad_position_get(int vertex_id)
T read(T depth_buffer_value)
float4 transform(float4 hs_position)
float3 sun_direction(float sun_cos_theta)
float4 point_world_to_homogenous(float3 P) const
float3 point_ndc_to_world(float3 ssP) const
float3 world_incident_vector(float3 P) const
CCL_NAMESPACE_BEGIN struct Window V