#pragma kernel FgFiltDist float4x4 _Transform; //float Xmin; //float Xmax; //float Ymin; //float Ymax; //float Zmin; //float Zmax; float4 _PosMin; float4 _PosMaxX; float4 _PosMaxY; //float4 _PosMaxZ; float4 _PosMaxZLeft; float4 _PosMaxZRight; float4 _PosDot; RWTexture2D _VertexTex; RWTexture2D _AlphaTex; [numthreads(8, 8, 1)] void FgFiltDist(uint3 id : SV_DispatchThreadID) { float4 vertex = _VertexTex[id.xy]; float3 vpos = mul(_Transform, vertex).xyz; // (float3)vertex; // bool mask = (vertex.a > 0.0); // && (vpos.y >= 0); //bool isInside = vpos.x >= Xmin && vpos.x <= Xmax && vpos.y >= Ymin && vpos.y <= Ymax && vpos.z >= Zmin && vpos.z <= Zmax; //mask = mask && isInside; float3 pmin = (float3)_PosMin; float3 pv = vpos - pmin; float3 px = (float3)_PosMaxX; float3 py = (float3)_PosMaxY; //float3 pz = (float3)_PosMaxZ; float3 pzl = (float3)_PosMaxZLeft; float3 pzr = (float3)_PosMaxZRight; float3 pz = (float3)lerp(pzr, pzl, pv.x / (_PosMaxX.x - pmin.x)); float3 pdot = (float3)_PosDot; float dx = dot(pv, px); bool bx = dx >= 0.0 && dx <= pdot.x; float dy = dot(pv, py); bool by = dy >= 0.0 && dy <= pdot.y; float dz = dot(pv, pz); bool bz = dz >= 0.0 && dz <= pdot.z; mask = mask && bx && by && bz; //_VertexTex[id.xy] = float4(mask, mask, mask, mask); mask = mask * mask; // make it positive _AlphaTex[id.xy] = float4(mask, mask, mask, mask); }