veldrid-samples icon indicating copy to clipboard operation
veldrid-samples copied to clipboard

ComputeParticles are all at bottom of screen

Open BinarySpike opened this issue 5 years ago • 4 comments

I cloned the project and did a dotnet run in the ComputeParticles/Desktop folder and all the particles are at the bottom of the screen.

image

This is on Windows 10

BinarySpike avatar Apr 21 '19 03:04 BinarySpike

Swapping particle x and y in the Vertex shader causes the particles to hang to the left hand size. Looks like Particles[gl_VertexIndex].Position.y is no good.

void main()
            {
                gl_Position = vec4(vec2(Particles[gl_VertexIndex].Position.y, Particles[gl_VertexIndex].Position.x) / vec2(ScreenWidth, ScreenHeight), 0, 1);
                gl_Position.xy = 2 * (gl_Position.xy - vec2(0.5, 0.5));
                fsin_color = Particles[gl_VertexIndex].Color;
            }

BinarySpike avatar Apr 21 '19 16:04 BinarySpike

Removed Velocity and Color from the ParticleInfo and now it's a proper distribution.

BinarySpike avatar Apr 21 '19 16:04 BinarySpike

Looks like Particles[index].Color.x is being translated to Particles[index].Position.y by the time it gets to the vertex shader.

This code at the end of of the Compute shader code causes everything to position, animate, and move correctly:

Particles[index].Position = newPos;
Particles[index].Velocity = newVel;
Particles[index].Color.x = pos.y;

BinarySpike avatar Apr 21 '19 17:04 BinarySpike

The correct solution seems to be changing this call: https://github.com/mellinoe/veldrid-samples/blob/0ac284ddc8f62d8d75c8eae88cc1824c320b1caf/src/ComputeParticles/Application/ComputeParticles.cs#L34-L38

BufferDescription.RawBuffer must be set to true to be functionally equivalent to other backends (and correct in general).

TechPizzaDev avatar Nov 16 '21 22:11 TechPizzaDev