Object (Plane) Texture Coordinate

Hi, i’m trying to learn procedural shaders in spark from this video:

at 4:04 we can see that there is a node for object texture coordinate. I can only see diagonal RG default UV texture if I connect the texture coordinate to pack vector 3 with second slot set to 0, and third slot to 1 for the alpha. also the coordinate is start from top left following the spark coordinate system.

how to set the uv so it looks like in 4:04? so the 0 is in the middle and divide to 4 squares like that?
To set fract, I use modulo. is that correct?
also what patch to use to replicate the “compare” patch in the video at 5:57?

I’m interested to play around with UV and vertex stuffs. can someone help me to accomplish that in spark?

*also i figured that we can do this using SDF, but since i’m interested in using UV, i wonder if this is possible in spark using UV.

I generally don’t use the vertex attribute texture coordinates when I’m doing UV manipulation. Instead, I use the function vec2.

You are right to use modulo 1 in place of fract - that does the same thing, dropping the whole number and leaving you with the decimal value.

There’s no compare node in Spark, but if you want a torus you can do this:

4 Likes

Wow. thanks a lot josh. I’m still not familiar with Function and Composition patch. So is a Function is kinda like an open and close bracket (…) that treats any patch after that to be some kind of a group calculation? I read the documentation but still goes over my head.

also from the torus/donut shape, it’s an oval. can I use device screen x value to divide the y value to get the square (or in this case a circle)?

I’m not sure about the details behind function / composition, other than that function behaves like a UV and composition behaves like a texture sampler (except it outputs a texture instead of a color).

The texture is actually a circle already, but the screen texture is distorted because it’s fitting the square texture into a rectangular shape. To get the aspect ratio, you can do screen y/x, then swizzle x1, then multiply the UV to scale it. Something like that…

2 Likes