add : unabomber scene

This commit is contained in:
2026-09-28 14:58:25 +02:00
parent e95980d88c
commit 769a75f9bb
137 changed files with 12749 additions and 9 deletions
@@ -57,6 +57,9 @@
{
"m_Id": "b464deebe5304824b318bea0d83b973c"
},
{
"m_Id": "7c1d4e2a9b3f4a6e8d5c0f1b2a3e4d5c"
},
{
"m_Id": "4d1b5e4632d84153a3a55ead37696b1d"
},
@@ -1867,6 +1870,9 @@
{
"m_Id": "b464deebe5304824b318bea0d83b973c"
},
{
"m_Id": "7c1d4e2a9b3f4a6e8d5c0f1b2a3e4d5c"
},
{
"m_Id": "4c76112170fd4b22b30eca3196ea7d9d"
},
@@ -5725,3 +5731,46 @@
]
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
"m_ObjectId": "7c1d4e2a9b3f4a6e8d5c0f1b2a3e4d5c",
"m_Guid": {
"m_GuidSerialized": "3f6b2c1d-8e4a-4b7c-9d2e-1a5f6c7b8d9e"
},
"promotedFromAssetID": "",
"promotedFromCategoryName": "",
"promotedOrdering": -1,
"m_Name": "DetailDistance",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "DetailDistance",
"m_DefaultReferenceName": "_DetailDistance",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_PerRendererData": false,
"m_customAttributes": [],
"m_Value": 18.0,
"m_FloatType": 0,
"m_LiteralFloatMode": false,
"m_RangeValues": {
"x": 0.0,
"y": 1.0
},
"m_SliderType": 0,
"m_SliderPower": 3.0,
"m_EnumType": 0,
"m_CSharpEnumString": "",
"m_EnumNames": [
"Default"
],
"m_EnumValues": [
0
]
}
@@ -106,8 +106,10 @@ void EnkiBillal_float
- 1 near the camera.
- 0 beyond ENKI_DETAIL_MAX_DISTANCE.
*/
float detailFadeStart = ENKI_DETAIL_MAX_DISTANCE - ENKI_DETAIL_FADE_DISTANCE;
float detailFade = 1.0 - smoothstep(detailFadeStart, ENKI_DETAIL_MAX_DISTANCE, depth);
// _DetailDistance is the per-material maximum distance (graph property, default ENKI_DETAIL_MAX_DISTANCE).
float detailMaxDistance = _DetailDistance > 0.0 ? _DetailDistance : ENKI_DETAIL_MAX_DISTANCE;
float detailFadeStart = detailMaxDistance - ENKI_DETAIL_FADE_DISTANCE;
float detailFade = 1.0 - smoothstep(detailFadeStart, detailMaxDistance, depth);
float detailWeightA = DetailIntensityA * detailFade;
float detailWeightB = DetailIntensityB * detailFade;
@@ -0,0 +1,303 @@
// Local URP 17.3 LitInput extension: keep all material properties in the same unconditional UnityPerMaterial buffer across every pass.
#ifndef UNIVERSAL_LIT_INPUT_INCLUDED
#define UNIVERSAL_LIT_INPUT_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ParallaxMapping.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
#if defined(_DETAIL_MULX2) || defined(_DETAIL_SCALED)
#define _DETAIL
#endif
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
CBUFFER_START(UnityPerMaterial)
float4 _BaseMap_ST;
float4 _BaseMap_TexelSize;
float4 _DetailAlbedoMap_ST;
half4 _BaseColor;
half4 _SpecColor;
half4 _EmissionColor;
half _Cutoff;
half _Smoothness;
half _Metallic;
half _BumpScale;
half _Parallax;
half _OcclusionStrength;
half _ClearCoatMask;
half _ClearCoatSmoothness;
half _DetailAlbedoMapScale;
half _DetailNormalMapScale;
half _Surface;
UNITY_TEXTURE_STREAMING_DEBUG_VARS;
// Shared by every server pass, including DOTS/GPU Resident Drawer variants.
float _Curvature;
float _StartDistance;
float _HorizontalInfluence;
float _BendAngle;
float4 _MeadowRegion;
float4 _MeadowEdgeColor;
float _MeadowEdgeFade;
float4x4 _MeadowWorldToLocal;
float _MaskID;
CBUFFER_END
// NOTE: Do not ifdef the properties for dots instancing, but ifdef the actual usage.
// Otherwise you might break CPU-side as property constant-buffer offsets change per variant.
// NOTE: Dots instancing is orthogonal to the constant buffer above.
#ifdef UNITY_DOTS_INSTANCING_ENABLED
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)
UNITY_DOTS_INSTANCED_PROP(float4, _SpecColor)
UNITY_DOTS_INSTANCED_PROP(float4, _EmissionColor)
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff)
UNITY_DOTS_INSTANCED_PROP(float , _Smoothness)
UNITY_DOTS_INSTANCED_PROP(float , _Metallic)
UNITY_DOTS_INSTANCED_PROP(float , _BumpScale)
UNITY_DOTS_INSTANCED_PROP(float , _Parallax)
UNITY_DOTS_INSTANCED_PROP(float , _OcclusionStrength)
UNITY_DOTS_INSTANCED_PROP(float , _ClearCoatMask)
UNITY_DOTS_INSTANCED_PROP(float , _ClearCoatSmoothness)
UNITY_DOTS_INSTANCED_PROP(float , _DetailAlbedoMapScale)
UNITY_DOTS_INSTANCED_PROP(float , _DetailNormalMapScale)
UNITY_DOTS_INSTANCED_PROP(float , _Surface)
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
// Here, we want to avoid overriding a property like e.g. _BaseColor with something like this:
// #define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseColor0)
//
// It would be simpler, but it can cause the compiler to regenerate the property loading code for each use of _BaseColor.
//
// To avoid this, the property loads are cached in some static values at the beginning of the shader.
// The properties such as _BaseColor are then overridden so that it expand directly to the static value like this:
// #define _BaseColor unity_DOTS_Sampled_BaseColor
//
// This simple fix happened to improve GPU performances by ~10% on Meta Quest 2 with URP on some scenes.
static float4 unity_DOTS_Sampled_BaseColor;
static float4 unity_DOTS_Sampled_SpecColor;
static float4 unity_DOTS_Sampled_EmissionColor;
static float unity_DOTS_Sampled_Cutoff;
static float unity_DOTS_Sampled_Smoothness;
static float unity_DOTS_Sampled_Metallic;
static float unity_DOTS_Sampled_BumpScale;
static float unity_DOTS_Sampled_Parallax;
static float unity_DOTS_Sampled_OcclusionStrength;
static float unity_DOTS_Sampled_ClearCoatMask;
static float unity_DOTS_Sampled_ClearCoatSmoothness;
static float unity_DOTS_Sampled_DetailAlbedoMapScale;
static float unity_DOTS_Sampled_DetailNormalMapScale;
static float unity_DOTS_Sampled_Surface;
void SetupDOTSLitMaterialPropertyCaches()
{
unity_DOTS_Sampled_BaseColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseColor);
unity_DOTS_Sampled_SpecColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _SpecColor);
unity_DOTS_Sampled_EmissionColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _EmissionColor);
unity_DOTS_Sampled_Cutoff = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Cutoff);
unity_DOTS_Sampled_Smoothness = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Smoothness);
unity_DOTS_Sampled_Metallic = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Metallic);
unity_DOTS_Sampled_BumpScale = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _BumpScale);
unity_DOTS_Sampled_Parallax = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Parallax);
unity_DOTS_Sampled_OcclusionStrength = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _OcclusionStrength);
unity_DOTS_Sampled_ClearCoatMask = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _ClearCoatMask);
unity_DOTS_Sampled_ClearCoatSmoothness = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _ClearCoatSmoothness);
unity_DOTS_Sampled_DetailAlbedoMapScale = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _DetailAlbedoMapScale);
unity_DOTS_Sampled_DetailNormalMapScale = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _DetailNormalMapScale);
unity_DOTS_Sampled_Surface = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Surface);
}
#undef UNITY_SETUP_DOTS_MATERIAL_PROPERTY_CACHES
#define UNITY_SETUP_DOTS_MATERIAL_PROPERTY_CACHES() SetupDOTSLitMaterialPropertyCaches()
#define _BaseColor unity_DOTS_Sampled_BaseColor
#define _SpecColor unity_DOTS_Sampled_SpecColor
#define _EmissionColor unity_DOTS_Sampled_EmissionColor
#define _Cutoff unity_DOTS_Sampled_Cutoff
#define _Smoothness unity_DOTS_Sampled_Smoothness
#define _Metallic unity_DOTS_Sampled_Metallic
#define _BumpScale unity_DOTS_Sampled_BumpScale
#define _Parallax unity_DOTS_Sampled_Parallax
#define _OcclusionStrength unity_DOTS_Sampled_OcclusionStrength
#define _ClearCoatMask unity_DOTS_Sampled_ClearCoatMask
#define _ClearCoatSmoothness unity_DOTS_Sampled_ClearCoatSmoothness
#define _DetailAlbedoMapScale unity_DOTS_Sampled_DetailAlbedoMapScale
#define _DetailNormalMapScale unity_DOTS_Sampled_DetailNormalMapScale
#define _Surface unity_DOTS_Sampled_Surface
#endif
TEXTURE2D(_ParallaxMap); SAMPLER(sampler_ParallaxMap);
TEXTURE2D(_OcclusionMap); SAMPLER(sampler_OcclusionMap);
TEXTURE2D(_DetailMask); SAMPLER(sampler_DetailMask);
TEXTURE2D(_DetailAlbedoMap); SAMPLER(sampler_DetailAlbedoMap);
TEXTURE2D(_DetailNormalMap); SAMPLER(sampler_DetailNormalMap);
TEXTURE2D(_MetallicGlossMap); SAMPLER(sampler_MetallicGlossMap);
TEXTURE2D(_SpecGlossMap); SAMPLER(sampler_SpecGlossMap);
TEXTURE2D(_ClearCoatMap); SAMPLER(sampler_ClearCoatMap);
#ifdef _SPECULAR_SETUP
#define SAMPLE_METALLICSPECULAR(uv) SAMPLE_TEXTURE2D(_SpecGlossMap, sampler_SpecGlossMap, uv)
#else
#define SAMPLE_METALLICSPECULAR(uv) SAMPLE_TEXTURE2D(_MetallicGlossMap, sampler_MetallicGlossMap, uv)
#endif
half4 SampleMetallicSpecGloss(float2 uv, half albedoAlpha)
{
half4 specGloss;
#ifdef _METALLICSPECGLOSSMAP
specGloss = half4(SAMPLE_METALLICSPECULAR(uv));
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
specGloss.a = albedoAlpha * _Smoothness;
#else
specGloss.a *= _Smoothness;
#endif
#else // _METALLICSPECGLOSSMAP
#if _SPECULAR_SETUP
specGloss.rgb = _SpecColor.rgb;
#else
specGloss.rgb = _Metallic.rrr;
#endif
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
specGloss.a = albedoAlpha * _Smoothness;
#else
specGloss.a = _Smoothness;
#endif
#endif
return specGloss;
}
half SampleOcclusion(float2 uv)
{
#ifdef _OCCLUSIONMAP
half occ = SAMPLE_TEXTURE2D(_OcclusionMap, sampler_OcclusionMap, uv).g;
return LerpWhiteTo(occ, _OcclusionStrength);
#else
return half(1.0);
#endif
}
// Returns clear coat parameters
// .x/.r == mask
// .y/.g == smoothness
half2 SampleClearCoat(float2 uv)
{
#if defined(_CLEARCOAT) || defined(_CLEARCOATMAP)
half2 clearCoatMaskSmoothness = half2(_ClearCoatMask, _ClearCoatSmoothness);
#if defined(_CLEARCOATMAP)
clearCoatMaskSmoothness *= SAMPLE_TEXTURE2D(_ClearCoatMap, sampler_ClearCoatMap, uv).rg;
#endif
return clearCoatMaskSmoothness;
#else
return half2(0.0, 1.0);
#endif // _CLEARCOAT
}
void ApplyPerPixelDisplacement(half3 viewDirTS, inout float2 uv)
{
#if defined(_PARALLAXMAP)
uv += ParallaxMapping(TEXTURE2D_ARGS(_ParallaxMap, sampler_ParallaxMap), viewDirTS, _Parallax, uv);
#endif
}
// Used for scaling detail albedo. Main features:
// - Depending if detailAlbedo brightens or darkens, scale magnifies effect.
// - No effect is applied if detailAlbedo is 0.5.
half3 ScaleDetailAlbedo(half3 detailAlbedo, half scale)
{
// detailAlbedo = detailAlbedo * 2.0h - 1.0h;
// detailAlbedo *= _DetailAlbedoMapScale;
// detailAlbedo = detailAlbedo * 0.5h + 0.5h;
// return detailAlbedo * 2.0f;
// A bit more optimized
return half(2.0) * detailAlbedo * scale - scale + half(1.0);
}
half3 ApplyDetailAlbedo(float2 detailUv, half3 albedo, half detailMask)
{
#if defined(_DETAIL)
half3 detailAlbedo = SAMPLE_TEXTURE2D(_DetailAlbedoMap, sampler_DetailAlbedoMap, detailUv).rgb;
// In order to have same performance as builtin, we do scaling only if scale is not 1.0 (Scaled version has 6 additional instructions)
#if defined(_DETAIL_SCALED)
detailAlbedo = ScaleDetailAlbedo(detailAlbedo, _DetailAlbedoMapScale);
#else
detailAlbedo = half(2.0) * detailAlbedo;
#endif
return albedo * LerpWhiteTo(detailAlbedo, detailMask);
#else
return albedo;
#endif
}
half3 ApplyDetailNormal(float2 detailUv, half3 normalTS, half detailMask)
{
#if defined(_DETAIL)
#if BUMP_SCALE_NOT_SUPPORTED
half3 detailNormalTS = UnpackNormal(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv));
#else
half3 detailNormalTS = UnpackNormalScale(SAMPLE_TEXTURE2D(_DetailNormalMap, sampler_DetailNormalMap, detailUv), _DetailNormalMapScale);
#endif
// With UNITY_NO_DXT5nm unpacked vector is not normalized for BlendNormalRNM
// For visual consistancy we going to do in all cases
detailNormalTS = normalize(detailNormalTS);
return lerp(normalTS, BlendNormalRNM(normalTS, detailNormalTS), detailMask); // todo: detailMask should lerp the angle of the quaternion rotation, not the normals
#else
return normalTS;
#endif
}
inline void InitializeStandardLitSurfaceData(float2 uv, out SurfaceData outSurfaceData)
{
half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff);
half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a);
outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb;
outSurfaceData.albedo = AlphaModulate(outSurfaceData.albedo, outSurfaceData.alpha);
#if _SPECULAR_SETUP
outSurfaceData.metallic = half(1.0);
outSurfaceData.specular = specGloss.rgb;
#else
outSurfaceData.metallic = specGloss.r;
outSurfaceData.specular = half3(0.0, 0.0, 0.0);
#endif
outSurfaceData.smoothness = specGloss.a;
outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
outSurfaceData.occlusion = SampleOcclusion(uv);
outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));
#if defined(_CLEARCOAT) || defined(_CLEARCOATMAP)
half2 clearCoat = SampleClearCoat(uv);
outSurfaceData.clearCoatMask = clearCoat.r;
outSurfaceData.clearCoatSmoothness = clearCoat.g;
#else
outSurfaceData.clearCoatMask = half(0.0);
outSurfaceData.clearCoatSmoothness = half(0.0);
#endif
#if defined(_DETAIL)
half detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).a;
float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw;
outSurfaceData.albedo = ApplyDetailAlbedo(detailUv, outSurfaceData.albedo, detailMask);
outSurfaceData.normalTS = ApplyDetailNormal(detailUv, outSurfaceData.normalTS, detailMask);
#endif
}
#endif // UNIVERSAL_INPUT_SURFACE_PBR_INCLUDED
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 56cb9e4ad60a490c915b3b29e855a15b
@@ -0,0 +1,53 @@
#ifndef CURVED_SERVER_VERTEX_INCLUDED
#define CURVED_SERVER_VERTEX_INCLUDED
#include "CurvedWorld.hlsl"
#include "PortalMeadowRegion.hlsl"
#include "Assets/_Content/Shaders/EnkiBilal/Include/Mask.hlsl"
// Parameters are declared in CurvedServerLitInput.hlsl's UnityPerMaterial cbuffer.
// Portal masks are global matrices written by PortalManager.
float4x4 _Mask0, _Mask1, _Mask2;
void ClipServerRegion(float4 positionCS)
{
float depth = positionCS.z;
#if !UNITY_REVERSED_Z
depth = lerp(UNITY_NEAR_CLIP_VALUE, 1, depth);
#endif
float3 bentWS = ComputeWorldSpacePosition(GetNormalizedScreenSpaceUV(positionCS), depth, UNITY_MATRIX_I_VP);
// The mask is a camera projection, so it uses the displayed (bent) position.
float maskAlpha;
Mask_float(bentWS, _MaskID, _Mask0, _Mask1, _Mask2, maskAlpha);
clip(maskAlpha - 0.5);
if (_MeadowRegion.w <= 0) return;
float3 view = CurvedWorldToFrame(bentWS);
float s, c;
sincos(radians(_BendAngle), s, c);
// This bend is a shear: depth and the perpendicular lateral axis stay unchanged.
float lateral = dot(view.xy, float2(c, s));
float distance = max(0, -view.z - _StartDistance);
view.xy -= float2(s, -c) * (distance * distance + lateral * lateral * _HorizontalInfluence) * _Curvature;
float3 originalWS = CurvedFrameToWorld(view);
ClipMeadowRegion(originalWS, positionCS.xy);
}
void BendServerFrame(inout float3 positionOS, inout float3 normalOS, inout float4 tangentOS)
{
float3 positionVS = CurvedWorldToFrame(TransformObjectToWorld(positionOS));
float3 normalVS = CurvedWorldDirToFrame(TransformObjectToWorldNormal(normalOS));
normalVS = CurvedWorldNormalVS(positionVS, normalVS, _Curvature,
_StartDistance, _HorizontalInfluence, _BendAngle);
normalOS = TransformWorldToObjectNormal(CurvedFrameDirToWorld(normalVS));
// Deform the tangent with the Jacobian to preserve the server's normal map.
float s, c;
sincos(radians(_BendAngle), s, c);
float lateral = dot(positionVS.xy, float2(c, s));
float3 gradient = 2 * _Curvature * float3(_HorizontalInfluence * lateral * float2(c, s),
-max(0.0, -positionVS.z - _StartDistance));
float3 tangentVS = CurvedWorldDirToFrame(TransformObjectToWorldDir(tangentOS.xyz));
tangentVS += float3(s, -c, 0) * dot(gradient, tangentVS);
tangentOS.xyz = TransformWorldToObjectDir(CurvedFrameDirToWorld(tangentVS));
CurvedWorld_float(positionOS, _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle, positionOS);
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9f6e3d5e375c4eac8f2c8141d65b037b
@@ -0,0 +1,65 @@
#ifndef CURVED_WORLD_INCLUDED
#define CURVED_WORLD_INCLUDED
// Bend frame: the camera view by default. PortalMeadow can pin it to a fixed world-space frame
// (e.g. a portal) so the bend stays still while the world is only seen through that portal.
float4x4 _CurvedWorldFrame, _CurvedWorldFrameInv;
float _CurvedWorldFrameFixed;
float3 CurvedWorldToFrame(float3 positionWS)
{
return _CurvedWorldFrameFixed > 0.5 ? mul(_CurvedWorldFrame, float4(positionWS, 1)).xyz : TransformWorldToView(positionWS);
}
float3 CurvedFrameToWorld(float3 positionFS)
{
return mul(_CurvedWorldFrameFixed > 0.5 ? _CurvedWorldFrameInv : UNITY_MATRIX_I_V, float4(positionFS, 1)).xyz;
}
float3 CurvedWorldDirToFrame(float3 directionWS)
{
return mul((float3x3)(_CurvedWorldFrameFixed > 0.5 ? _CurvedWorldFrame : UNITY_MATRIX_V), directionWS);
}
float3 CurvedFrameDirToWorld(float3 directionFS)
{
return mul((float3x3)(_CurvedWorldFrameFixed > 0.5 ? _CurvedWorldFrameInv : UNITY_MATRIX_I_V), directionFS);
}
// Shared by the ground and the grass; also usable as a Shader Graph custom function.
void CurvedWorld_float(float3 PositionOS, float Curvature, float StartDistance,
float HorizontalInfluence, float BendAngle, out float3 Out)
{
#ifdef SHADERGRAPH_PREVIEW
Out = PositionOS;
#else
float3 positionVS = CurvedWorldToFrame(TransformObjectToWorld(PositionOS));
// Rotate the bend frame around the camera's forward axis (degrees).
// 0 = down, 90 = right, 180 = up, 270 = left.
float s, c;
sincos(radians(BendAngle), s, c);
float lateral = dot(positionVS.xy, float2(c, s));
float distanceFromCamera = max(0.0, -positionVS.z - StartDistance);
float bend = (distanceFromCamera * distanceFromCamera
+ lateral * lateral * HorizontalInfluence) * Curvature;
positionVS.xy += float2(s, -c) * bend;
Out = TransformWorldToObject(CurvedFrameToWorld(positionVS));
#endif
}
// Preserve existing Shader Graph custom functions using the original signature.
void CurvedWorld_float(float3 PositionOS, float Curvature, float StartDistance,
float HorizontalInfluence, out float3 Out)
{
CurvedWorld_float(PositionOS, Curvature, StartDistance, HorizontalInfluence, 0, Out);
}
float3 CurvedWorldNormalVS(float3 positionVS, float3 normalVS, float Curvature,
float StartDistance, float HorizontalInfluence, float BendAngle)
{
float s, c;
sincos(radians(BendAngle), s, c);
float lateral = dot(positionVS.xy, float2(c, s));
float3 gradient = 2 * Curvature * float3(HorizontalInfluence * lateral * float2(c, s),
-max(0.0, -positionVS.z - StartDistance));
// Inverse transpose of the bend Jacobian; the gradient is perpendicular to its direction.
return normalVS - gradient * dot(float2(s, -c), normalVS.xy);
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 323e136332b04410aaac77b2b92b8966
@@ -0,0 +1,19 @@
#ifndef PORTAL_MEADOW_REGION_INCLUDED
#define PORTAL_MEADOW_REGION_INCLUDED
// Uniforms are supplied by each shader's UnityPerMaterial buffer.
float MeadowRegionFade(float3 originalWS)
{
if (_MeadowRegion.w <= 0) return 1;
float3 local = mul(_MeadowWorldToLocal, float4(originalWS, 1)).xyz;
float distanceToEdge = _MeadowRegion.w - length(local.xz - _MeadowRegion.xz);
clip(distanceToEdge);
return saturate(distanceToEdge / max(_MeadowEdgeFade, 0.001));
}
float ClipMeadowRegion(float3 originalWS, float2 pixel)
{
float fade = MeadowRegionFade(originalWS);
float threshold = frac(52.9829189 * frac(dot(floor(pixel), float2(0.06711056, 0.00583715))));
clip(fade - threshold);
return fade;
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bb3e643eb7b5481dbb5c97aad043eea4
@@ -0,0 +1,329 @@
// URP 17.3 Lit passes with shared curved-world vertex wrappers. Generated server materials only.
Shader "Unheimlich/Portal Curved Server"
{
Properties
{
// Specular vs Metallic workflow
_WorkflowMode("WorkflowMode", Float) = 1.0
[MainTexture] _BaseMap("Albedo", 2D) = "white" {}
[MainColor] _BaseColor("Color", Color) = (1,1,1,1)
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
_Metallic("Metallic", Range(0.0, 1.0)) = 0.0
_MetallicGlossMap("Metallic", 2D) = "white" {}
_SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
_SpecGlossMap("Specular", 2D) = "white" {}
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}
_Parallax("Scale", Range(0.005, 0.08)) = 0.005
_ParallaxMap("Height Map", 2D) = "black" {}
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion", 2D) = "white" {}
[HDR] _EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
_DetailMask("Detail Mask", 2D) = "white" {}
_DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0
_DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {}
_DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0
[Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {}
// SRP batching compatibility for Clear Coat (Not used in Lit)
[HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0
[HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0
// Blending state
_Surface("__surface", Float) = 0.0
_Blend("__blend", Float) = 0.0
_Cull("__cull", Float) = 2.0
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0
[HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
[HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0
[HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0
[HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0
[HideInInspector] _XRMotionVectorsPass("_XRMotionVectorsPass", Float) = 1.0
[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
[Enum(Default,0,Outside,1,Inside,2)] _MaskID("Portal mask", Float) = 0
// Editmode props
_QueueOffset("Queue offset", Float) = 0.0
// ObsoleteProperties
[HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
[HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
[HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0
[HideInInspector] _Glossiness("Smoothness", Float) = 0.0
[HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0
[HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
[HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
[HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
_Curvature("Curvature (synced from meadow)", Float) = 0.006
_StartDistance("Start distance", Float) = 6
_HorizontalInfluence("Horizontal influence", Float) = 0.12
_BendAngle("Bend angle", Float) = 0
[HideInInspector] _MeadowRegion("Circular region", Vector) = (0,0,0,0)
[HideInInspector] _MeadowEdgeFade("Edge fade", Float) = 4
[HideInInspector] _MeadowEdgeColor("Edge haze", Color) = (0.36,0.43,0.46,1)
}
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline"="UniversalPipeline" "UniversalMaterialType"="Lit" }
Pass
{
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
// no LightMode tag are also rendered by Universal Render Pipeline
Name "ForwardLit"
Tags
{
"LightMode" = "UniversalForwardOnly"
}
// -------------------------------------
// Render State Commands
Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha]
ZWrite[_ZWrite]
Cull[_Cull]
AlphaToMask[_AlphaToMask]
HLSLPROGRAM
#pragma target 3.5
// -------------------------------------
// Shader Stages
#pragma vertex CurvedLitPassVertex
#pragma fragment CurvedLitFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local _PARALLAXMAP
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma shader_feature_local_fragment _EMISSION
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature_local_fragment _OCCLUSIONMAP
#pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
#pragma shader_feature_local_fragment _SPECULAR_SETUP
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _SCREEN_SPACE_IRRADIANCE
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile_fragment _ LIGHTMAP_BICUBIC_SAMPLING
#pragma multi_compile_fragment _ REFLECTION_PROBE_ROTATION
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ USE_LEGACY_LIGHTMAPS
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
#include "Include/CurvedServerLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
#include "Include/CurvedServerVertex.hlsl"
Varyings CurvedLitPassVertex(Attributes input)
{
UNITY_SETUP_INSTANCE_ID(input);
BendServerFrame(input.positionOS.xyz, input.normalOS, input.tangentOS);
return LitPassVertex(input);
}
void CurvedLitFragment(Varyings input, out half4 outColor : SV_Target0
#ifdef _WRITE_RENDERING_LAYERS
, out uint outRenderingLayers : SV_Target1
#endif
)
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
ClipServerRegion(input.positionCS);
LitPassFragment(input, outColor
#ifdef _WRITE_RENDERING_LAYERS
, outRenderingLayers
#endif
);
}
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags
{
"LightMode" = "DepthOnly"
}
// -------------------------------------
// Render State Commands
ZWrite On
ColorMask R
Cull[_Cull]
HLSLPROGRAM
#pragma target 3.5
// -------------------------------------
// Shader Stages
#pragma vertex CurvedDepthOnlyVertex
#pragma fragment CurvedDepthFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ALPHATEST_ON
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ LOD_FADE_CROSSFADE
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include "Include/CurvedServerLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
#include "Include/CurvedServerVertex.hlsl"
Varyings CurvedDepthOnlyVertex(Attributes input)
{
UNITY_SETUP_INSTANCE_ID(input);
CurvedWorld_float(input.position.xyz, _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle, input.position.xyz);
return DepthOnlyVertex(input);
}
half CurvedDepthFragment(Varyings input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
ClipServerRegion(input.positionCS);
return DepthOnlyFragment(input);
}
ENDHLSL
}
Pass
{
Name "DepthNormals"
Tags
{
"LightMode" = "DepthNormalsOnly"
}
// -------------------------------------
// Render State Commands
ZWrite On
Cull[_Cull]
HLSLPROGRAM
#pragma target 3.5
// -------------------------------------
// Shader Stages
#pragma vertex CurvedDepthNormalsVertex
#pragma fragment CurvedNormalsFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local _PARALLAXMAP
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
#pragma shader_feature_local _ALPHATEST_ON
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ LOD_FADE_CROSSFADE
// -------------------------------------
// Universal Pipeline keywords
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include "Include/CurvedServerLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
#include "Include/CurvedServerVertex.hlsl"
Varyings CurvedDepthNormalsVertex(Attributes input)
{
UNITY_SETUP_INSTANCE_ID(input);
BendServerFrame(input.positionOS.xyz, input.normal, input.tangentOS);
return DepthNormalsVertex(input);
}
void CurvedNormalsFragment(Varyings input, out half4 outNormalWS : SV_Target0
#ifdef _WRITE_RENDERING_LAYERS
, out uint outRenderingLayers : SV_Target1
#endif
)
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
ClipServerRegion(input.positionCS);
DepthNormalsFragment(input, outNormalWS
#ifdef _WRITE_RENDERING_LAYERS
, outRenderingLayers
#endif
);
}
ENDHLSL
}
}
Fallback Off
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 33f9a9f0528942b0807e8c885dcaf5b6
+85
View File
@@ -0,0 +1,85 @@
Shader "Unheimlich/Portal Fog"
{
Properties
{
_ColorA ("Fog shadow", Color) = (0.18,0.25,0.28,0.38)
_ColorB ("Fog light", Color) = (0.42,0.52,0.54,0.38)
_DepthAtten ("Depth attenuation", Range(0,1)) = 1
_Density ("Density", Range(0,2)) = 0.8
_Curvature ("Curvature", Float) = 0.006
_StartDistance ("Start distance", Float) = 6
_HorizontalInfluence ("Horizontal influence", Float) = 0.12
_BendAngle ("Bend angle", Float) = 180
[Enum(Default,0,Outside,1,Inside,2)] _MaskID ("Portal mask", Float) = 0
}
SubShader
{
Tags { "RenderPipeline"="UniversalPipeline" "Queue"="Transparent" "RenderType"="Transparent" }
Pass
{
Name "PortalFog"
Tags { "LightMode"="SRPDefaultUnlit" }
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#pragma target 3.5
#pragma multi_compile_instancing
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Assets/_Content/Shaders/Include/CurvedWorld.hlsl"
#include "Assets/_Content/Models/VFX/Fog/ShadersA/Fog.hlsl"
#include "Assets/_Content/Shaders/EnkiBilal/Include/Mask.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _ColorA, _ColorB;
float _DepthAtten, _Density;
float _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle;
float _MaskID;
CBUFFER_END
float4x4 _Mask0, _Mask1, _Mask2;
struct Attributes { float3 positionOS : POSITION; UNITY_VERTEX_INPUT_INSTANCE_ID };
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 originalWS : TEXCOORD0;
float3 originalOS : TEXCOORD1;
float3 bentWS : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings Vert(Attributes input)
{
Varyings output = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
output.originalOS = input.positionOS;
output.originalWS = TransformObjectToWorld(input.positionOS);
float3 bent;
CurvedWorld_float(input.positionOS, _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle, bent);
output.bentWS = TransformObjectToWorld(bent);
output.positionCS = TransformWorldToHClip(output.bentWS);
return output;
}
half4 Frag(Varyings input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
// The mask is a camera projection, so it uses the displayed (bent) position.
float maskAlpha;
Mask_float(input.bentWS, _MaskID, _Mask0, _Mask1, _Mask2, maskAlpha);
clip(maskAlpha - 0.5);
float3 color; float alpha;
float3 scale = float3(length(TransformObjectToWorldDir(float3(1,0,0), false)),
length(TransformObjectToWorldDir(float3(0,1,0), false)),
length(TransformObjectToWorldDir(float3(0,0,1), false)));
// Keep the noise anchored in the world while the curtains follow the player.
Fog_float(_ColorA, _ColorB, _DepthAtten, input.originalWS, input.originalOS,
float3(0,0,0), scale, color, alpha);
return half4(color, saturate(alpha * _Density));
}
ENDHLSL
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: aaa728d8c8934848a67c5aff9ffdb531
+145
View File
@@ -0,0 +1,145 @@
Shader "Unheimlich/Portal Meadow"
{
Properties
{
_RootColor("Grass roots", Color) = (0.055, 0.12, 0.025, 1)
_TipColor("Grass tips", Color) = (0.35, 0.48, 0.12, 1)
_GroundColor("Ground", Color) = (0.08, 0.12, 0.035, 1)
_Curvature("Curvature", Float) = 0.006
_BendAngle("Bend angle (0 down, 180 up)", Range(0,360)) = 0
_StartDistance("Bend start distance", Float) = 6
_HorizontalInfluence("Horizontal influence", Range(0,1)) = 0.12
_WindStrength("Wind strength", Range(0,1)) = 0.22
_WindSpeed("Wind speed", Float) = 1.8
_WindDirection("Wind direction XZ", Vector) = (1,0.4,0,0)
[Enum(Default,0,Outside,1,Inside,2)] _MaskID("Portal mask", Float) = 0
[HideInInspector] _MeadowRegion("Circular region", Vector) = (0,0,0,0)
[HideInInspector] _MeadowEdgeFade("Edge fade", Float) = 4
[HideInInspector] _MeadowEdgeColor("Edge haze", Color) = (0.36,0.43,0.46,1)
}
SubShader
{
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
Cull Off
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Include/CurvedWorld.hlsl"
#include "EnkiBilal/Include/Mask.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _RootColor, _TipColor, _GroundColor, _WindDirection;
float _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle;
float _WindStrength, _WindSpeed, _MaskID;
float4 _MeadowRegion, _MeadowEdgeColor;
float _MeadowEdgeFade;
float4x4 _MeadowWorldToLocal;
CBUFFER_END
#include "Include/PortalMeadowRegion.hlsl"
float4x4 _Mask0, _Mask1, _Mask2;
struct Attributes { float4 positionOS : POSITION; float3 normalOS : NORMAL; float2 uv : TEXCOORD0; float4 color : COLOR; };
struct Varyings { float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; float3 normalWS : TEXCOORD1; float2 uv : TEXCOORD2; float4 color : COLOR; float fog : TEXCOORD3; float3 originalWS : TEXCOORD4; };
Varyings Vert(Attributes input)
{
Varyings output;
float3 p = input.positionOS.xyz;
float3 ws = TransformObjectToWorld(p);
float2 wind = _WindDirection.xy / max(length(_WindDirection.xy), 0.001);
// UV.y is zero at the roots. Color.a is zero for ground vertices.
float wave = sin(dot(ws.xz, float2(0.43,0.31)) - _Time.y * _WindSpeed);
wave += 0.35 * sin(dot(ws.xz, float2(1.7,-0.9)) - _Time.y * _WindSpeed * 2.1 + input.color.g * 6.28);
ws.xz += wind * (0.45 + wave * 0.55) * _WindStrength * input.uv.y * input.uv.y * input.color.a;
p = TransformWorldToObject(ws);
output.originalWS = ws;
float3 positionVS = CurvedWorldToFrame(ws);
float3 normalVS = CurvedWorldDirToFrame(TransformObjectToWorldNormal(input.normalOS));
normalVS = CurvedWorldNormalVS(positionVS, normalVS, _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle);
CurvedWorld_float(p, _Curvature, _StartDistance, _HorizontalInfluence, _BendAngle, p);
output.positionWS = TransformObjectToWorld(p);
output.positionCS = TransformWorldToHClip(output.positionWS);
output.normalWS = normalize(CurvedFrameDirToWorld(normalVS));
output.uv = input.uv;
output.color = input.color;
output.fog = ComputeFogFactor(output.positionCS.z);
return output;
}
void ApplyMask(float3 positionWS)
{
float alpha;
Mask_float(positionWS, _MaskID, _Mask0, _Mask1, _Mask2, alpha);
clip(alpha - 0.5);
}
half4 Frag(Varyings input) : SV_Target
{
float edgeFade = ClipMeadowRegion(input.originalWS, input.positionCS.xy);
ApplyMask(input.positionWS);
half3 grass = lerp(_RootColor.rgb, _TipColor.rgb, saturate(input.uv.y));
half3 albedo = lerp(_GroundColor.rgb, grass, input.color.a) * lerp(0.75, 1.25, input.color.r);
half3 n = normalize(input.normalWS);
// Light layers keep the lights of the other world (e.g. the cave spot) out of PortalB.
uint meshRenderingLayers = GetMeshRenderingLayer();
Light sun = GetMainLight();
half3 illumination = max(SampleSH(half3(0,1,0)), half3(0.32,0.32,0.32));
if (IsMatchingLightLayer(sun.layerMask, meshRenderingLayers))
illumination += sun.color * (0.3 + 0.7 * abs(dot(n, sun.direction))) * sun.distanceAttenuation;
#if defined(_ADDITIONAL_LIGHTS)
uint count = GetAdditionalLightsCount();
for (uint i = 0u; i < count; ++i)
{
Light light = GetAdditionalLight(i, input.positionWS);
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
illumination += light.color * saturate(abs(dot(n, light.direction))) * light.distanceAttenuation;
}
#endif
return half4(lerp(_MeadowEdgeColor.rgb, MixFog(albedo * illumination, input.fog), edgeFade), 1);
}
half4 DepthFrag(Varyings input) : SV_Target { ClipMeadowRegion(input.originalWS, input.positionCS.xy); ApplyMask(input.positionWS); return 0; }
half4 NormalsFrag(Varyings input) : SV_Target
{
ClipMeadowRegion(input.originalWS, input.positionCS.xy);
ApplyMask(input.positionWS);
float3 normalWS = normalize(input.normalWS);
#if defined(_GBUFFER_NORMALS_OCT)
float2 oct = PackNormalOctQuadEncode(normalWS);
return half4(PackFloat2To888(saturate(oct * 0.5 + 0.5)), 0);
#else
return half4(normalWS, 0);
#endif
}
ENDHLSL
Pass
{
Name "Forward"
Tags { "LightMode"="UniversalForwardOnly" }
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#pragma target 3.5
#pragma multi_compile_fog
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _LIGHT_LAYERS
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags { "LightMode"="DepthOnly" }
ColorMask 0
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment DepthFrag
#pragma target 3.5
ENDHLSL
}
Pass
{
Name "DepthNormals"
Tags { "LightMode"="DepthNormalsOnly" }
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment NormalsFrag
#pragma target 3.5
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
ENDHLSL
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2a94804e4785426ba3de2b816874c64b
@@ -0,0 +1,74 @@
Shader "Unheimlich/Portal Sky Dome"
{
Properties
{
_ZenithColor("Zenith", Color) = (0.12, 0.23, 0.38, 1)
_HorizonColor("Horizon", Color) = (0.65, 0.72, 0.68, 1)
_GroundColor("Below horizon", Color) = (0.07, 0.1, 0.075, 1)
_SkyCube("Optional sky cubemap", Cube) = "" {}
[Toggle] _UseCubemap("Use cubemap", Float) = 0
_Exposure("Exposure", Range(0,8)) = 1
_Rotation("Sky rotation", Range(0,360)) = 0
[HideInInspector] _Visibility("Visibility", Float) = 0
[HideInInspector] _InsidePortalB("Inside PortalB", Float) = 0
}
SubShader
{
// Draw after the global skybox, but before ordinary transparent geometry.
// Depth testing lets all opaque scene geometry occlude the sphere.
Tags { "RenderPipeline"="UniversalPipeline" "Queue"="Transparent-100" "RenderType"="Transparent" }
Pass
{
Tags { "LightMode"="SRPDefaultUnlit" }
Cull Front
ZWrite Off
ZTest LEqual
Blend One Zero
HLSLPROGRAM
#pragma target 3.5
#pragma vertex Vert
#pragma fragment Frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"
#include "EnkiBilal/Include/Mask.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _ZenithColor, _HorizonColor, _GroundColor, _SkyCube_HDR;
float _UseCubemap, _Exposure, _Rotation, _Visibility, _InsidePortalB;
CBUFFER_END
TEXTURECUBE(_SkyCube); SAMPLER(sampler_SkyCube);
float4x4 _Mask0, _Mask1, _Mask2;
struct Attributes { float3 positionOS : POSITION; };
struct Varyings { float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; };
Varyings Vert(Attributes input)
{
Varyings output;
output.positionWS = TransformObjectToWorld(input.positionOS);
output.positionCS = TransformWorldToHClip(output.positionWS);
return output;
}
half4 Frag(Varyings input) : SV_Target
{
clip(1.5 - _Visibility);
if (_Visibility > 0.5 && _InsidePortalB < 0.5)
{
// No active portal = hidden outside. Entry explicitly exposes the full sky.
float mask = SampleProjectionMask(input.positionWS, _Mask0)
+ SampleProjectionMask(input.positionWS, _Mask1)
+ SampleProjectionMask(input.positionWS, _Mask2);
clip(mask - 0.5);
}
float3 direction = normalize(input.positionWS - _WorldSpaceCameraPos);
float s, c;
sincos(radians(_Rotation), s, c);
direction.xz = float2(c * direction.x - s * direction.z, s * direction.x + c * direction.z);
half3 color = direction.y >= 0
? lerp(_HorizonColor.rgb, _ZenithColor.rgb, pow(saturate(direction.y), 0.55))
: lerp(_HorizonColor.rgb, _GroundColor.rgb, saturate(-direction.y * 4));
if (_UseCubemap > 0.5)
color = DecodeHDREnvironment(SAMPLE_TEXTURECUBE(_SkyCube, sampler_SkyCube, direction), _SkyCube_HDR);
return half4(color * _Exposure, 1);
}
ENDHLSL
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e317bd1b9476421a82618a58665a4a03
@@ -273,7 +273,15 @@ void EnkiBillalFullscreen_float
float2 uvDistort1 = uv0 + nDistort1 * .025;
float3 sceneColor2 = SampleSceneColor(uvDistort0);
sceneColor2 = lerp(sceneColor2, SampleSceneColor(uvDistort1), .3);
float3 cDistort = saturate(sceneColor2 - sceneColor) * distortAtten;
// Carry pigment from the closest surface instead of adding a positive RGB
// difference (which turns dark silhouettes against the sky into white fringes).
float3 bleedColor = SampleSceneColor(uv0);
float bleedDepth = depthMeters;
float sampleDepth0 = LinearEyeDepth(SampleSceneDepth(uvDistort0), _ZBufferParams);
float sampleDepth1 = LinearEyeDepth(SampleSceneDepth(uvDistort1), _ZBufferParams);
if (sampleDepth0 < bleedDepth) { bleedColor = SampleSceneColor(uvDistort0); bleedDepth = sampleDepth0; }
if (sampleDepth1 < bleedDepth) { bleedColor = SampleSceneColor(uvDistort1); }
float bleedWeight = saturate(length(sceneColor2 - sceneColor) * 1.5) * distortAtten;
// OUTLINE
@@ -317,7 +325,7 @@ void EnkiBillalFullscreen_float
//c = lerp(c, sceneColor2, (greyscale + smoothstep(5, 35, depthMeters) * .8) * .5);
//c += sceneColor2 * greyscale * .5;
c = lerp(c, outlineColor, outline);
c += cDistort * 1.5;
c = lerp(c, bleedColor, bleedWeight);
//c = ((c + 1) * (sceneColor2 + 0));
//c = smoothstep(-.1, 0, np2);
//c = greyscale;
@@ -379,4 +387,4 @@ void EnkiBillalFullscreen_float
//Output = hatchMask;
//Output = dot(normalWS, viewDir);
}
#endif
#endif
@@ -414,7 +414,8 @@ Shader "Custom/ToonBilal"
// Blow out highlights — bright zones go nearly white like Bilal
float highlightMask = smoothstep(_HighlightThreshold, 1.0, lum);
toonCol = lerp(toonCol, toonCol * _HighlightBoost, highlightMask);
toonCol = min(toonCol, 1.2); // allow slight overexposure
// Limit intensity uniformly: channel-wise clipping washed saturated highlights white.
toonCol *= min(1.0, 1.2 / max(0.0001, max(toonCol.r, max(toonCol.g, toonCol.b))));
// ── Gouache in dark areas
toonCol = ApplyGouache(toonCol, worldPos, lum, curvature);