Arctan2 in Patch Editor?

Hey there, I’m trying to convert a shader from Shader Forge to Spark Patch Editor, and I’ve run up against a couple of small problems. Number one: there’s an atan2 operation in the original shader, but none in Spark. How can I build the operation myself?

Number two: The original shader calls for the Object position to be compared to the view position in a certain way, such as here:

.

I couldn’t find those exact values, so I tried to fake it with head rotation compared against a fixed [0,0,0] vector.
Do you think that will work?

This is what I have in Spark right now:

There is atan2 in spark, it’s just called “Arctangent”

I think you can get the object position in global space by multiplying the local position vertex attribute by the model-view vertex transform.

I’m not exactly sure what you’re trying to do in the end, but if it’s fresnel or iridescence, check out the Glitternator 5,000,000

Hey Josh, thanks for taking the time to answer my slightly cryptic question :smiley:

I actually realized that I was really overcomplicating things by not using the straight head rotation. Let me explain.

My goal was to translate this tutorial for a lava lamp shader in Unity into a cool insta filter. First I wrote the shader, then I put a bunch of objects and occluders together to put the lava lamp into the face. The angle is needed to drive the parallax effect, and as the plane uses the head tracker, it was a simple fix to my perceived “problem”.

Here’s the result. Let me know if you’re interested in a patch asset for the lava lamp shader!

1 Like

Woah, that is super cool! Of course I’d love to see a patch asset for it!

Here’s the patch asset:
Lava Lamp Shader.arp (13.9 KB)

And here’s the texture that goes along with it:


(make sure to set repeat mode to Tiling, linear color encoding, high sampling)

Enjoy!

3 Likes