Merge branch 'main' of http://212.24.110.183:3000/IPSEITY/Unheimlich_POC
This commit is contained in:
@@ -155,16 +155,27 @@ float BipyramidHatch(float3 PositionWS, float3 NormalWS, float Angle, float Scal
|
|||||||
float SampleSceneDepthMeter(float2 UV)
|
float SampleSceneDepthMeter(float2 UV)
|
||||||
{
|
{
|
||||||
float rawDepth = SampleSceneDepth(UV);
|
float rawDepth = SampleSceneDepth(UV);
|
||||||
return (LinearEyeDepth(rawDepth, _ZBufferParams));
|
#if UNITY_REVERSED_Z
|
||||||
|
bool isSky = rawDepth <= 0.00001;
|
||||||
|
rawDepth = isSky ? 0.0 : rawDepth;
|
||||||
|
#else
|
||||||
|
bool isSky = rawDepth >= 0.99999;
|
||||||
|
rawDepth = isSky ? 1.0 : rawDepth;
|
||||||
|
#endif
|
||||||
|
float depthMeters = isSky
|
||||||
|
? _ProjectionParams.z
|
||||||
|
: LinearEyeDepth(rawDepth, _ZBufferParams);
|
||||||
|
|
||||||
|
return depthMeters;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ComputeOutline(float2 UV, float2 Thickness, float3 NormalWS, float3 ViewDir, float DepthMeters, float DepthAtten)
|
float ComputeOutline(float2 UV, float2 Thickness, float3 NormalWS, float3 ViewDir, float DepthAtten)
|
||||||
{
|
{
|
||||||
// DEPTH OUTLINE
|
// DEPTH OUTLINE
|
||||||
|
|
||||||
float2 o = Thickness * (1 - DepthAtten);
|
float2 o = Thickness * (1 - DepthAtten);
|
||||||
|
|
||||||
float d0 = DepthMeters;
|
float d0 = SampleSceneDepthMeter(UV);
|
||||||
float d1 = SampleSceneDepthMeter(UV + float2(-o.x,0));
|
float d1 = SampleSceneDepthMeter(UV + float2(-o.x,0));
|
||||||
float d2 = SampleSceneDepthMeter(UV + float2( o.x,0));
|
float d2 = SampleSceneDepthMeter(UV + float2( o.x,0));
|
||||||
float d3 = SampleSceneDepthMeter(UV + float2(0,-o.y));
|
float d3 = SampleSceneDepthMeter(UV + float2(0,-o.y));
|
||||||
@@ -186,7 +197,7 @@ float ComputeOutline(float2 UV, float2 Thickness, float3 NormalWS, float3 ViewDi
|
|||||||
|
|
||||||
o *= .5;
|
o *= .5;
|
||||||
|
|
||||||
float3 n0 = NormalWS;
|
float3 n0 = normalize(SampleSceneNormals(UV));
|
||||||
float3 n1 = normalize(SampleSceneNormals(UV + float2(-o.x, 0)));
|
float3 n1 = normalize(SampleSceneNormals(UV + float2(-o.x, 0)));
|
||||||
float3 n2 = normalize(SampleSceneNormals(UV + float2( o.x, 0)));
|
float3 n2 = normalize(SampleSceneNormals(UV + float2( o.x, 0)));
|
||||||
float3 n3 = normalize(SampleSceneNormals(UV + float2(0, -o.y)));
|
float3 n3 = normalize(SampleSceneNormals(UV + float2(0, -o.y)));
|
||||||
@@ -194,7 +205,7 @@ float ComputeOutline(float2 UV, float2 Thickness, float3 NormalWS, float3 ViewDi
|
|||||||
|
|
||||||
float normalDiff = distance(n0, n1) + distance(n0, n2) + distance(n0, n3) + distance(n0, n4);
|
float normalDiff = distance(n0, n1) + distance(n0, n2) + distance(n0, n3) + distance(n0, n4);
|
||||||
|
|
||||||
float normalOutline = smoothstep(0.6, 0.8, normalDiff) * smoothstep(10, 3, DepthMeters);
|
float normalOutline = smoothstep(0.6, 0.8, normalDiff) * smoothstep(10, 3, d0);
|
||||||
|
|
||||||
return saturate(depthOutline + normalOutline * .8);
|
return saturate(depthOutline + normalOutline * .8);
|
||||||
//return depthOutline;
|
//return depthOutline;
|
||||||
@@ -210,10 +221,17 @@ void EnkiBillalFullscreen_float
|
|||||||
|
|
||||||
float3 sceneColor = SampleSceneColor(UV);
|
float3 sceneColor = SampleSceneColor(UV);
|
||||||
|
|
||||||
|
|
||||||
float rawDepth = SampleSceneDepth(UV);
|
float rawDepth = SampleSceneDepth(UV);
|
||||||
float depthMeters = LinearEyeDepth(rawDepth, _ZBufferParams);
|
#if UNITY_REVERSED_Z
|
||||||
//float depth01 = Linear01Depth(rawDepth, _ZBufferParams);
|
bool isSky = rawDepth <= 0.00001;
|
||||||
|
rawDepth = isSky ? 0.0 : rawDepth;
|
||||||
|
#else
|
||||||
|
bool isSky = rawDepth >= 0.99999;
|
||||||
|
rawDepth = isSky ? 1.0 : rawDepth;
|
||||||
|
#endif
|
||||||
|
float depthMeters = isSky
|
||||||
|
? _ProjectionParams.z
|
||||||
|
: LinearEyeDepth(rawDepth, _ZBufferParams);
|
||||||
|
|
||||||
float depthForReconstruct = rawDepth;
|
float depthForReconstruct = rawDepth;
|
||||||
#if !UNITY_REVERSED_Z
|
#if !UNITY_REVERSED_Z
|
||||||
@@ -222,17 +240,22 @@ void EnkiBillalFullscreen_float
|
|||||||
|
|
||||||
float3 positionWS = ComputeWorldSpacePosition(UV, depthForReconstruct, UNITY_MATRIX_I_VP);
|
float3 positionWS = ComputeWorldSpacePosition(UV, depthForReconstruct, UNITY_MATRIX_I_VP);
|
||||||
|
|
||||||
float np1 = PerlinNoise3D(positionWS, 10) * 2 - 1;
|
float noiseAtten = pow(smoothstep(1, 10, depthMeters), 2);
|
||||||
float2 uv1 = UV + np1 * lerp(.002, .004, pow(smoothstep(1, 20, depthMeters), 2));
|
|
||||||
|
float np1 = PerlinNoise3D(positionWS + floor(_Time.y * 8) * 3.7, 15) * 2 - 1;
|
||||||
|
float2 uv1 = UV + np1 * lerp(.001, .002, noiseAtten);
|
||||||
|
|
||||||
float3 normalWS = normalize(SampleSceneNormals(UV));
|
float3 normalWS = normalize(SampleSceneNormals(UV));
|
||||||
float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - positionWS);
|
float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - positionWS);
|
||||||
|
|
||||||
float np2 = RidgedNoise3D(positionWS + np1 * .2, 1, 2, 2, .5) * 1.4 - 1;
|
float np2 = FBMNoise3D(positionWS + np1 * .05, .5, 1, 2, .5) * 2 - 1;
|
||||||
float2 uv2 = uv1 + np2 * lerp(0, .04, pow(smoothstep(1, 20, depthMeters), 2));
|
float2 uv2 = uv1 + np2 * .0;
|
||||||
|
|
||||||
float3 sceneColor2 = SampleSceneColor(uv2);
|
float3 sceneColor2 = SampleSceneColor(uv2);
|
||||||
|
|
||||||
|
float np3 = PerlinNoise3D(positionWS + floor(_Time.y * 5) * 6.1, 1.5);
|
||||||
|
float2 uv3 = uv2 + np3 * lerp(.005, .008, noiseAtten);
|
||||||
|
|
||||||
// OUTLINE
|
// OUTLINE
|
||||||
|
|
||||||
float outlineAtten = smoothstep(3, 30, depthMeters);
|
float outlineAtten = smoothstep(3, 30, depthMeters);
|
||||||
@@ -248,15 +271,17 @@ void EnkiBillalFullscreen_float
|
|||||||
|
|
||||||
float n1 = PerlinNoise3D(positionWS + i * 3.3 + n0, 1.7 + 1 * .2 + t);
|
float n1 = PerlinNoise3D(positionWS + i * 3.3 + n0, 1.7 + 1 * .2 + t);
|
||||||
|
|
||||||
float2 thickness = lerp(0, 20, pow(n1, 2));
|
float2 thickness = lerp(0, 15 + i * 2, pow(n1, 2));
|
||||||
thickness = thickness * _ScreenParams.y / 1080 / _ScreenParams.xy;
|
thickness = thickness * _ScreenParams.y / 1080 / _ScreenParams.xy;
|
||||||
|
|
||||||
float2 uv = UV;
|
float2 uv = uv3;
|
||||||
|
if (i == 1)
|
||||||
|
uv = uv1;
|
||||||
|
|
||||||
outline += ComputeOutline(uv, thickness, normalWS, viewDir, depthMeters, outlineAtten);
|
outline += ComputeOutline(uv, thickness, normalWS, viewDir, outlineAtten) * (i * .5 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
outline /= 2;
|
outline /= 2.5;
|
||||||
|
|
||||||
// COLOR (WIP)
|
// COLOR (WIP)
|
||||||
|
|
||||||
@@ -274,7 +299,7 @@ void EnkiBillalFullscreen_float
|
|||||||
//c = greyscale;
|
//c = greyscale;
|
||||||
|
|
||||||
/*float3 pWS = positionWS; //scaledPositionOS;
|
/*float3 pWS = positionWS; //scaledPositionOS;
|
||||||
float n0 = PerlinNoise3D(pWS, 2);
|
//float n0 = PerlinNoise3D(pWS, 2);
|
||||||
float distort = WorldDistort(pWS + n0 * .2, normalWS, 1, .1);
|
float distort = WorldDistort(pWS + n0 * .2, normalWS, 1, .1);
|
||||||
float3 p = pWS + n0 * 2 + distort * smoothstep(.5, .7, n0) * .06;
|
float3 p = pWS + n0 * 2 + distort * smoothstep(.5, .7, n0) * .06;
|
||||||
float grad = 0;
|
float grad = 0;
|
||||||
@@ -298,7 +323,7 @@ void EnkiBillalFullscreen_float
|
|||||||
|
|
||||||
// SHADOW
|
// SHADOW
|
||||||
|
|
||||||
/*float sceneLuminance = dot(sceneColor, float3(.299, .587, .114));
|
float sceneLuminance = dot(sceneColor, float3(.299, .587, .114));
|
||||||
|
|
||||||
float hatchAtten = smoothstep(15, 1, depthMeters);
|
float hatchAtten = smoothstep(15, 1, depthMeters);
|
||||||
|
|
||||||
@@ -306,8 +331,7 @@ void EnkiBillalFullscreen_float
|
|||||||
|
|
||||||
float hatchWidth = lerp(.025, .18, hatchMask) * hatchAtten;
|
float hatchWidth = lerp(.025, .18, hatchMask) * hatchAtten;
|
||||||
|
|
||||||
float hatchNoise = PerlinNoise3D(positionWS, .85);
|
float hatchLayerMask = smoothstep(.35, .75, np3 + n0);
|
||||||
float hatchLayerMask = smoothstep(.35, .75, hatchNoise);
|
|
||||||
|
|
||||||
float hatch0 = BipyramidHatch(positionWS, normalWS, .35, 28, hatchWidth);
|
float hatch0 = BipyramidHatch(positionWS, normalWS, .35, 28, hatchWidth);
|
||||||
float hatch1 = BipyramidHatch(positionWS + 13.7, normalWS, 1.75, 21, hatchWidth * .85);
|
float hatch1 = BipyramidHatch(positionWS + 13.7, normalWS, 1.75, 21, hatchWidth * .85);
|
||||||
@@ -320,12 +344,12 @@ void EnkiBillalFullscreen_float
|
|||||||
|
|
||||||
float hatches = saturate(hatchesA + hatchesB * hatchLayerMask * .55);
|
float hatches = saturate(hatchesA + hatchesB * hatchLayerMask * .55);
|
||||||
|
|
||||||
c = lerp(c, float3(0, 0, 0), hatches * hatchMask * .3);*/
|
c = lerp(c, float3(0, 0, 0), hatches * hatchMask * .3);
|
||||||
|
|
||||||
// OUTPUT
|
// OUTPUT
|
||||||
|
|
||||||
Output = c;
|
Output = c;
|
||||||
Output = sceneColor;
|
//Output = sceneColor;
|
||||||
//Output = hatchMask;
|
//Output = hatchMask;
|
||||||
//Output = dot(normalWS, viewDir);
|
//Output = dot(normalWS, viewDir);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user