ray-paraboloid intersection in 3d space with entry and exit point in hlsl? How would i approach it?

45 Views Asked by At

So I'm currently programming a shader in hlsl (more specifically, shaderlab, unity's version of hlsl) where i want to simulate rocket engine's plumes. These plumes tend to follow an equation that i simplified quite a lot to be

f(x) = Radius+(x*LinearExpansion) + (x^2 * QuadraticExpansion)

and the ray function would be

f(x) = RayOrigin + RayDirection*x

I've been able to integrate ray - cylinder and paraboloid equations on my shader code but none have the flexibility needed to also implement linear and quadratic expansion.

The idea is to create a "cylindrical" shape with f(x) by rotating said expression 360º, then get the entry and exit point and raymarch between those 2 points to create the volumetric effect. I had an idea to get the first ray's y intersection on the expression to get the entry point and then extend that same ray toward the 2nd intersection to get the exit point but I had not luck with my recent experiments.

I already tried to use a cube, raymarch it and mask the density by distance from center, but this gives me less than optimal effects with artifacts when looking at it from certain angles (since its a cube and not a cylinder). It was the closest i could get to the desired effect tho. but its horrible for performance.

0

There are 0 best solutions below