#pragma kernel CSMain #include "UnityCG.cginc" #include "../../ParticleWorks/Shader/Inc/Defines.cginc" struct Vertex { float3 position; float3 normal; float4 color; float4 uv; //float2 uv2; //float4 tangent; }; RWStructuredBuffer ssbo; RWStructuredBuffer origin_buffer; RWStructuredBuffer vertex_buffer; [numthreads(WORK_GROUP_SIZE, 1, 1)] void CSMain(uint3 id : SV_DispatchThreadID) { Vertex o = origin_buffer[id.x]; Vertex v = vertex_buffer[id.x]; int index = o.uv.z; Particle p = ssbo[index]; v.position = mul(p.model_matrix, float4(o.position, 1)).xyz; v.normal = mul((float3x3)p.model_matrix, o.normal); v.color = float4(p.color.rgb, 1.0f); v.uv = float4(o.uv.xy, 0, 0); float space_height = 3.0; float limit_height = 0.1; v.position.y = saturate(v.position.y / space_height) * limit_height; vertex_buffer[id.x] = v; }