<commit_before>#ifndef POINT_LIGHT_H_
#define POINT_LIGHT_H_

#include "material.h"
#include "pbr.h"

struct PointShaderInfo
{
	vec3 color;
	vec3 falloff;
	float inv_radius;
	vec3 position;
	vec3 direction;
	float xy_scale;
};

#ifndef POINT_LIGHT_DATA_SET
#define POINT_LIGHT_DATA_SET 2
#endif
#ifndef POINT_LIGHT_DATA_BINDING
#define POINT_LIGHT_DATA_BINDING 0
#endif
#ifndef POINT_LIGHT_DATA_COUNT
#define POINT_LIGHT_DATA_COUNT 256
#endif

layout(std140, set = POINT_LIGHT_DATA_SET, binding = POINT_LIGHT_DATA_BINDING) uniform PointParameters
{
#ifdef POSITIONAL_LIGHT_INSTANCING
    PointShaderInfo data[POINT_LIGHT_DATA_COUNT];
#else
    PointShaderInfo data;
#endif
} point;

#ifdef POSITIONAL_LIGHTS_SHADOW
#ifndef POINT_LIGHT_SHADOW_DATA_SET
#define POINT_LIGHT_SHADOW_DATA_SET 2
#endif
#ifndef POINT_LIGHT_SHADOW_DATA_BINDING
#define POINT_LIGHT_SHADOW_DATA_BINDING 3
#endif
#ifndef POINT_LIGHT_SHADOW_DATA_COUNT
#define POINT_LIGHT_SHADOW_DATA_COUNT 256
#endif
#ifndef POINT_LIGHT_SHADOW_ATLAS_SET
#define POINT_LIGHT_SHADOW_ATLAS_SET 2
#endif
#ifndef POINT_LIGHT_SHADOW_ATLAS_BINDING
#define POINT_LIGHT_SHADOW_ATLAS_BINDING 2
#endif

struct PointShadowData
{
	vec4 transform;
	vec4 slice;
};

#ifdef POSITIONAL_LIGHT_INSTANCING
#define POINT_DATA(index) point.data[index]
#define POINT_SHADOW_TRANSFORM(index) point_shadow.data[index]
#else
#define POINT_DATA(index) point.data
#define POINT_SHADOW_TRANSFORM(index) point_shadow.data
#endif

layout(set = POINT_LIGHT_SHADOW_ATLAS_SET, binding = POINT_LIGHT_SHADOW_ATLAS_BINDING) uniform samplerCubeArrayShadow uPointShadowAtlas;
layout(std140, set = POINT_LIGHT_SHADOW_DATA_SET, binding = POINT_LIGHT_SHADOW_DATA_BINDING) uniform PointShadow
{
#ifdef POSITIONAL_LIGHT_INSTANCING
	PointShadowData data[POINT_LIGHT_SHADOW_DATA_COUNT];
#else
	PointShadowData data;
#endif
} point_shadow;
#endif

