top of page
Search
Writer's pictureEvan Ryan

Exercise 1 - Contrast - Visual Continuation

Building on the visual techniques I explored last week, I wanted to expand on the spherical overlap shader as I can see it being very useful later on in the project. At this stage, it's two drawbacks were that it only worked in a spherical area and that objects sharing this shader cannot interact with each other.

Overlap Shader as from last week

So far I'm yet to find a way to let the shader interact with itself. I believe this is due to the shader using the SceneTexture node, which provides an element of the scene's shader buffer. This can only be used by transparent materials as they are rendered later in the process, this means at the stage of the SceneTexture node, any other objects using this shader, have yet to be drawn. As for the spherical masking, the shader now works for cubes/rectangles. Originally the shader worked by taking the position of a pixel in World Space and comparing it to the location of the sphere, if it was within the radius of the sphere, it would draw. This gives us the overlay for which parts of the scene are within the sphere.

Location comparison for Sphere Overlap

The issue with this is it takes the 3d values of the pixel and object's location, and strips it to a 1d value, this is only useful for sphere's with their constant radius. The solution to this then is to keep the values 3d until after the distance comparison has been made, meaning we can have different values per axis. Simply adding together these three values however did not give the correct result, it provided the overlap of the cube, if the cube was 45° rotated on all axes.


In order to fix this, and to have the overlap area transform in line with any changes to the rotation or scale of the shape, the three values had to be combined using a Max function, and the object and pixel location had to be transformed to Local Space rather than World Space. As it currently stands the shader gives correct overlap for spheres and cubes of any rotation and scale.

The current iteration of the Overlap Shader

19 views0 comments

Comments


Post: Blog2_Post
bottom of page