Search Unity

"Bake" triplanar shader

Discussion in 'Shaders' started by calpolican, Feb 11, 2021.

  1. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    425
    I'm doing some procedural tools for making buildings, and one thing that I noticed is how annoying is that every piece has to be unwrapped with exact UV map, so that the textures tile seamless. For many reasons this is pretty restrincting an very slow to add any architectural variation. So, I begin thinking of using triplanar shaders. The result works well (except for round corners wich ultimately I don't mind that much). But triplanar shaders seem expensive because it has to constantly compare the direction of the normal.
    I thought of a workaround for this: make the engine determine the direction of the normal at start and then just choose between 3 options (x,y,z) and use that one. This avoids the constant comparision. But I'm not 100% sure how slow/fast is the "World position" node in the shader (?). Is it just a reference to the vector 3 of the object's world position, or the vertex world position?

    So, what I'm looking for is to dynamically create the UVs of the object based on world position after the procedural buidling is finished, resulting in something that looks exactly like a triplanar. Is this possible?
     
    Last edited: Feb 12, 2021