Download

Looking for references/directions: Procedural Triangle Shader Fragment?

I’m trying to get a way to draw a filled triangle dynamically based on just PixelShader (UV) inputs.

I’ve found on Internet the Procedural Circle algorithm and some crazy fractals, but everytime I type “Triangle UV Rasterize” on Google I’m buried by docs where the author has access to VertexShader (Duh :smiley: ), but it’s not my case here since this material is being designed to use on Slate/UMG where I’ll be constrained to render to a Quad.

If the algorythm it’s “portable” I think I could get it to work, as I did with the circle one:
922f2d9b0f4fb2669389ce4f6fd9a43d85466dcc.jpeg

I’m not a Math guy, but I think that is there already a way to make this, maybe I’m lost on vocabulary.

Any help will be greatly appreciated.

Thank you.

“Barycentric Coordinates!” Finally found the term (and the algorythm).
Special Thanks to P.Avery by post the code/question here: http://gamedev.stackexchange.com/questions/62651/finding-pixels-within-uv-coordinates

And yes, if we follow the formula correctly it works pretty well! :smiley:

to future Searchs: HOW TO DRAW A FILL TRIANGLE ON MATERIAL

triangle.jpg

Just remember on pass your triangle Vertices Coordinates as UV positions.

Regards!

I’ve been working n the same task, needed to make a triangle material for UI, found more elegant solution using less nodes, and it is easy understandable. NOTE: in TexCoord you need to set U tiling to 0.25. You can also rotate it by changing masks.