verenion
verenion

Reputation: 383

Shader Noise and CPU Noise

I've come across an issue, where I am using a custom shader to offset the vertices of a (flat) mesh using noise. this is fine, and works well:

enter image description here

I also want to generate a collision mesh for this - which requires the use of CPU-based noise. I am usin "noiseSimplex.cginc" that can be found online, but want to implement a c# version that gives the same result. Is there a suggested way of approaching this problem?

Upvotes: 0

Views: 180

Answers (1)

Thomas Hilbert
Thomas Hilbert

Reputation: 3629

If you need to calculate the mesh on the CPU anyways, there is no further advantage in having it calculated on the GPU. Do your mesh transformation on the CPU and use that mesh for both the rendering and the collision.

Edit:

Assuming a case where you mostly need the mesh for rendering only, but sometimes you want to have it on the CPU for processing, you might consider having it generated on the GPU with the possibility to download it as required.

I'm not up to date on shader technology, but last time I looked (DirectX 10 times), you might have generated the mesh purely using a geometry shader into a buffer on the GPU. Then you can use that buffer to feed into your rendering as well as download it to the CPU if required.

It's quite possible that this is no longer the way to do it today, but it should work.

Upvotes: 1

Related Questions