Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feedback Change how to draw particle
#1
Bombilla 
Hi dev.
Correct me if I'm wrong, for now I think the particle rendering is only for debugging and adjustment to get desired physics result.
So why not use Unity's Handle API to do it?
My current problem with it is my Unity 2022.2.2f1 URP 14, Obi Particle shader does not render.
I do not wish to tell you guys to fix this shader, since it will break again when Unity makes changes to their rendering.
Handle API will not break, it can draw mesh with custom shader.
The sphere mesh can be referenced in code (instead of currently generated in shader?), and the shader can just be a simple Lit shader made in Shader Graph.
Shader Graph's shader will not likely to break than custom HLSL shader.

Thank you, hope you a nice day!
Reply
#2
(25-01-2023, 07:28 AM)spikebor Wrote: Hi dev.
Correct me if I'm wrong, for now I think the particle rendering is only for debugging and adjustment to get desired physics result.

Hi Spikebor!

In Obi Rope yes, but in Obi Fluid it is the main rendering method as used to draw both granulars and fluid.

(25-01-2023, 07:28 AM)spikebor Wrote: So why not use Unity's Handle API to do it?

Because handles are extremely slow compared to the current method, and can only be used in-editor.

(25-01-2023, 07:28 AM)spikebor Wrote: My current problem with it is my Unity 2022.2.2f1 URP 14, Obi Particle shader does not render.

Are you using the URP particle shader? You can find it in Obi/Resources/ObiMaterials/URP, as stated in the manual.


(25-01-2023, 07:28 AM)spikebor Wrote: I do not wish to tell you guys to fix this shader, since it will break again when Unity makes changes to their rendering.
Handle API will not break, it can draw mesh with custom shader.
The sphere mesh can be referenced in code (instead of currently generated in shader?), and the shader can just be a simple Lit shader made in Shader Graph.

You can't use a custom shader to render particles unless you use a mesh for each particle, which would be very slow for large amounts of particles (it's not unusual for Obi to deal with +5000 particles). In upcoming updates that allow for GPU simulation, you can simulate as many as 100k particles so rendering speed becomes even more of a bottleneck.

The included particle shader implements something called "screen-space ellipsoid splatting": each particle is just a camera-facing quad generated in the vertex shader, and the surface of the sphere is determined using raytracing in the fragment shader. This is many orders of magnitude faster than rendering spheres using the Handles API since each particle is only 2 triangles and they're all rendered in a single draw call.

If you're curious about this technique you can read more here:
http://www.inf.tu-dresden.de/content/ins...ipsoid.pdf

If you want to use an arbitrary mesh to render each particle, with a custom ShaderGraph shader, you can use the ObiInstancedParticleRenderer component instead. Note the shader you use must support GPU instancing, and this will be slower than using ObiParticleRenderer.

kind regards,
Reply
#3
Thanks for the info!
Oh it's splat shader, I know this one also in asset like Mudbun
I've checked, the shader I'm using is indeed the correct shader you've pointed out
But the particles only drawing shadows inside the rope, without the rope mesh it will not render at all.

[Image: FWEE7Bw.png]

[Image: KaUeFGf.png]

[Image: X4zcG3V.png]
Reply
#4
As a side note, in Obi 7 the particle shader is implemented using Shader Graph. The main reason being we want to support HDRP, and hand-writing shaders for HDRP is close to impossible.
Reply
#5
(25-01-2023, 09:03 AM)spikebor Wrote: Thanks for the info!
Oh it's splat shader, I know this one also in asset like Mudbun
I've checked, the shader I'm using is indeed the correct shader you've pointed out
But the particles only drawing shadows inside the rope, without the rope mesh it will not render at all.

Ok, will take a look! Thanks for reporting it.

In the meantime, you can use ObiInstancedParticleRenderer to visualize the particles. It's a bit more inconvenient to use, but should do the trick since it doesn't use any SRP-specific shaders.

Edit: is the "depth texture" checkbox enabled in your URP pipeline asset? The particle shader performs depth testing against the scene, so if there's no depth buffer available they might not appear at all.
Reply
#6
(25-01-2023, 09:04 AM)josemendez Wrote: As a side note, in Obi 7 the particle shader is implemented using Shader Graph. The main reason being we want to support HDRP, and hand-writing shaders for HDRP is close to impossible.
It'll be great! Thanks for your hard work.

(25-01-2023, 09:06 AM)josemendez Wrote: Ok, will take a look! Thanks for reporting it.

In the meantime, you can use ObiInstancedParticleRenderer to visualize the particles. It's a bit more inconvenient to use, but should do the trick since it doesn't use any SRP-specific shaders.

Edit: is the "depth texture" checkbox enabled in your URP pipeline asset? The particle shader performs depth testing against the scene, so if there's no depth buffer available they might not appear at all.

yes depth & opaque textures both enabled, using deferred rendering.

I'm using instanced particle renderer without issue. This is exactly what I wanted, thanks!
Reply