- Added RpcFunction.cs with init static functions - Extend BlendShaderController for getting needed data - Added CrpcExtensions for server api
51 lines
1.7 KiB
Plaintext
51 lines
1.7 KiB
Plaintext
// Each #kernel tells which function to compile; you can have many kernels
|
|
#pragma kernel CSMain
|
|
#pragma kernel CSBlendDepths
|
|
|
|
// Create a RenderTexture with enableRandomWrite flag and set it
|
|
// with cs.SetTexture
|
|
RWTexture2D<float4> Camera1;
|
|
RWTexture2D<float4> Camera2;
|
|
RWTexture2D<float4> Result;
|
|
RWStructuredBuffer<float> MonoChannelResult;
|
|
|
|
StructuredBuffer<float> Depths1;
|
|
StructuredBuffer<float> Depths2;
|
|
RWStructuredBuffer<float> MergedDepths;
|
|
|
|
float ResX;
|
|
float Offset;
|
|
float FarClipPlane;
|
|
|
|
[numthreads(8,8,1)]
|
|
void CSMain (uint3 id : SV_DispatchThreadID)
|
|
{
|
|
int2 idxy1 = int2(clamp(id.x + Offset, 0, ResX), id.y);
|
|
int2 idxy2 = int2(clamp(id.x - Offset, 0, ResX), id.y);
|
|
float3 col1 = Camera1[idxy1].xyz;
|
|
float3 col2 = Camera1[idxy2].xyz;
|
|
float diffFactorL = saturate(id.x - Offset);
|
|
float diffFactorR = saturate(ResX - (id.x + Offset));
|
|
float4 resVal = 0;
|
|
//if(diffFactorL && diffFactorR > 0)
|
|
resVal = float4(((col1 * diffFactorR + col2 * diffFactorL) / ((diffFactorL && diffFactorR) == false ? 1 : 2)).xyz, 1);
|
|
//else
|
|
//resVal = float4(max(col1, col2), 1);
|
|
|
|
Result[id.xy] = resVal;
|
|
MonoChannelResult[id.x + id.y * ResX] = resVal.r * FarClipPlane;
|
|
}
|
|
|
|
[numthreads(8, 8, 1)]
|
|
void CSBlendDepths(uint3 id : SV_DispatchThreadID)
|
|
{
|
|
int2 idx1 = int2(clamp(id.x + Offset, 0, ResX), id.y);
|
|
int2 idx2 = int2(clamp(id.x - Offset, 0, ResX), id.y);
|
|
float col1 = Depths1[idx1.x + ResX * idx1.y];
|
|
float col2 = Depths1[idx2.x + ResX * idx2.y];
|
|
float diffFactorL = saturate(id.x - Offset);
|
|
float diffFactorR = saturate(ResX - (id.x + Offset));
|
|
float resCol = (col1 * diffFactorR + col2 * diffFactorL) / ((diffFactorL && diffFactorR) == false ? 1 : 2);
|
|
MergedDepths[id.x + id.y * ResX] = resCol;
|
|
}
|