SDFs are great for little tricks like that. This works for any shape, as long as the distance estimation is correct. If you want to make the border bigger, simply subtract another term to increase its size, just like you did to make a rounded box. This make an object with an "empty" border. Abs(de) will basically remove the inside of the object (negative distance) by making it positive. You can get a border by using the absolute value of the distance. You can get a rounded box by subtracting a term to the distance, but you already figured it out (r in your exemple). Use the box signed exact function here If you want to write it yourself, try to figure out a way of getting the closest point on the box, then return the distance to this point. You can add an infinite number of object for (almost) no added cost. SDFs performance are usually bound by the number of objects you add in your distance function this is the reason why mod/floor functions are so useful when making SDFs. Instead of computing a single object, you compute two objects. it will connect the first and last, so if you have more than one triangle, it wont work. if you are only rendering a single triangle at a time you can use GLLINELOOP. Using a secondary box to extrude the first one is a bad idea, as it will lead to worse performance. Use GLLINES, GLLINESTRIP, or GLLINELOOP (difference see here) with the same vertices that you use for GLTRIANGLES.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |