feat: House of leaves, details added to wall shader
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
#ifndef ENKI_BILAL_INCLUDED
|
||||
#define ENKI_BILAL_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
|
||||
#include "Assets/_Content/Shaders/Include/Details.hlsl"
|
||||
#include "Assets/_Content/Shaders/Include/Utilities.hlsl"
|
||||
//#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/AmbientOcclusion.hlsl"
|
||||
|
||||
float GetShadow(float3 PositionWS)
|
||||
{
|
||||
float4 shadowCoord = TransformWorldToShadowCoord(PositionWS);
|
||||
Light mainLight = GetMainLight(shadowCoord);
|
||||
|
||||
float shadow = 1 - mainLight.shadowAttenuation;
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS)
|
||||
uint lightsCount = GetAdditionalLightsCount();
|
||||
|
||||
[loop]
|
||||
for (uint i = 0; i < lightsCount; i++)
|
||||
{
|
||||
Light light = GetAdditionalLight(i, PositionWS);
|
||||
shadow = max(shadow, 1 - light.shadowAttenuation);
|
||||
}
|
||||
#endif
|
||||
|
||||
return saturate(shadow);
|
||||
}
|
||||
|
||||
void EnkiBillal_float
|
||||
(
|
||||
float4 Color,
|
||||
UnityTexture2D DetailTexA,
|
||||
UnityTexture2D DetailTexB,
|
||||
float2 ScreenUV,
|
||||
float3 PositionWS,
|
||||
float3 NormalWS,
|
||||
float ProjectionsBlend,
|
||||
float DetailIntensityA,
|
||||
float DetailIntensityB,
|
||||
float DetailSizeA,
|
||||
float DetailSizeB,
|
||||
uint FogUse,
|
||||
float4 FogColor,
|
||||
float FogMin,
|
||||
float FogMax,
|
||||
out float3 Output,
|
||||
out float Alpha
|
||||
)
|
||||
{
|
||||
// Common
|
||||
float depth = length(PositionWS - _WorldSpaceCameraPos.xyz);
|
||||
|
||||
float3 pivotWS = TransformObjectToWorld(float3(0, 0, 0));
|
||||
|
||||
float3 scale = GetScale(pivotWS);
|
||||
|
||||
float3 positionOS = TransformWorldToObject(PositionWS) * scale;
|
||||
float3 normalOS = normalize(TransformWorldToObjectDir(NormalWS));
|
||||
|
||||
//float ao = GetScreenSpaceAmbientOcclusion(ScreenUV).directAmbientOcclusion;
|
||||
|
||||
// Shadow
|
||||
|
||||
float shadow = GetShadow(PositionWS);
|
||||
float shadowAtten = Remap(1, 0, .6, 1, shadow);
|
||||
|
||||
// Detail
|
||||
|
||||
float4 detailA = SampleProjectedDetailLOD
|
||||
(
|
||||
DetailTexA,
|
||||
positionOS,
|
||||
normalOS,
|
||||
ProjectionsBlend,
|
||||
DetailSizeA,
|
||||
depth
|
||||
|
||||
);
|
||||
|
||||
float4 detailB = SampleProjectedDetailLOD
|
||||
(
|
||||
DetailTexB,
|
||||
positionOS,
|
||||
normalOS,
|
||||
ProjectionsBlend,
|
||||
DetailSizeB,
|
||||
depth
|
||||
|
||||
);
|
||||
|
||||
float detailMaskA = smoothstep(0, .8, detailA.a);
|
||||
float detailMaskB = smoothstep(0, .8, detailB.a);
|
||||
|
||||
// Fog
|
||||
|
||||
// Output
|
||||
|
||||
Output = Color.rgb;
|
||||
Output = lerp(Output.rgb, detailA.rgb, detailMaskA * DetailIntensityA);
|
||||
Output = lerp(Output.rgb, detailB.rgb, detailMaskB * DetailIntensityB);
|
||||
|
||||
if (FogUse)
|
||||
{
|
||||
Output = lerp(Output.rgb, FogColor.rgb, smoothstep(FogMin, FogMax, depth) * FogColor.a);
|
||||
}
|
||||
|
||||
Alpha = Color.a;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user