2026-06-09 룸 프로토타입 디자인 (진행중)

This commit is contained in:
skrwns304@gmail.com
2026-06-09 20:53:26 +09:00
parent 3a18351d17
commit 4c955dafc3
3544 changed files with 226503 additions and 17 deletions

View File

@@ -0,0 +1,128 @@
// Stylized Water 3 by Staggart Creations (http://staggart.xyz)
// COPYRIGHT PROTECTED UNDER THE UNITY ASSET STORE EULA (https://unity.com/legal/as-terms)
// • Copying or referencing source code for the production of new asset store, or public, content is strictly prohibited!
// • Uploading this file to a public repository will subject it to an automated DMCA takedown request.
Shader "Hidden/StylizedWater3/HeightProcessor"
{
SubShader
{
Cull Off ZWrite Off ZTest Always
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
ENDHLSL
Pass
{
Name "Height To Normal"
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment frag
float4 _HeightToNormalParams;
//X: Strength
//Y: Channel
//Z: Miplevel
float4 frag (Varyings input) : SV_Target
{
float2 uv = input.texcoord;
float radius = _BlitTexture_TexelSize.x; //1f/width
float strength = _HeightToNormalParams.x * 2.0;
int channel = _HeightToNormalParams.y;
uint mip = _HeightToNormalParams.z;
if(uv.x >= (1-radius) || uv.y >= (1-radius)
|| uv.x <= (radius) || uv.y <= (radius)
) return float4(1,1,1,1);
const float xLeft = (SAMPLE_TEXTURE2D_X_LOD(_BlitTexture, sampler_LinearClamp, float2(uv.xy - float2(radius, 0.0)), mip)[channel]) * strength;
const float xRight = (SAMPLE_TEXTURE2D_X_LOD(_BlitTexture, sampler_LinearClamp, float2(uv.xy + float2(radius, 0.0)), mip)[channel]) * strength;
const float yUp = (SAMPLE_TEXTURE2D_X_LOD(_BlitTexture, sampler_LinearClamp, float2(uv.xy - float2(0.0, radius)), mip)[channel]) * strength;
const float yDown = (SAMPLE_TEXTURE2D_X_LOD(_BlitTexture, sampler_LinearClamp, float2(uv.xy + float2(0.0, radius)), mip)[channel]) * strength;
float xDelta = ((xLeft - xRight) + 1.0) * 0.5f;
float yDelta = ((yUp - yDown) + 1.0) * 0.5f;
float4 normals = float4(xDelta, yDelta, 0.0, 0);
return normals;
}
ENDHLSL
}
Pass
{
Name "Terrain Intersection Mask"
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment frag
#include "../Libraries/Height.hlsl"
#include "../Libraries/Terrain.hlsl"
float _TerrainIntersectionMaskOffset;
float4 frag (Varyings input) : SV_Target
{
float2 uv = input.texcoord;
//Snap texels to terrain height buffer grid to avoid texel swimming
float cellSize = 2;
//uv = floor(uv / cellSize) * cellSize;
float3 positionWS = float3(
_TerrainHeightRenderCoords.x + (uv.x * _TerrainHeightRenderCoords.z),
0,
_TerrainHeightRenderCoords.y + (uv.y * _TerrainHeightRenderCoords.z));
float3 terrainHeightSamplePos = positionWS;
terrainHeightSamplePos.x = floor(positionWS.x / cellSize) * cellSize;
terrainHeightSamplePos.z = floor(positionWS.z / cellSize) * cellSize;
terrainHeightSamplePos = floor(positionWS / cellSize) * (cellSize) + (cellSize * 0.5f);
/*
int resolution = 256.0f;
float3 origin = float3(_TerrainHeightRenderCoords.x, 0, _TerrainHeightRenderCoords.y);
origin = origin * resolution / 2.0f;
float3 roundedOrigin = round(origin);
float3 roundOffset = roundedOrigin - origin;
//Need to fix the pixel swimming. SDF mask renders at a lower resolution than the terrain height prepass
roundOffset = roundOffset * 2.0f / resolution;
positionWS += roundOffset;
*/
float2 waterHeights = SampleWaterHeight(positionWS);
float waterHeight = waterHeights.x;
//Factor in displacement effects?
//waterHeight += waterHeights.g;
if(HasHitWaterSurface(waterHeight) == false) return 0;
//TODO: Implement padding to shift the SDF inwards a bit
waterHeight += _TerrainIntersectionMaskOffset;
const float terrainHeight = SampleTerrainHeight(terrainHeightSamplePos);
float delta = waterHeight - terrainHeight;
//Soft
//float mask = 1-saturate(delta * 32);
//Boolean
float mask = waterHeight < terrainHeight ? 1 : 0;
return float4(mask, 0.0, 0.0, 1.0);
}
ENDHLSL
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a1cfcf2c2c8140c084fb10845093540e
timeCreated: 1718458047
AssetOrigin:
serializedVersion: 1
productId: 287769
packageName: Stylized Water 3
packageVersion: 3.2.7
assetPath: Assets/Stylized Water 3/Shaders/Rendering/HeightProcessor.shader
uploadId: 927372

View File

@@ -0,0 +1,97 @@
Shader "Hidden/StylizedWater3/TerrainHeight"
{
Properties
{
[MainTexture] _BaseMap("Texture", 2D) = "black" {}
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"IgnoreProjector" = "True"
"UniversalMaterialType" = "Unlit"
"RenderPipeline" = "UniversalPipeline"
}
LOD 100
ZWrite Off
Cull Off
Pass
{
Name "Output terrain height"
HLSLPROGRAM
#pragma target 2.0
#pragma vertex UnlitPassVertex
#pragma fragment UnlitPassFragment
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" //UnpackHeightmap
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" //UnpackHeightmap
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float2 uv : TEXCOORD0;
float4 positionCS : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings UnlitPassVertex(Attributes input)
{
Varyings output = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
output.uv = input.uv;
return output;
}
TEXTURE2D_FLOAT(_TerrainHeightmap);
float4 _TerrainHeightRange;
//X: Bottom y-position
//Y: Max height (heightmap scale)
void UnlitPassFragment(Varyings input, out half4 outColor : SV_Target0)
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
half2 uv = input.uv;
float scale = (_TerrainHeightRange.y);
float heightMap = UnpackHeightmap(SAMPLE_TEXTURE2D(_TerrainHeightmap, sampler_LinearRepeat, uv).r);
heightMap *= scale * 1;
float worldHeight = (_TerrainHeightRange.x + heightMap);
//worldHeight = PackHeightmap(worldHeight);
outColor = float4(worldHeight.xxx, 1.0);
}
ENDHLSL
}
}
FallBack "Hidden/Universal Render Pipeline/FallbackError"
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 457f526f44254ef78348e3d0b1cc07ec
timeCreated: 1718291858
AssetOrigin:
serializedVersion: 1
productId: 287769
packageName: Stylized Water 3
packageVersion: 3.2.7
assetPath: Assets/Stylized Water 3/Shaders/Rendering/TerrainHeight.shader
uploadId: 927372