Last active
September 29, 2022 22:52
-
-
Save billw2012/568ad7cd6c804a27467cc4d6208439a7 to your computer and use it in GitHub Desktop.
Remove point light attenuation in URP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Drop this into a custom Shader Graph node, then output it to Unlit master Color and Alpha. | |
// If you want the point light to also behave as a directional light then instead of passing | |
// the Vertex world position pass the last column of the model Transformation matrix (Transformation node) | |
// instead. | |
// NOTE: this function removes GI feature entirely, as it wasn't necessary for my purpose. | |
void PBR_ZeroAttenuation_half(half3 Albedo, | |
half Metallic, | |
half3 Specular, | |
half Smoothness, | |
half3 Emission, | |
half Alpha, | |
float3 PositionWS, | |
half3 NormalWS, | |
half3 ViewDirectionWS, | |
out half4 fragOut) | |
{ | |
#ifdef UNIVERSAL_LIGHTING_INCLUDED | |
BRDFData brdfData; | |
InitializeBRDFData(Albedo, Metallic, Specular, Smoothness, Alpha, brdfData); | |
Light mainLight = GetMainLight(); | |
half3 color = LightingPhysicallyBased(brdfData, mainLight, NormalWS, ViewDirectionWS); | |
uint pixelLightCount = GetAdditionalLightsCount(); | |
for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex) | |
{ | |
Light light = GetAdditionalLight(lightIndex, PositionWS); | |
color += LightingPhysicallyBased(brdfData, light.color, light.direction, 1, NormalWS, ViewDirectionWS); | |
} | |
color += Emission; | |
fragOut = half4(color, Alpha); | |
#else | |
fragOut = half4 (1, 1, 1, 1); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment