还原水插件
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
|
||||
// Inspired by https://github.com/speps/GX-EncinoWaves
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
// First SIZE constant must match FFT_KERNEL_0_RESOLUTION in FFTCompute.cs
|
||||
#pragma kernel ComputeFFT SIZE=8 PASSES=3 CHANNEL=x TX=8 TY=1 FINAL=0
|
||||
#pragma kernel ComputeFFT SIZE=8 PASSES=3 CHANNEL=y TX=1 TY=8 FINAL=1
|
||||
@@ -24,13 +22,11 @@
|
||||
// Must match CASCADE_COUNT in FFTCompute.cs
|
||||
#define CASCADE_COUNT 16
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
|
||||
Texture2D<float2> _Crest_InputButterfly;
|
||||
#if !FINAL
|
||||
RWTexture2DArray<m_Float2> _Crest_Output1;
|
||||
RWTexture2DArray<m_Float2> _Crest_Output2;
|
||||
RWTexture2DArray<m_Float2> _Crest_Output3;
|
||||
RWTexture2DArray<float2> _Crest_Output1;
|
||||
RWTexture2DArray<float2> _Crest_Output2;
|
||||
RWTexture2DArray<float2> _Crest_Output3;
|
||||
#else
|
||||
Texture2DArray<float2> _Crest_InputH;
|
||||
Texture2DArray<float2> _Crest_InputX;
|
||||
@@ -144,9 +140,9 @@ void ComputeFFT(const uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
const uint coord = id.CHANNEL;
|
||||
#if !FINAL
|
||||
_Crest_IntermediatesH[coord] = conj(_Crest_Output1[id].xy);
|
||||
_Crest_IntermediatesX[coord] = conj(_Crest_Output2[id].xy);
|
||||
_Crest_IntermediatesZ[coord] = conj(_Crest_Output3[id].xy);
|
||||
_Crest_IntermediatesH[coord] = conj(_Crest_Output1[id]);
|
||||
_Crest_IntermediatesX[coord] = conj(_Crest_Output2[id]);
|
||||
_Crest_IntermediatesZ[coord] = conj(_Crest_Output3[id]);
|
||||
#else
|
||||
_Crest_IntermediatesH[coord] = _Crest_InputH[id];
|
||||
_Crest_IntermediatesX[coord] = _Crest_InputX[id];
|
||||
@@ -168,9 +164,9 @@ void ComputeFFT(const uint3 id : SV_DispatchThreadID)
|
||||
const float2 resultZ = pingpong ? _Crest_IntermediatesZ[coord] : _Crest_ScratchZ[coord];
|
||||
|
||||
#if !FINAL
|
||||
_Crest_Output1[id] = m_Float2FromFloat2(resultH);
|
||||
_Crest_Output2[id] = m_Float2FromFloat2(resultX);
|
||||
_Crest_Output3[id] = m_Float2FromFloat2(resultZ);
|
||||
_Crest_Output1[id] = resultH;
|
||||
_Crest_Output2[id] = resultX;
|
||||
_Crest_Output3[id] = resultZ;
|
||||
#else
|
||||
const float sign = ((id.x + id.y) % 2) == 1 ? -1.0 : 1.0;
|
||||
const float3 res = float3(sign * resultX.x, sign * resultH.x, sign * resultZ.x);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Inspired by https://github.com/speps/GX-EncinoWaves
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel SpectrumInitalize
|
||||
#pragma kernel SpectrumUpdate
|
||||
|
||||
@@ -20,8 +18,6 @@
|
||||
#define SPECTRUM_OCTAVE_COUNT 14.0
|
||||
#define SPECTRUM_SMALLEST_WL_POW_2 -4.0
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
|
||||
uint _Crest_Size;
|
||||
float _Crest_WindSpeed;
|
||||
float _Crest_Turbulence;
|
||||
@@ -224,9 +220,9 @@ float _Crest_Time;
|
||||
float _Crest_Chop;
|
||||
|
||||
Texture2DArray<float4> _Crest_Init0;
|
||||
RWTexture2DArray<m_Float2> _Crest_ResultHeight;
|
||||
RWTexture2DArray<m_Float2> _Crest_ResultDisplaceX;
|
||||
RWTexture2DArray<m_Float2> _Crest_ResultDisplaceZ;
|
||||
RWTexture2DArray<float2> _Crest_ResultHeight;
|
||||
RWTexture2DArray<float2> _Crest_ResultDisplaceX;
|
||||
RWTexture2DArray<float2> _Crest_ResultDisplaceZ;
|
||||
|
||||
float2 cmul(float2 lhs, float2 rhs)
|
||||
{
|
||||
@@ -261,7 +257,7 @@ void SpectrumUpdate(uint3 id : SV_DispatchThreadID)
|
||||
const float4 h0 = _Crest_Init0[id];
|
||||
const float2 h = cmul(h0.xy, fwd) + cmul(h0.zw, bkwd);
|
||||
|
||||
_Crest_ResultHeight[id] = m_Float2FromFloat2(h);
|
||||
_Crest_ResultDisplaceX[id] = m_Float2FromFloat2((_Crest_Chop * float2(-h.y * k.x, h.x * k.x) / (kMag + 0.00001f)));
|
||||
_Crest_ResultDisplaceZ[id] = m_Float2FromFloat2((_Crest_Chop * float2(-h.y * k.y, h.x * k.y) / (kMag + 0.00001f)));
|
||||
_Crest_ResultHeight[id] = h;
|
||||
_Crest_ResultDisplaceX[id] = _Crest_Chop * float2(-h.y * k.x, h.x * k.x) / (kMag + 0.00001f);
|
||||
_Crest_ResultDisplaceZ[id] = _Crest_Chop * float2(-h.y * k.y, h.x * k.y) / (kMag + 0.00001f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user