I'm new here, so hi guys! I've got a shader for you.
The problem started like this: I needed a way to "clip" particular objects to regions on the screen. i.e Things would only render in certain specified areas of the viewport.
There didn't seem to be much information about this on the forum, so I decided to write a shader for it (attached).
How to use:
You need to load ONE effect for EACH CLIPPING REGION. Then set the region for each effect using:
set effect constant float effectnumber, "x1", #somevalue
set effect constant float effectnumber, "y1", #somevalue
set effect constant float effectnumber, "x2", #somevalue
set effect constant float effectnumber, "y2", #somevalue
where x1,y1 is the top-left corner and x2,y2 is the bottom-right. (Only rectangular clipping regions are supported)
To clip object x to the region specified for effect y, simply apply effect y to object x
"set object effect, x,y"
IMPORTANT:
For efficiency reasons, the Co-ordinate system for the rectangles is independent of resolution and is defined as follows:
using [x,y]
0,0 is the BOTTOM LEFT of the screen
x increases to the right, and y increases upwards
2,2 is the TOP RIGHT of the screen
(hence 1,1 is the center of the screen)
Good luck! and hope it's useful to some of you.
Do you ever feel, in your caves of steel, The chill of an ancient fear?
Do you shudder and say, when you pass this way,
A human once walked here?