Max Barashev a2f9328f5f Made color and dapth calculations in parallel
- Edited RenderDepth.sahder to 2 sapces calculations
 - In DepthRenderPassFeature.cs changes passEvent to rendering after post-processing
 - Remove side cutting merged image in BlendShader.compute
2026-06-03 15:37:10 +03:00

32 lines
1.1 KiB
Plaintext

// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
RWTexture2D<float4> Camera1;
RWTexture2D<float4> Camera2;
RWTexture2D<float4> Result;
RWStructuredBuffer<float> MonoChannelResult;
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;
}