2026-06-09 룸 프로토타입 디자인 (진행중)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// 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.
|
||||
|
||||
#define THREAD_GROUPS 64
|
||||
#pragma kernel SampleOffsets
|
||||
|
||||
#include "..\Libraries\Height.hlsl"
|
||||
|
||||
//Input
|
||||
StructuredBuffer<float3> positions;
|
||||
uint sampleCount; //Length of 'positions' array
|
||||
|
||||
//Output
|
||||
RWStructuredBuffer<float> offsets;
|
||||
|
||||
[numthreads(THREAD_GROUPS,1,1)]
|
||||
void SampleOffsets(uint id : SV_DispatchThreadID)
|
||||
{
|
||||
//Early out when no more positions are left to process
|
||||
//Important for the Metal API, as it avoids accessing unbound array elements!
|
||||
if(id > sampleCount) return;
|
||||
|
||||
const uint index = (uint)(id);
|
||||
|
||||
//Input positions to sample at
|
||||
const float3 positionWS = positions[index];
|
||||
|
||||
//Position, relative to rendering bounds (normalized 0-1)
|
||||
const float2 uv = WorldToHeightUV(positionWS);
|
||||
|
||||
//Texel value at coordinates
|
||||
float2 heights = SampleHeightBuffer(uv).rg;
|
||||
|
||||
//Output
|
||||
offsets[index] = heights.r + heights.g;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 768e0c28dfdbc6b429fd59518fa03f2d
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 4
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 287769
|
||||
packageName: Stylized Water 3
|
||||
packageVersion: 3.2.7
|
||||
assetPath: Assets/Stylized Water 3/Shaders/Compute/HeightSampler.compute
|
||||
uploadId: 927372
|
||||
51
Assets/Stylized Water 3/Shaders/Compute/SDF.compute
Normal file
51
Assets/Stylized Water 3/Shaders/Compute/SDF.compute
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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.
|
||||
|
||||
#pragma kernel CSMain
|
||||
|
||||
Texture2D<float4> _InputTexture;
|
||||
RWTexture2D<float> _OutputTexture;
|
||||
|
||||
float _MaxDistance;
|
||||
|
||||
uint2 _TextureSize;
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void CSMain (uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id.x >= _TextureSize.x || id.y >= _TextureSize.y) return;
|
||||
|
||||
float pixel = _InputTexture[id.xy].r;
|
||||
bool isBackground = pixel.r > 0.5; //Assume white is the background
|
||||
|
||||
float minDistance = _MaxDistance;
|
||||
|
||||
//Reduced search window based on _MaxDistance
|
||||
int searchRadius = int(_MaxDistance);
|
||||
int2 start = max(int2(0, 0), int2(id.xy) - searchRadius);
|
||||
int2 end = min(_TextureSize, int2(id.xy) + searchRadius + 1);
|
||||
|
||||
for (int y = start.y; y < end.y; y++)
|
||||
{
|
||||
for (int x = start.x; x < end.x; x++)
|
||||
{
|
||||
float sample = _InputTexture[int2(x, y)].r;
|
||||
bool sampleIsBackground = sample.r > 0.5;
|
||||
|
||||
if(sampleIsBackground == isBackground || sample < pixel) continue;
|
||||
//if (sampleIsBackground != isBackground && sample > pixel)
|
||||
{
|
||||
float2 diff = float2(x, y) - id.xy;
|
||||
float distance = length(diff);
|
||||
if (distance < minDistance)
|
||||
{
|
||||
minDistance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_OutputTexture[id.xy] = 1-(minDistance / _MaxDistance); // Normalize
|
||||
}
|
||||
10
Assets/Stylized Water 3/Shaders/Compute/SDF.compute.meta
Normal file
10
Assets/Stylized Water 3/Shaders/Compute/SDF.compute.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ed6fcf8ffe9497086e18655ba389d39
|
||||
timeCreated: 1718465479
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 287769
|
||||
packageName: Stylized Water 3
|
||||
packageVersion: 3.2.7
|
||||
assetPath: Assets/Stylized Water 3/Shaders/Compute/SDF.compute
|
||||
uploadId: 927372
|
||||
Reference in New Issue
Block a user