You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
870 B

#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<Particle> ssbo;
RWStructuredBuffer<Vertex> origin_buffer;
RWStructuredBuffer<Vertex> 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.xzy, 1)).xyz;
v.normal = mul((float3x3)p.model_matrix, o.normal);
v.color = p.color;
v.uv = float4(o.uv.xy, p.seed, 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;
}