Files
LNXSDK/leenkx/Shaders/std/light.glsl

704 lines
17 KiB
Plaintext
Raw Normal View History

2025-04-07 15:45:04 +00:00
#ifndef _LIGHT_GLSL_
#define _LIGHT_GLSL_
#include "compiled.inc"
#include "std/brdf.glsl"
#include "std/math.glsl"
#ifdef _ShadowMap
#include "std/shadows.glsl"
#endif
#ifdef _VoxelShadow
#include "std/conetrace.glsl"
#endif
#ifdef _LTC
#include "std/ltc.glsl"
#endif
#ifdef _LightIES
#include "std/ies.glsl"
#endif
#ifdef _SSRS
#include "std/ssrs.glsl"
#endif
#ifdef _Spot
#include "std/light_common.glsl"
#endif
2025-05-22 02:20:28 +00:00
#ifdef _VoxelShadow
#include "std/conetrace.glsl"
#endif
2025-04-07 15:45:04 +00:00
#ifdef _ShadowMap
#ifdef _SinglePoint
#ifdef _Spot
#ifndef _LTC
uniform sampler2DShadow shadowMapSpot[1];
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
uniform sampler2D shadowMapSpotTransparent[1];
2025-05-29 21:22:25 +00:00
#endif
uniform mat4 LWVPSpotArray[1];
2025-04-07 15:45:04 +00:00
#endif
#else
uniform samplerCubeShadow shadowMapPoint[1];
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
uniform samplerCube shadowMapPointTransparent[1];
2025-05-29 21:22:25 +00:00
#endif
2025-04-07 15:45:04 +00:00
uniform vec2 lightProj;
#endif
#endif
#ifdef _Clusters
#ifdef _SingleAtlas
//!uniform sampler2DShadow shadowMapAtlas;
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
//!uniform sampler2D shadowMapAtlasTransparent;
#endif
2025-05-29 21:22:25 +00:00
#endif
2026-08-07 02:04:01 -07:00
#ifndef _SinglePoint
2025-04-07 15:45:04 +00:00
uniform vec2 lightProj;
2026-08-07 02:04:01 -07:00
#endif
2025-04-07 15:45:04 +00:00
#ifdef _ShadowMapAtlas
#ifndef _SingleAtlas
uniform sampler2DShadow shadowMapAtlasPoint;
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
uniform sampler2D shadowMapAtlasPointTransparent;
#endif
2025-05-29 21:22:25 +00:00
#endif
2025-04-07 15:45:04 +00:00
#else
uniform samplerCubeShadow shadowMapPoint[4];
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
uniform samplerCube shadowMapPointTransparent[4];
#endif
2025-05-29 21:22:25 +00:00
#endif
2025-04-07 15:45:04 +00:00
#ifdef _Spot
#ifdef _ShadowMapAtlas
#ifndef _SingleAtlas
uniform sampler2DShadow shadowMapAtlasSpot;
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
uniform sampler2D shadowMapAtlasSpotTransparent;
#endif
2025-05-29 21:22:25 +00:00
#endif
2025-04-07 15:45:04 +00:00
#else
uniform sampler2DShadow shadowMapSpot[4];
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
uniform sampler2D shadowMapSpotTransparent[4];
#endif
2025-05-29 21:22:25 +00:00
#endif
2025-04-07 15:45:04 +00:00
uniform mat4 LWVPSpotArray[maxLightsCluster];
#endif
#endif
#endif
#ifdef _LTC
uniform vec3 lightArea0;
uniform vec3 lightArea1;
uniform vec3 lightArea2;
uniform vec3 lightArea3;
uniform sampler2D sltcMat;
uniform sampler2D sltcMag;
#ifdef _ShadowMap
#ifdef _SinglePoint
uniform sampler2DShadow shadowMapSpot[1];
2025-05-29 21:22:25 +00:00
#ifdef _ShadowMapTransparent
2025-04-07 15:45:04 +00:00
uniform sampler2D shadowMapSpotTransparent[1];
2025-05-29 21:22:25 +00:00
#endif
uniform mat4 LWVPSpotArray[1];
2025-04-07 15:45:04 +00:00
#endif
#endif
#endif
2026-08-07 02:04:01 -07:00
vec3 sampleLightCore(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
2025-04-07 15:45:04 +00:00
const vec3 albedo, const float rough, const float spec, const vec3 f0
#ifdef _ShadowMap
2025-05-29 21:22:25 +00:00
, int index, float bias, bool receiveShadow
#ifdef _ShadowMapTransparent
, bool transparent
#endif
2025-04-07 15:45:04 +00:00
#endif
#ifdef _Spot
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
#endif
2026-07-27 12:10:11 -07:00
#ifdef _ClearCoat
2026-08-07 02:04:01 -07:00
, float clearcoat, float clearcoatRough, float coatIOR, vec3 coatTint, vec3 coatN
2026-07-27 12:10:11 -07:00
#endif
#ifdef _Sheen
, float sheen, float sheenRough, vec3 sheenTint
#endif
#ifdef _Anisotropy
, float anisotropy, float anisoRot, vec3 tangent
#endif
2026-08-07 02:04:01 -07:00
#ifdef _SSS
2026-07-27 12:10:11 -07:00
, float subsurface, vec3 sssColor, vec3 sssRadius, float sssAnisotropy
#endif
#ifdef _Transmission
, float transmission, float transRough, float ior, float thinWall
#endif
2026-08-07 02:04:01 -07:00
, out vec3 l_out
2026-05-12 23:54:06 -07:00
) {
2025-04-07 15:45:04 +00:00
vec3 ld = lp - p;
2026-08-07 02:04:01 -07:00
float dist = length(ld);
vec3 l = ld / dist;
2025-04-07 15:45:04 +00:00
vec3 h = normalize(v + l);
float dotNH = max(0.0, dot(n, h));
float dotVH = max(0.0, dot(v, h));
float dotNL = max(0.0, dot(n, l));
2026-08-07 02:04:01 -07:00
#ifdef _VoxelPass
vec3 direct = vec3(dotNL);
#else
2025-04-07 15:45:04 +00:00
#ifdef _LTC
float theta = acos(dotNV);
vec2 tuv = vec2(rough, theta / (0.5 * PI));
tuv = tuv * LUT_SCALE + LUT_BIAS;
vec4 t = textureLod(sltcMat, tuv, 0.0);
mat3 invM = mat3(
vec3(1.0, 0.0, t.y),
vec3(0.0, t.z, 0.0),
vec3(t.w, 0.0, t.x));
2026-05-16 10:50:02 -07:00
float ltcspec = ltcEvaluate(n, v, dotNV, p, invM, lightArea0, lightArea1, lightArea2, lightArea3);
2025-04-07 15:45:04 +00:00
ltcspec *= textureLod(sltcMag, tuv, 0.0).a;
2026-05-16 10:50:02 -07:00
float ltcdiff = ltcEvaluate(n, v, dotNV, p, mat3(1.0), lightArea0, lightArea1, lightArea2, lightArea3);
2025-04-07 15:45:04 +00:00
vec3 direct = albedo * ltcdiff + ltcspec * spec * 0.05;
#else
2026-07-27 12:10:11 -07:00
#ifdef _Anisotropy
vec3 direct;
2026-08-07 02:04:01 -07:00
if (abs(anisotropy) > 0.001 && dot(tangent, tangent) > 0.001) {
2026-07-27 12:10:11 -07:00
vec3 bitangent = normalize(cross(n, tangent));
direct = lambertDiffuseBRDF(albedo, dotNL) +
anisotropicBRDF(f0, rough, anisotropy, anisoRot,
tangent, bitangent, n, l, v, dotNL, dotNV) * spec;
} else {
direct = lambertDiffuseBRDF(albedo, dotNL) +
specularBRDF(f0, rough, dotNL, dotNH, dotNV, dotVH) * spec;
}
#else
2025-04-07 15:45:04 +00:00
vec3 direct = lambertDiffuseBRDF(albedo, dotNL) +
2026-08-07 02:04:01 -07:00
specularBRDF(f0, rough, dotNL, dotNH, dotNV, dotVH) * spec;
2025-04-07 15:45:04 +00:00
#endif
2026-07-27 12:10:11 -07:00
#endif
// before attenuate/shadow so everything is properly shadowed in one pass
2026-08-07 02:04:01 -07:00
#ifdef _ExtBRDF
float layerWeight;
direct = applyExtBRDFLayers(direct, albedo, f0, rough,
dotNL, dotNV, dotNH, dotVH, n, l, v, h
#ifdef _ClearCoat
, clearcoat, clearcoatRough, coatIOR, coatTint, coatN
#endif
#ifdef _Sheen
, sheen, sheenRough, sheenTint
#endif
#ifdef _Transmission
, transmission, transRough, ior, thinWall
#endif
, layerWeight);
2026-07-27 12:10:11 -07:00
#endif
#endif
2025-04-07 15:45:04 +00:00
2026-08-07 02:04:01 -07:00
direct *= attenuate(dist);
2026-02-24 11:44:01 -08:00
direct *= min(lightCol, vec3(100.0));
2025-04-07 15:45:04 +00:00
#ifdef _LTC
#ifdef _ShadowMap
if (receiveShadow) {
#ifdef _SinglePoint
2026-08-07 02:04:01 -07:00
vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
2025-05-29 21:22:25 +00:00
direct *= shadowTest(shadowMapSpot[0],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[0],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#endif
#ifdef _Clusters
2026-08-07 02:04:01 -07:00
vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
#ifdef _ShadowMapAtlas
tileBounds = tileBoundsSpotArray[index];
direct *= shadowTest(
#ifdef _ShadowMapTransparent
#ifndef _SingleAtlas
shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
#else
shadowMapAtlas, shadowMapAtlasTransparent
#endif
#else
#ifndef _SingleAtlas
shadowMapAtlasSpot
#else
shadowMapAtlas
#endif
#endif
, lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
#else
2025-05-29 21:22:25 +00:00
if (index == 0) direct *= shadowTest(shadowMapSpot[0],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[0],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[1],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[2],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[3],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#endif
2026-08-07 02:04:01 -07:00
#endif
2025-04-07 15:45:04 +00:00
}
#endif
2026-08-07 02:04:01 -07:00
l_out = l;
2025-04-07 15:45:04 +00:00
return direct;
#endif
#ifdef _Spot
if (isSpot) {
direct *= spotlightMask(l, spotDir, right, scale, spotSize, spotBlend);
#ifdef _ShadowMap
if (receiveShadow) {
#ifdef _SinglePoint
2026-05-16 10:50:02 -07:00
vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
2025-05-29 21:22:25 +00:00
direct *= shadowTest(shadowMapSpot[0],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[0],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#endif
#ifdef _Clusters
2026-05-16 10:50:02 -07:00
vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
2025-04-07 15:45:04 +00:00
#ifdef _ShadowMapAtlas
2026-08-07 02:04:01 -07:00
tileBounds = tileBoundsSpotArray[index];
direct *= shadowTest(
#ifdef _ShadowMapTransparent
#ifndef _SingleAtlas
shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
#else
shadowMapAtlas, shadowMapAtlasTransparent
#endif
#else
#ifndef _SingleAtlas
shadowMapAtlasSpot
#else
shadowMapAtlas
#endif
#endif
, lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#else
2026-02-24 11:44:01 -08:00
if (index == 0) direct *= shadowTest(shadowMapSpot[0],
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[0],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[1],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[2],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapSpotTransparent[3],
#endif
lPos.xyz / lPos.w, bias
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#endif
#endif
}
#endif
2026-08-07 02:04:01 -07:00
l_out = l;
2025-04-07 15:45:04 +00:00
return direct;
}
#endif
#ifdef _LightIES
direct *= iesAttenuation(-l);
#endif
#ifdef _ShadowMap
if (receiveShadow) {
#ifdef _SinglePoint
#ifndef _Spot
2025-05-29 21:22:25 +00:00
direct *= PCFCube(shadowMapPoint[0],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapPointTransparent[0],
#endif
ld, -l, bias, lightProj, n
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#endif
#endif
#ifdef _Clusters
#ifdef _ShadowMapAtlas
direct *= PCFFakeCube(
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
#ifndef _SingleAtlas
shadowMapAtlasPoint, shadowMapAtlasPointTransparent
#else
shadowMapAtlas, shadowMapAtlasTransparent
#endif
#else
#ifndef _SingleAtlas
shadowMapAtlasPoint
#else
shadowMapAtlas
#endif
#endif
, ld, -l, bias, lightProj, n, index
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#else
2026-02-24 11:44:01 -08:00
if (index == 0) direct *= PCFCube(shadowMapPoint[0],
#ifdef _ShadowMapTransparent
shadowMapPointTransparent[0],
#endif
ld, -l, bias, lightProj, n
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 1) direct *= PCFCube(shadowMapPoint[1],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapPointTransparent[1],
#endif
ld, -l, bias, lightProj, n
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 2) direct *= PCFCube(shadowMapPoint[2],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapPointTransparent[2],
#endif
ld, -l, bias, lightProj, n
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-05-29 21:22:25 +00:00
else if (index == 3) direct *= PCFCube(shadowMapPoint[3],
2026-02-24 11:44:01 -08:00
#ifdef _ShadowMapTransparent
shadowMapPointTransparent[3],
#endif
ld, -l, bias, lightProj, n
#ifdef _ShadowMapTransparent
, transparent
#endif
);
2025-04-07 15:45:04 +00:00
#endif
#endif
}
#endif
2026-08-07 02:04:01 -07:00
l_out = l;
2025-04-07 15:45:04 +00:00
return direct;
}
2026-08-07 02:04:01 -07:00
vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
2025-05-21 01:04:30 +00:00
const vec3 albedo, const float rough, const float spec, const vec3 f0
#ifdef _ShadowMap
2025-05-29 21:22:25 +00:00
, int index, float bias, bool receiveShadow
#ifdef _ShadowMapTransparent
, bool transparent
#endif
2025-05-21 01:04:30 +00:00
#endif
#ifdef _Spot
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
#endif
2026-08-07 02:04:01 -07:00
#ifdef _VoxelShadow
, sampler3D voxels, sampler3D voxelsSDF, float clipmaps[10 * voxelgiClipmapCount], vec2 velocity
#endif
#ifdef _MicroShadowing
, float occ
#endif
#ifdef _SSRS
, sampler2D gbufferD, mat4 invVP, vec3 eye
#endif
2026-07-27 12:10:11 -07:00
#ifdef _ClearCoat
2026-08-07 02:04:01 -07:00
, float clearcoat, float clearcoatRough, float coatIOR, vec3 coatTint, vec3 coatN
2026-07-27 12:10:11 -07:00
#endif
#ifdef _Sheen
, float sheen, float sheenRough, vec3 sheenTint
#endif
#ifdef _Anisotropy
, float anisotropy, float anisoRot, vec3 tangent
#endif
2026-08-07 02:04:01 -07:00
#ifdef _SSS
2026-07-27 12:10:11 -07:00
, float subsurface, vec3 sssColor, vec3 sssRadius, float sssAnisotropy
#endif
#ifdef _Transmission
, float transmission, float transRough, float ior, float thinWall
#endif
2026-08-07 02:04:01 -07:00
) {
vec3 l;
vec3 direct = sampleLightCore(p, n, v, dotNV, lp, lightCol, albedo, rough, spec, f0
#ifdef _ShadowMap
, index, bias, receiveShadow
#ifdef _ShadowMapTransparent
, transparent
#endif
#endif
#ifdef _Spot
, isSpot, spotSize, spotBlend, spotDir, scale, right
#endif
#ifdef _ClearCoat
, clearcoat, clearcoatRough, coatIOR, coatTint, coatN
#endif
#ifdef _Sheen
, sheen, sheenRough, sheenTint
#endif
#ifdef _Anisotropy
, anisotropy, anisoRot, tangent
#endif
#ifdef _SSS
, subsurface, sssColor, sssRadius, sssAnisotropy
#endif
#ifdef _Transmission
, transmission, transRough, ior, thinWall
#endif
, l);
2025-05-21 01:04:30 +00:00
float dotNL = max(0.0, dot(n, l));
2026-08-07 02:04:01 -07:00
#ifdef _MicroShadowing
direct *= clamp(dotNL + 2.0 * occ * occ - 1.0, 0.0, 1.0);
2025-05-21 01:04:30 +00:00
#endif
2026-08-07 02:04:01 -07:00
#ifdef _SSRS
direct *= traceShadowSS(l, p, gbufferD, invVP, eye);
2026-07-27 12:10:11 -07:00
#endif
2026-08-07 02:04:01 -07:00
#ifdef _VoxelShadow
vec3 lightDir = l;
#ifdef _Spot
if (isSpot)
lightDir = spotDir;
2026-07-27 12:10:11 -07:00
#endif
2026-08-07 02:04:01 -07:00
direct *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, lightDir, clipmaps, gl_FragCoord.xy, velocity).r) * voxelgiShad;
2026-07-27 12:10:11 -07:00
#endif
2026-08-07 02:04:01 -07:00
return direct;
}
2025-05-21 01:04:30 +00:00
2026-08-07 02:04:01 -07:00
// Backward-compatible overload for generated shaders that don't pass extended BRDF params
#ifdef _ExtBRDF
vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
const vec3 albedo, const float rough, const float spec, const vec3 f0
2025-05-21 01:04:30 +00:00
#ifdef _ShadowMap
2026-08-07 02:04:01 -07:00
, int index, float bias, bool receiveShadow
#ifdef _ShadowMapTransparent
, bool transparent
2025-05-21 01:04:30 +00:00
#endif
#endif
#ifdef _Spot
2026-08-07 02:04:01 -07:00
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
#endif
#ifdef _VoxelShadow
, sampler3D voxels, sampler3D voxelsSDF, float clipmaps[10 * voxelgiClipmapCount], vec2 velocity
#endif
#ifdef _MicroShadowing
, float occ
#endif
#ifdef _SSRS
, sampler2D gbufferD, mat4 invVP, vec3 eye
#endif
) {
return sampleLight(p, n, v, dotNV, lp, lightCol, albedo, rough, spec, f0
2025-05-21 01:04:30 +00:00
#ifdef _ShadowMap
2026-08-07 02:04:01 -07:00
, index, bias, receiveShadow
#ifdef _ShadowMapTransparent
, transparent
2025-05-21 01:04:30 +00:00
#endif
2026-08-07 02:04:01 -07:00
#endif
#ifdef _Spot
, isSpot, spotSize, spotBlend, spotDir, scale, right
#endif
#ifdef _VoxelShadow
, voxels, voxelsSDF, clipmaps, velocity
#endif
#ifdef _MicroShadowing
, occ
#endif
#ifdef _SSRS
, gbufferD, invVP, eye
#endif
#ifdef _ClearCoat
, 0.0, 0.0, 1.5, vec3(1.0), n
#endif
#ifdef _Sheen
, 0.0, 0.0, vec3(1.0)
#endif
#ifdef _Anisotropy
, 0.0, 0.0, vec3(0.0)
#endif
#ifdef _SSS
, 0.0, vec3(0.0), vec3(0.0), 0.0
#endif
#ifdef _Transmission
, 0.0, 0.0, 1.45, 1.0
#endif
);
}
#endif // _ExtBRDF
2025-05-21 01:04:30 +00:00
2026-08-07 02:04:01 -07:00
#ifdef _VoxelGI
vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
const vec3 albedo, const float rough, const float spec, const vec3 f0
#ifdef _ShadowMap
, int index, float bias, bool receiveShadow
#ifdef _ShadowMapTransparent
, bool transparent
#endif
#endif
#ifdef _Spot
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
#endif
#ifdef _ClearCoat
, float clearcoat, float clearcoatRough, float coatIOR, vec3 coatTint, vec3 coatN
2025-05-21 01:04:30 +00:00
#endif
2026-08-07 02:04:01 -07:00
#ifdef _Sheen
, float sheen, float sheenRough, vec3 sheenTint
#endif
#ifdef _Anisotropy
, float anisotropy, float anisoRot, vec3 tangent
#endif
#ifdef _SSS
, float subsurface, vec3 sssColor, vec3 sssRadius, float sssAnisotropy
#endif
#ifdef _Transmission
, float transmission, float transRough, float ior, float thinWall
#endif
) {
vec3 l;
return sampleLightCore(p, n, v, dotNV, lp, lightCol, albedo, rough, spec, f0
#ifdef _ShadowMap
, index, bias, receiveShadow
#ifdef _ShadowMapTransparent
, transparent
#endif
#endif
#ifdef _Spot
, isSpot, spotSize, spotBlend, spotDir, scale, right
#endif
#ifdef _ClearCoat
, clearcoat, clearcoatRough, coatIOR, coatTint, coatN
#endif
#ifdef _Sheen
, sheen, sheenRough, sheenTint
#endif
#ifdef _Anisotropy
, anisotropy, anisoRot, tangent
#endif
#ifdef _SSS
, subsurface, sssColor, sssRadius, sssAnisotropy
#endif
#ifdef _Transmission
, transmission, transRough, ior, thinWall
#endif
, l);
}
2025-05-21 01:04:30 +00:00
2026-08-07 02:04:01 -07:00
// Backward-compatible overload for generated shaders that don't pass extended BRDF params
#ifdef _ExtBRDF
vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
const vec3 albedo, const float rough, const float spec, const vec3 f0
2025-05-21 01:04:30 +00:00
#ifdef _ShadowMap
2026-08-07 02:04:01 -07:00
, int index, float bias, bool receiveShadow
#ifdef _ShadowMapTransparent
, bool transparent
2025-05-21 01:04:30 +00:00
#endif
2026-08-07 02:04:01 -07:00
#endif
#ifdef _Spot
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
#endif
) {
vec3 l;
return sampleLightCore(p, n, v, dotNV, lp, lightCol, albedo, rough, spec, f0
#ifdef _ShadowMap
, index, bias, receiveShadow
#ifdef _ShadowMapTransparent
, transparent
#endif
#endif
#ifdef _Spot
, isSpot, spotSize, spotBlend, spotDir, scale, right
#endif
#ifdef _ClearCoat
, 0.0, 0.0, 1.5, vec3(1.0), n
#endif
#ifdef _Sheen
, 0.0, 0.0, vec3(1.0)
#endif
#ifdef _Anisotropy
, 0.0, 0.0, vec3(0.0)
#endif
#ifdef _SSS
, 0.0, vec3(0.0), vec3(0.0), 0.0
#endif
#ifdef _Transmission
, 0.0, 0.0, 1.45, 1.0
#endif
, l);
2025-05-21 01:04:30 +00:00
}
2026-08-07 02:04:01 -07:00
#endif // _ExtBRDF
2025-05-21 01:04:30 +00:00
#endif
2025-04-07 15:45:04 +00:00
#endif