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
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,8 @@
|
|||||||
#define HOUSE_OF_LEAVES_INCLUDED
|
#define HOUSE_OF_LEAVES_INCLUDED
|
||||||
|
|
||||||
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
|
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
|
||||||
|
#include "Assets/_Content/Shaders/Include/Details.hlsl"
|
||||||
|
#include "Assets/_Content/Shaders/Include/Utilities.hlsl"
|
||||||
|
|
||||||
float Hash(float n)
|
float Hash(float n)
|
||||||
{
|
{
|
||||||
@@ -106,7 +108,6 @@ void Sand_float
|
|||||||
|
|
||||||
// Output
|
// Output
|
||||||
|
|
||||||
|
|
||||||
Position = PositionWS;
|
Position = PositionWS;
|
||||||
Position.y += sandMask;
|
Position.y += sandMask;
|
||||||
Position.y *= 1 + saturate(pow(abs(PositionWS.x * .5), 3)) * lerp(-.2, 1.4, sandMask);
|
Position.y *= 1 + saturate(pow(abs(PositionWS.x * .5), 3)) * lerp(-.2, 1.4, sandMask);
|
||||||
@@ -130,6 +131,13 @@ void HouseOfLeaves_float
|
|||||||
float4 ColorE,
|
float4 ColorE,
|
||||||
float3 PositionWS,
|
float3 PositionWS,
|
||||||
float3 NormalWS,
|
float3 NormalWS,
|
||||||
|
float ProjectionsBlend,
|
||||||
|
UnityTexture2D DetailTexA,
|
||||||
|
UnityTexture2D DetailTexB,
|
||||||
|
float DetailIntensityA,
|
||||||
|
float DetailIntensityB,
|
||||||
|
float DetailSizeA,
|
||||||
|
float DetailSizeB,
|
||||||
out float3 Output
|
out float3 Output
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -195,7 +203,36 @@ void HouseOfLeaves_float
|
|||||||
bandFrac
|
bandFrac
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
|
||||||
|
float4 detailA = SampleProjectedDetailLOD
|
||||||
|
(
|
||||||
|
DetailTexA,
|
||||||
|
PositionWS,
|
||||||
|
NormalWS,
|
||||||
|
ProjectionsBlend,
|
||||||
|
DetailSizeA,
|
||||||
|
depth
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
float4 detailB = SampleProjectedDetailLOD
|
||||||
|
(
|
||||||
|
DetailTexB,
|
||||||
|
PositionWS,
|
||||||
|
NormalWS,
|
||||||
|
ProjectionsBlend,
|
||||||
|
DetailSizeB,
|
||||||
|
depth
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
float detailMaskA = smoothstep(0, .8, detailA.a);
|
||||||
|
float detailMaskB = smoothstep(0, .8, detailB.a);
|
||||||
|
|
||||||
Output = col;
|
Output = col;
|
||||||
|
Output = lerp(Output.rgb, detailA.rgb, detailMaskA * DetailIntensityA);
|
||||||
|
Output = lerp(Output.rgb, detailB.rgb, detailMaskB * DetailIntensityB);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+4
-132
@@ -1,55 +1,7 @@
|
|||||||
#ifndef ENKI_BILAL_INCLUDED
|
#ifndef DETAILS_HLSL
|
||||||
#define ENKI_BILAL_INCLUDED
|
#define DETAILS_HLSL
|
||||||
|
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
#include "Assets/_Content/Shaders/Include/Utilities.hlsl"
|
||||||
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
|
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/AmbientOcclusion.hlsl"
|
|
||||||
|
|
||||||
float2 RotateUV(float2 UV, float2 Pivot, float Angle)
|
|
||||||
{
|
|
||||||
float s = sin(Angle);
|
|
||||||
float c = cos(Angle);
|
|
||||||
|
|
||||||
UV -= Pivot;
|
|
||||||
|
|
||||||
float2 rotated = float2(
|
|
||||||
UV.x * c - UV.y * s,
|
|
||||||
UV.x * s + UV.y * c
|
|
||||||
);
|
|
||||||
|
|
||||||
return rotated + Pivot;
|
|
||||||
}
|
|
||||||
|
|
||||||
float3 GetScale(float3 PivotWS)
|
|
||||||
{
|
|
||||||
return float3
|
|
||||||
(
|
|
||||||
length(TransformObjectToWorld(float3(1, 0, 0)) - PivotWS),
|
|
||||||
length(TransformObjectToWorld(float3(0, 1, 0)) - PivotWS),
|
|
||||||
length(TransformObjectToWorld(float3(0, 0, 1)) - PivotWS)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 GetDetailLOD
|
void GetDetailLOD
|
||||||
(
|
(
|
||||||
@@ -195,6 +147,7 @@ ProjectionData GetProjections
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float4 SampleProjectedDetailLOD
|
float4 SampleProjectedDetailLOD
|
||||||
(
|
(
|
||||||
UnityTexture2D DetailTex,
|
UnityTexture2D DetailTex,
|
||||||
@@ -258,85 +211,4 @@ float4 SampleProjectedDetailLOD
|
|||||||
return detail / max(totalMask, 1e-5);
|
return detail / max(totalMask, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
#endif
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cd2ecc5897b2b6d4aa8221fe1a514dff
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef UTILITIES_HLSL
|
||||||
|
#define UTILITIES_HLSL
|
||||||
|
|
||||||
|
float2 RotateUV(float2 UV, float2 Pivot, float Angle)
|
||||||
|
{
|
||||||
|
float s = sin(Angle);
|
||||||
|
float c = cos(Angle);
|
||||||
|
|
||||||
|
UV -= Pivot;
|
||||||
|
|
||||||
|
float2 rotated = float2(
|
||||||
|
UV.x * c - UV.y * s,
|
||||||
|
UV.x * s + UV.y * c
|
||||||
|
);
|
||||||
|
|
||||||
|
return rotated + Pivot;
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 GetScale(float3 PivotWS)
|
||||||
|
{
|
||||||
|
return float3
|
||||||
|
(
|
||||||
|
length(TransformObjectToWorld(float3(1, 0, 0)) - PivotWS),
|
||||||
|
length(TransformObjectToWorld(float3(0, 1, 0)) - PivotWS),
|
||||||
|
length(TransformObjectToWorld(float3(0, 0, 1)) - PivotWS)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dffae08c547f6154c9741b4f205a314a
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user