vec3 compute_point_light(int index, MaterialProperties material, vec3 world_pos, vec3 camera_pos)
{
	vec3 light_pos = POINT_DATA(index).position;
	vec3 light_dir_full = world_pos - light_pos;
	mediump vec3 light_dir = normalize(-light_dir_full);

#ifdef POSITIONAL_LIGHTS_SHADOW
	vec3 dir_abs = abs(light_dir_full);
	float max_z = max(max(dir_abs.x, dir_abs.y), dir_abs.z);
	vec4 shadow_transform = POINT_SHADOW_TRANSFORM(index).transform;
	vec2 shadow_ref2 = shadow_transform.zw - shadow_transform.xy * max_z;
	float shadow_ref = shadow_ref2.x / shadow_ref2.y;
	mediump float slice = POINT_SHADOW_TRANSFORM(index).slice.x;
	mediump float shadow_falloff = texture(uPointShadowAtlas, vec4(light_dir_full, slice), shadow_ref);
#else
	const float shadow_falloff = 1.0;
#endif

	mediump float light_dist = length(world_pos - light_pos);
	mediump float static_falloff = shadow_falloff * (1.0 - smoothstep(0.9, 1.0, light_dist * POINT_DATA(index).inv_radius));
	mediump vec3 f = POINT_DATA(index).falloff;
	mediump vec3 point_color = POINT_DATA(index).color * (static_falloff / (f.x + light_dist * f.y + light_dist * light_dist * f.z));

#ifdef POINT_LIGHT_EARLY_OUT
	if (all(equal(point_color, vec3(0.0))))
		discard;
#endif

	mediump float roughness = material.roughness * 0.75 + 0.25;<commit_msg>Fix point.h build.<commit_after>#ifndef POINT_LIGHT_H_
#define POINT_LIGHT_H_

#include "material.h"
#include "pbr.h"

struct PointShaderInfo
{
	vec3 color;
	vec3 falloff;
	float inv_radius;
	vec3 position;
	vec3 direction;
	float xy_scale;
};

#ifndef POINT_LIGHT_DATA_SET
#define POINT_LIGHT_DATA_SET 2
#endif
#ifndef POINT_LIGHT_DATA_BINDING
#define POINT_LIGHT_DATA_BINDING 0
#endif
#ifndef POINT_LIGHT_DATA_COUNT
#define POINT_LIGHT_DATA_COUNT 256
#endif

layout(std140, set = POINT_LIGHT_DATA_SET, binding = POINT_LIGHT_DATA_BINDING) uniform PointParameters
{
#ifdef POSITIONAL_LIGHT_INSTANCING
    PointShaderInfo data[POINT_LIGHT_DATA_COUNT];
#else
    PointShaderInfo data;
#endif
} point;

#ifdef POSITIONAL_LIGHTS_SHADOW
#ifndef POINT_LIGHT_SHADOW_DATA_SET
#define POINT_LIGHT_SHADOW_DATA_SET 2
#endif
#ifndef POINT_LIGHT_SHADOW_DATA_BINDING
#define POINT_LIGHT_SHADOW_DATA_BINDING 3
#endif
#ifndef POINT_LIGHT_SHADOW_DATA_COUNT
#define POINT_LIGHT_SHADOW_DATA_COUNT 256
#endif
#ifndef POINT_LIGHT_SHADOW_ATLAS_SET
#define POINT_LIGHT_SHADOW_ATLAS_SET 2
#endif
#ifndef POINT_LIGHT_SHADOW_ATLAS_BINDING
#define POINT_LIGHT_SHADOW_ATLAS_BINDING 2
#endif

struct PointShadowData
{
	vec4 transform;
	vec4 slice;
};

layout(set = POINT_LIGHT_SHADOW_ATLAS_SET, binding = POINT_LIGHT_SHADOW_ATLAS_BINDING) uniform samplerCubeArrayShadow uPointShadowAtlas;
layout(std140, set = POINT_LIGHT_SHADOW_DATA_SET, binding = POINT_LIGHT_SHADOW_DATA_BINDING) uniform PointShadow
{
#ifdef POSITIONAL_LIGHT_INSTANCING
	PointShadowData data[POINT_LIGHT_SHADOW_DATA_COUNT];
#else
	PointShadowData data;
#endif
} point_shadow;
#endif

#ifdef POSITIONAL_LIGHT_INSTANCING
#define POINT_DATA(index) point.data[index]
#define POINT_SHADOW_TRANSFORM(index) point_shadow.data[index]
#else
#define POINT_DATA(index) point.data
#define POINT_SHADOW_TRANSFORM(index) point_shadow.data
#endif


vec3 compute_point_light(int index, MaterialProperties material, vec3 world_pos, vec3 camera_pos)
{
	vec3 light_pos = POINT_DATA(index).position;
	vec3 light_dir_full = world_pos - light_pos;
	mediump vec3 light_dir = normalize(-light_dir_full);

#ifdef POSITIONAL_LIGHTS_SHADOW
	vec3 dir_abs = abs(light_dir_full);
	float max_z = max(max(dir_abs.x, dir_abs.y), dir_abs.z);
	vec4 shadow_transform = POINT_SHADOW_TRANSFORM(index).transform;
	vec2 shadow_ref2 = shadow_transform.zw - shadow_transform.xy * max_z;
	float shadow_ref = shadow_ref2.x / shadow_ref2.y;
	mediump float slice = POINT_SHADOW_TRANSFORM(index).slice.x;
	mediump float shadow_falloff = texture(uPointShadowAtlas, vec4(light_dir_full, slice), shadow_ref);
#else
	const float shadow_falloff = 1.0;
#endif

	mediump float light_dist = length(world_pos - light_pos);
	mediump float static_falloff = shadow_falloff * (1.0 - smoothstep(0.9, 1.0, light_dist * POINT_DATA(index).inv_radius));
	mediump vec3 f = POINT_DATA(index).falloff;
	mediump vec3 point_color = POINT_DATA(index).color * (static_falloff / (f.x + light_dist * f.y + light_dist * light_dist * f.z));

#ifdef POINT_LIGHT_EARLY_OUT
	if (all(equal(point_color, vec3(0.0))))
		discard;
#endif

	mediump float roughness = material.roughness * 0.75 + 0.25;
{'fraction_non_alphanumeric': 0.0799492385786802, 'fraction_numerical': 0.017766497461928935, 'mean_word_length': 7.451742627345845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3840399', 'n_tokens_mistral': 2580, 'n_tokens_neox': 2463, 'n_words': 471}