This commit is contained in:
SoulliesOfficial
2025-12-17 04:19:38 -05:00
parent 7c1cb7e8e1
commit d15957c719
4315 changed files with 8260710 additions and 2940 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fc0f31b7f348e264f80547d5f6a192d0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,71 @@
#pragma once
#include "Includes/Features/Lighting/Equations/Skin.hlsl"
half3 mDirDiffFac;
// Note: Disney diffuse must be multiply by diffuseAlbedo / PI. This is done outside of this function.
half DisneyDiffuseBuiltin(half NdotV, half NdotL, half LdotH, half perceptualRoughness)
{
half fd90 = 0.5 + 2 * LdotH * LdotH * perceptualRoughness;
// Two schlick fresnel term
half lightScatter = (1 + (fd90 - 1) * SafePow5(1 - NdotL));
half viewScatter = (1 + (fd90 - 1) * SafePow5(1 - NdotV));
return lightScatter * viewScatter;
}
half3 GetDirectDiffuse(PerLightData lightData)
{
half3 dirDiff = 0;
#if SUBTRACTIVE
{
// Entering here indicates Mixed Lighting is active
// In SUBTRACTIVE mode, static objects don't receive Mixed Lighting
// No need to check LIGHTMAP_ON since SUBTRACTIVE is only enabled for static objects
return 0;
}
#endif
half3 diffCoeff = lightData.NdotL;
#if _DIRECT_DIFFUSE_DEFAULT
{
diffCoeff = _DirectDiffuseShadowLift + (1 - _DirectDiffuseShadowLift) * diffCoeff;
// Lambert
dirDiff = diffCoeff * lightData.attenuationColor;
// DisneyDiffuse is not much different from Lambert;
// lower brightness when view direction is balanced with the surface
// half disneyDiffuse = DisneyDiffuseBuiltin(mNdotV, lightData.NdotL, lightData.LdotH, mPBRData.perceptualRoughness);
// todo: Don't adjust shadow brightness for fill lights
// dirDiff = disneyDiffuse * diffCoeff * lightData.attenuationColor;
}
#elif _DIRECT_DIFFUSE_RAMP
{
// half3 rampTexCol = tex2D(_DirectDiffuseRamp, lightData.rampUV);
half2 rampUV = lightData.rampUV;
rampUV.x = _DirectDiffuseShadowLift + (1 - _DirectDiffuseShadowLift) * rampUV.x;
half3 rampTexCol = tex2D(_DirectDiffuseRamp, rampUV);
diffCoeff = TryGammaToLinear(rampTexCol);
dirDiff = diffCoeff * lightData.attenuationColor;
}
#elif _DIRECT_DIFFUSE_SKIN
{
dirDiff = GetDirectDiffuse_Skin(lightData);
}
#endif
#if _SHADOW_COLOR_ON
{
half3 brightness = diffCoeff * lightData.finalAttenuation;
dirDiff = lerp(_ShadowColor, lightData.color, brightness);
dirDiff = lerp(_ShadowColor, dirDiff, lightData.shadowAttenuation);
}
#endif
return dirDiff;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 7528fd27fcab7c148a160ff14f75179f
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Components/DirectDiffuse.hlsl
uploadId: 820558

View File

@@ -0,0 +1,30 @@
#pragma once
half3 mDirSpecFac;
#include "Includes/Features/Lighting/Equations/GGX.hlsl"
#include "Includes/Features/Lighting/Equations/Hair.hlsl"
#include "Includes/Features/Lighting/Equations/Aniso.hlsl"
half3 GetDirectSpecular(PerLightData lightData)
{
half3 dirSpec = 0;
half3 radiance = lightData.NdotL * lightData.attenuationColor;
#if _DIRECT_SPECULAR_DEFAULT
{
dirSpec = CalculateGGX(lightData.NdotL, mNdotV, lightData.NdotH, lightData.LdotH, mPBRData.roughness, mPBRData.roughness2, mPBRData.specularColor) * radiance;
}
#elif _DIRECT_SPECULAR_HAIR
{
dirSpec = CalculateHair(lightData) * lightData.attenuationColor;
}
#elif _DIRECT_SPECULAR_ANISO
{
dirSpec = CalculateAniso(lightData) * radiance;
}
#endif
return (dirSpec + CalculateGGXFromDirectionalLightmap()) * _DirectSpecularColor;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: cccbc1fa6fd87a94d886bd768ac16d7b
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Components/DirectSpecular.hlsl
uploadId: 820558

View File

@@ -0,0 +1,22 @@
#pragma once
#include "Includes/Features/Lighting/Equations/Skin.hlsl"
half3 mIndirectDiffuseFac;
half3 GetIndirectDiffuse_DirAmbient(half3 ambient, half3 normalWS)
{
return ambient * lerp(_IndirectDiffuseParams.y, _IndirectDiffuseParams.x, normalWS.y * 0.5 + 0.5);
}
half3 GetIndirectDiffuse(half3 ambientColor, half3 normalWS, half3 lightDirection)
{
#if _INDIRECT_DIFFUSE_ON
{
half3 indirDiffFac = GetIndirectDiffuse_DirAmbient(ambientColor, normalWS);
return ApplySkinIndirectDiffuse(indirDiffFac);
}
#endif
return 0;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 7a118d16091629c478a62c85a32bca56
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Components/IndirectDiffuse.hlsl
uploadId: 820558

View File

@@ -0,0 +1,33 @@
#pragma once
half3 mIndirSpecFac;
// Reduce ambient light reflection intensity in dark areas
half GetIndirectSpecularAttentuation(GI gi, PerLightData lightData)
{
#if !_MAIN_LIGHT_SHADOWS
{
return 1;
}
#endif
#if LIGHTMAP_ON
{
half indirectSpecularAttentuation = LumByMax(gi.indirectDiffuse); // [0, 1]
indirectSpecularAttentuation = 0.5 * indirectSpecularAttentuation + 0.5; // [0.5, 1]
return indirectSpecularAttentuation;
}
#else
{
half indirectSpecularAttentuation = (1 - lightData.NdotL_Raw); // [0, 2]
indirectSpecularAttentuation = 0.25 * indirectSpecularAttentuation + 0.5; // [0.5, 1]
return lerp(indirectSpecularAttentuation, 1, lightData.finalAttenuation);
}
#endif
}
half3 GetIndirectSpecular(GI gi, PerLightData lightData)
{
return gi.indirectSpecular * GetIndirectSpecularAttentuation(gi, lightData);
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: dba773e7291e31a4c8d5af3d8d11f185
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Components/IndirectSpecular.hlsl
uploadId: 820558

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 900040eb3eced764b9ce459a16f52cee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
#pragma once
struct FlowData
{
full3 forward;
half3 up;
half3 right;
half shift;
};
FlowData CreateFlowData(sampler2D flowMap)
{
FlowData data;
half3 encodeColor = tex2D(flowMap, mVaryings.uv);
half3 decodeColor = 2 * (encodeColor - 0.5);
half3 forwardTS = half3(-decodeColor.x, decodeColor.y, 0);
data.forward.x = dot(mTangentToWorld[0], forwardTS);
data.forward.y = dot(mTangentToWorld[1], forwardTS);
data.forward.z = dot(mTangentToWorld[2], forwardTS);
// data.forward = normalize(data.forward);
data.up = mVaryings.normalWS;
data.right = cross(data.up, data.forward);
data.shift = decodeColor.z;
return data;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 2ad899d796eb07047acc7c9627b35ee3
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Data/FlowData.hlsl
uploadId: 820558

View File

@@ -0,0 +1,39 @@
#pragma once
struct PBRData
{
half metallic;
half smoothness;
half occlusion;
half perceptualRoughness;
half roughness;
half roughness2;
half reflectivity;
half oneMinusReflectivity;
half3 diffuseColor;
half3 specularColor;
};
PBRData mPBRData;
void InitPBRData()
{
mPBRData = (PBRData)0;
mPBRData.metallic = GetMaskValue(_MetallicSrc) * _Metallic;
mPBRData.smoothness = GetMaskValue(_SmoothnessSrc) * _Smoothness;
mPBRData.occlusion = LerpWhiteTo(GetMaskValue(_OcclusionSrc), _OcclusionStrength);
mPBRData.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(mPBRData.smoothness); // 1 - smoothness
mPBRData.roughness = max(PerceptualRoughnessToRoughness(mPBRData.perceptualRoughness), HALF_MIN_SQRT);
mPBRData.roughness2 = max(mPBRData.roughness * mPBRData.roughness, HALF_MIN);
mPBRData.oneMinusReflectivity = OneMinusReflectivityMetallic(mPBRData.metallic);
mPBRData.reflectivity = 1 - mPBRData.oneMinusReflectivity;
mPBRData.diffuseColor = mAlbedoColor * mPBRData.oneMinusReflectivity;
mPBRData.specularColor = lerp(kDielectricSpec, mAlbedoColor, mPBRData.metallic);
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 3550146bd15213142a8799d028eb54fe
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Data/PBRData.hlsl
uploadId: 820558

View File

@@ -0,0 +1,59 @@
#pragma once
#include "Includes/Features/Misc/SSAO.hlsl"
struct PerLightData
{
half3 color;
half3 direction;
half distanceAttenuation;
half shadowAttenuation;
half finalAttenuation;
half3 attenuationColor;
half3 halfDirection;
half NdotL_Raw;
half NdotL_Remap01;
half NdotL;
half NdotH;
half LdotV;
half LdotH;
half VdotH;
half2 rampUV;
};
PerLightData CreatePerLightData(Light light)
{
PerLightData lightData = (PerLightData)0;
lightData.color = light.color;
lightData.direction = light.direction;
lightData.halfDirection = normalize(lightData.direction + mViewDirWS);
lightData.NdotL_Raw = dot(mNormalWS, lightData.direction);
lightData.NdotL_Remap01 = lightData.NdotL_Raw * 0.5 + 0.5;
lightData.NdotL = saturate(lightData.NdotL_Raw);
lightData.NdotH = max(0, dot(mNormalWS, lightData.halfDirection));
lightData.LdotV = max(0, dot(mNormalWS, mViewDirWS));
lightData.LdotH = max(0, dot(lightData.direction, lightData.halfDirection));
lightData.VdotH = max(0, dot(mViewDirWS, lightData.halfDirection));
lightData.rampUV = half2(lightData.NdotL_Remap01, 0.5);
lightData.distanceAttenuation = light.distanceAttenuation;
lightData.shadowAttenuation = light.shadowAttenuation * mSSAOFactor.directAmbientOcclusion;
// lightData.shadowAttenuation += lightData.NdotL_Remap01 * 0.25; // Effect works for characters but not good for flat buildings
lightData.finalAttenuation = lightData.shadowAttenuation * lightData.distanceAttenuation;
lightData.attenuationColor = lightData.color * lightData.finalAttenuation;
return lightData;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 1aa49bd5328c5f44cb02cb7ca5249eb6
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Data/PreLightData.hlsl
uploadId: 820558

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 608e95f324a5d7e46a51e77d52a65fc4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
#pragma once
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl"
#include "Includes/Features/Lighting/Data/FlowData.hlsl"
// Anisotropic GGX [Burley 2012, "Physically-Based Shading at Disney"]
full D_Aniso_GGX(full x, full y, full nh, full3 h, full3 t, full3 b)
{
// This equation easily causes issues in Editor GLES
// Cannot accurately infer data precision of intermediate operations after compilation
// Therefore, use full precision throughout and avoid division by zero
// When flow direction is reversed, the effect remains the same
// No difference even if flow direction is drawn incorrectly
// x = rough in tangent dir
// y = rough in bitangent dir
full x2 = x * x;
full y2 = y * y;
full x4 = x2 * x2;
full y4 = y2 * y2;
full x2y2 = x2 * y2;
full th = dot(t, h);
full bh = dot(b, h);
full th2 = th * th;
full bh2 = bh * bh;
full nh2 = nh * nh;
x4 = max(1e-5, x4);
y4 = max(1e-5, y4);
full f = th2 / x4 + bh2 / y4 + nh2;
full d = x2y2 * f * f;
d = max(1e-5, d);
full res = 1.0 / d;
return res;
}
half3 CalculateAniso(PerLightData lightData)
{
FlowData flowData = CreateFlowData(_DirectSpecularFlowMap);
half3 t = mTangentWS;
half3 b = mBitangentWS;
#if _DIRECT_SPECULAR_FLOWMAP
{
t = flowData.forward;
b = flowData.right;
}
#endif
half2 r = _DirectSpecularAnisoParams.yz * mPBRData.perceptualRoughness;
half3 d = D_Aniso_GGX(r.x, r.y, lightData.NdotH, lightData.halfDirection, t, b); // return d;
// half3 d = D_GGXAniso(r.x, r.y, lightData.NdotH, t, b);
half3 f = F_Schlick(mPBRData.specularColor, lightData.VdotH); // return d * f;
half intensity = _DirectSpecularAnisoParams.x;
return intensity * d * f;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 242de01915568aa4cb196de18eea62b7
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Equations/Aniso.hlsl
uploadId: 820558

View File

@@ -0,0 +1,65 @@
#pragma once
// GGX Distribution multiplied by combined approximation of Visibility and Fresnel
// BRDFspec = (D * V * F) / 4.0
// D = roughness^2 / ( NoH^2 * (roughness^2 - 1) + 1 )^2
// V * F = 1.0 / ( LoH^2 * (roughness + 0.5) )
// See "Optimizing PBR for Mobile" from Siggraph 2015 moving mobile graphics course
// https://community.arm.com/events/1155
// Final BRDFspec = roughness^2 / ( NoH^2 * (roughness^2 - 1) + 1 )^2 * (LoH^2 * (roughness + 0.5) * 4.0)
half URPDirectBRDFSpecular(half nl, half nv, half nh, half lh, half rough, half rough2)
{
half nh2 = nh * nh;
half lh2 = lh * lh;
half rough2MinusOne = rough2 - 1;
half normalizationTerm = (rough * 4 + 2);
half d = (nh2 * rough2MinusOne + 1.00001f);
half specularTerm = rough2 / ((d * d) * max(0.1h, lh2) * normalizationTerm);
// On platforms where half actually means something, the denominator has a risk of overflow
// clamp below was added specifically to "fix" that, but dx compiler (we convert bytecode to metal/gles)
// sees that specularTerm have only non-negative terms, so it skips max(0,..) in clamp (leaving only min(100,...))
#if REAL_IS_HALF
specularTerm = specularTerm - HALF_MIN;
// Update: Conservative bump from 100.0 to 1000.0 to better match the full float specular look.
// Roughly 65504.0 / 32*2 == 1023.5,
// or HALF_MAX / ((mobile) MAX_VISIBLE_LIGHTS * 2),
// to reserve half of the per light range for specular and half for diffuse + indirect + emissive.
specularTerm = clamp(specularTerm, 0.0, 1000.0); // Prevent FP16 overflow on mobiles
#endif
return specularTerm;
}
half3 CalculateGGX(half nl, half nv, half nh, half lh, half rough, half rough2, half3 specCol)
{
return URPDirectBRDFSpecular(nl, nv, nh, lh, rough, rough2) * specCol;
}
half3 CalculateGGXFromDirectionalLightmap()
{
half3 dirSpec = 0;
/*
#if DIRLIGHTMAP_COMBINED
{
DirectionalLightmapData dirlightmapData = GetDirectionalLightmapData(mVaryings.ambientOrLightmapUV.xy);
half3 lightCol = dirlightmapData.col;
half3 lightDirection = dirlightmapData.dir;
half3 halfDirection = normalize(lightDirection + mViewDirWS);
half NdotL = max(0, dot(mNormalWS, lightDirection));
half NdotH = max(0, dot(mNormalWS, halfDirection));
half LdotH = max(0, dot(lightDirection, halfDirection));
if _DIRECT_SPECULAR_DEFAULT
{
dirSpec = CalculateGGX(NdotL, mNdotV, NdotH, LdotH, mPBRData.roughness, mPBRData.roughness2, mPBRData.specularColor) * NdotL * lightColor;
}
#endif
}
#endif
*/
return dirSpec;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 9c97e51242013944e88085e33bf6cffc
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Equations/GGX.hlsl
uploadId: 820558

View File

@@ -0,0 +1,47 @@
#pragma once
#include "Includes/Features/Lighting/Data/FlowData.hlsl"
half3 Scheuermann(half3 n, half3 h, half3 hairDir, half shift, half exp)
{
half3 t = normalize(hairDir + shift * n); // shift dir
half dotTH = dot(t, h);
// Original version, standard 1 - cos²
// half sinTH = sqrt(1 - dotTH * dotTH);
// half kajiya_kay_1 = pow(sinTH, exp);
// Optimized version, one less sqrt; halving exp gives the same result, adjusted by material parameters
half sinTH = 1 - dotTH * dotTH;
// [-1, 1] mapped to [0, 1], backlight and front light will be brighter
half atten = smoothstep(-1, 0, dotTH);
atten = 1;
half kajiya_kay_1 = pow(sinTH, exp) * atten;
// return kajiya_kay_1;
// Scheuermann is double-layer specular
half kajiya_kay_2 = pow(sinTH, exp / 2) * atten;
return kajiya_kay_1 + kajiya_kay_2;
}
half3 CalculateHair(PerLightData lightData)
{
half3 flowForward = mTangentWS;
half3 flowUp = mNormalWS;
half exp = _DirectSpecularHairParams.y;
half shift = _DirectSpecularHairParams.z;
#if _DIRECT_SPECULAR_FLOWMAP
{
FlowData flowData = CreateFlowData(_DirectSpecularFlowMap);
flowForward = flowData.forward;
flowUp = flowData.up;
shift += _DirectSpecularHairParams.w * flowData.shift;
}
#endif
half3 spec = Scheuermann(flowUp, lightData.halfDirection, flowForward, shift, exp);
half intensity = _DirectSpecularHairParams.x;
return intensity * spec * mPBRData.specularColor;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: e6d7ca475a7c7a3418a2c3daaf3974a5
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Equations/Hair.hlsl
uploadId: 820558

View File

@@ -0,0 +1,73 @@
#pragma once
// Skin lighting model
half mSkinCurvature;
half mIsSkin;
#define SKIN_BRIGHTNESS _DirectDiffuseSkinParams.x
#define SKIN_LIGHTCOLOR_INFLUENCE (1 - _DirectDiffuseSkinParams.y)
#define SKIN_SHADOW_STRENGTH _DirectDiffuseSkinParams.z
#define SKIN_RIM_POWER _DirectDiffuseSkinParams.w
void InitSkin()
{
mSkinCurvature = GetMaskValue(_DirectDiffuseSkinCurvatureSrc) * _DirectDiffuseSkinCurvatureScale;
mIsSkin = ceil(mSkinCurvature - 0.05); // compressed formats have noise, so don't use 0.01
}
half3 ApplySkinIndirectDiffuse(half3 indirectDiffuseFac)
{
#if _DIRECT_DIFFUSE_SKIN
{
// Desaturate indirect diffuse light for Skin areas to reduce ambient color influence
half3 skinIndirectDiffuseFac = LumByMax(indirectDiffuseFac);
indirectDiffuseFac = lerp(indirectDiffuseFac, skinIndirectDiffuseFac, SKIN_LIGHTCOLOR_INFLUENCE * mIsSkin);
}
#endif
return indirectDiffuseFac;
}
half ComputeSkinLUTx(PerLightData lightData)
{
half skinShadowStrength = lerp(1, lightData.shadowAttenuation, SKIN_SHADOW_STRENGTH);
half lutX = lightData.NdotL_Remap01 * skinShadowStrength; // Can blend with diffuse reflection
lutX *= pow(mNdotV, SKIN_RIM_POWER);
return lutX;
}
half3 GetSkinLUTColor(half lutX)
{
// Current lightmap has obvious shadow gradient
// Limit minimum lutX value for better backlight quality
lutX = max(1e-1, lutX);
// SkinLUT use gamma for better visual quality, make sure sRGB toogle is off.
half2 uv = half2(lutX, mSkinCurvature);
half3 texCol = tex2D(_DirectDiffuseSkinLUT, uv); //
return texCol * lerp(1, SKIN_BRIGHTNESS, mIsSkin);
}
half3 GetSkinAttenLightColor(PerLightData lightData, half lutX)
{
// Only distance attenuation needed here; Skin shadows are expressed through Lut
half3 skinAttenLightColor = lightData.color * lightData.distanceAttenuation;
return lerp(skinAttenLightColor, LumByMax(skinAttenLightColor), SKIN_LIGHTCOLOR_INFLUENCE);
}
half3 GetDirectDiffuse_Skin(PerLightData lightData, half lutX)
{
half3 lutCol = GetSkinLUTColor(lutX);
half3 rawAttenLightColor = lightData.attenuationColor;
half3 skinAttenLightColor = GetSkinAttenLightColor(lightData, lutX);
half3 attenLightColor = lerp(rawAttenLightColor, skinAttenLightColor, mIsSkin);
return saturate(lutCol * attenLightColor); // saturate to prevent Skin areas from overexposing
}
half3 GetDirectDiffuse_Skin(PerLightData lightData)
{
half lutX = ComputeSkinLUTx(lightData);
lutX = (1 - _DirectDiffuseShadowLift) * lutX + _DirectDiffuseShadowLift;
return GetDirectDiffuse_Skin(lightData, lutX);
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 5346361212108744c848a65a5bb0b006
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Equations/Skin.hlsl
uploadId: 820558

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ba5240bb51961a64ba7c9b6414c98f9d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
#pragma once
struct DirectionalLightmapData
{
half3 direction;
half3 color;
};
DirectionalLightmapData GetDirectionalLightmapData(half2 lightmapUV)
{
DirectionalLightmapData data = (DirectionalLightmapData)0;
#if DIRLIGHTMAP_COMBINED
{
half4 lightmapColor = UNITY_SAMPLE_DETAIL_MAPD(unity_Lightmap, lightmapUV);
half3 bakedColor = DecodeLightmap(lightmapColor);
#if 0 && UNITY_COLORSPACE_GAMMA
bakedColor *= bakedColor;
#endif
half4 dirTexcolor = UNITY_SAMPLE_DETAIL_MAPD_SAMPLER(unity_LightmapInd, unity_Lightmap, lightmapUV);
// The length of the direction vector is the light's "directionality",
// i.e. 1 for all light coming from this direction, lower values for more spread out.
half3 lightDirection = 2 * dirTexcolor - 1;
half directionality = max(0.001, length(lightDirection)); // Percentage of light shining in this direction
lightDirection /= directionality; // Direction map data is not a unit vector, needs to be normalized
half3 lightcolor = bakedColor * directionality; // Multiply by the percentage of light shining in this direction
// half3 lightcolor = bakedColor * 1; // Brighter if not using directionality
// lightcolor /= dirTexcolor.w; // Correction factor, use division, will be brighter
data.direction = lightDirection;
data.color = lightcoloror;
}
#endif
return data;
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 92cc75dba3cca0c43a8f328160599bb7
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/GI/DirectionalLightmap.hlsl
uploadId: 820558

View File

@@ -0,0 +1,69 @@
#pragma once
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl"
struct GI
{
half3 indirectDiffuse;
half3 indirectSpecular;
};
GI mGI;
half4 mShadowMask;
void GetGI_IndirectDiffuse()
{
half3 lightmapOrSH = SAMPLE_GI(mVaryings.lightmapUV, mVaryings.vertexSH, mNormalWS);
mGI.indirectDiffuse = lightmapOrSH * mPBRData.occlusion;
}
half3 FresnelSchlickRoughness(half oneMinusNdotV, half3 f0, float gloss)
{
return f0 + (max(gloss, f0) - f0) * SafePow4(oneMinusNdotV);
}
// TODO: Switch to HDR Decode method to support LDR environment reflection maps
void GetGI_IndirectSpecular()
{
half3 glossyEnvRefl = 0;
half3 reflDirWS = reflect(-mViewDirWS, mNormalWS);
#if _INDIRECT_SPECULAR_DEFAULT
{
glossyEnvRefl = GlossyEnvironmentReflection(reflDirWS, mPBRData.perceptualRoughness, mPBRData.occlusion);
}
#else
{
#if _INDIRECT_SPECULAR_CUSTOM
{
half mip = PerceptualRoughnessToMipmapLevel(mPBRData.perceptualRoughness);
half4 encodedIrradiance = texCUBElod(_IndirectSpecularCustomCubeMap, full4(reflDirWS, mip));
glossyEnvRefl = DecodeHDREnvironment(encodedIrradiance, _IndirectSpecularCustomCubeMap_HDR);
}
#elif _INDIRECT_SPECULAR_CONSTANT_COLOR
{
glossyEnvRefl = _GlossyEnvironmentColor;
}
#endif
glossyEnvRefl = TryGammaToLinear(glossyEnvRefl) * mPBRData.occlusion;
}
#endif
glossyEnvRefl *= _IndirectSpecularParams.x; // reflection scale
half fresnelTerm = SafePow4(mOneMinusNdotV) * _IndirectSpecularParams.y; // fresnel scale
half grazingTerm = saturate(mPBRData.smoothness + mPBRData.reflectivity);
half surfaceReduction = 1.0 / (mPBRData.roughness2 + 1.0);
half3 envBRDFSpec = surfaceReduction * lerp(mPBRData.specularColor, grazingTerm, fresnelTerm);
mGI.indirectSpecular = glossyEnvRefl * envBRDFSpec;
mGI.indirectSpecular = max(mGI.indirectSpecular, 0); // Artists might set values below zero causing issues; need restriction
}
void GetGI()
{
mGI = (GI)0;
GetGI_IndirectDiffuse();
GetGI_IndirectSpecular();
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: d885a5e297b29384b9ab826d5062424b
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/GI/GI.hlsl
uploadId: 820558

View File

@@ -0,0 +1,62 @@
#pragma once
#include "Includes/Features/Lighting/Data/PBRData.hlsl"
#include "Includes/Features/Lighting/Data/PreLightData.hlsl"
#include "Includes/Features/Lighting/GI/GI.hlsl"
#include "Includes/Features/Lighting/Components/IndirectDiffuse.hlsl"
#include "Includes/Features/Lighting/Components/DirectDiffuse.hlsl"
#include "Includes/Features/Lighting/Components/DirectSpecular.hlsl"
#include "Includes/Features/Lighting/Components/IndirectSpecular.hlsl"
PerLightData mMainLightData;
half3 GetDirectLighting(PerLightData lightData)
{
half3 dirDiff = GetDirectDiffuse(lightData) * mPBRData.diffuseColor;
half3 dirSpec = GetDirectSpecular(lightData);
return dirDiff + dirSpec;
}
half3 GetLightingColor()
{
InitPBRData();
#if LIGHTMAP_ON
{
mShadowMask = SAMPLE_SHADOWMASK(mVaryings.lightmapUV);
}
#endif
InitSSAOFactor();
full4 shadowCoord = TransformWorldToShadowCoord(mVaryings.positionWS);
Light mainLight = GetMainLight(shadowCoord, mVaryings.positionWS, mShadowMask);
mMainLightData = CreatePerLightData(mainLight);
GetGI();
InitSkin();
mIndirectDiffuseFac = GetIndirectDiffuse(mGI.indirectDiffuse, mNormalWS, mMainLightData.direction);
mDirDiffFac = GetDirectDiffuse(mMainLightData);
half3 diff = (mIndirectDiffuseFac + mDirDiffFac) * mPBRData.diffuseColor;
mDirSpecFac = GetDirectSpecular(mMainLightData);
mIndirSpecFac = GetIndirectSpecular(mGI, mMainLightData);
half3 spec = (mIndirSpecFac + mDirSpecFac) / lerp(1, mAlpha, _PreserveSpecular);
half3 lightingColor = diff + spec;
#ifdef _ADDITIONAL_LIGHTS
{
uint pixelLightCount = GetAdditionalLightsCount();
for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex)
{
Light additionalLight = GetAdditionalLight(lightIndex, mVaryings.positionWS, mShadowMask);
PerLightData additionalLightData = CreatePerLightData(additionalLight);
lightingColor.xyz += GetDirectLighting(additionalLightData);
}
}
#endif
return lightingColor;
}

View File

@@ -0,0 +1,16 @@
fileFormatVersion: 2
guid: 1982e61fe1b1e9e4884a54f36050d3fb
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/LitPlus/Shaders/Includes/Features/Lighting/Lighting.hlsl
uploadId: 820558