Artistic Experiments
  • Home
  • Reel
  • Shaders
    • Stylized Shaders
    • Lighting Techniques
    • Shader Effects
    • Cubemaps
    • Pixel Lit Shaders (Basic)
    • Vertex Lit Shaders (Basic)
    • Unlit Shaders (Basic)
  • Tools
  • WIP
  • Contact

WorldSpace UVs

9/1/2012

1 Comment

 
I was asked today to create a shader that tiles a texture based on world space coordinates rather than in UV space, essentially creating a top-down planar projection. For example, this would allow you to use a much smaller plane to create the illusion of it extending infinitely into world space.

It turned out to be a rather simple and inexpensive trick (1 extra ALU call over mesh uvs), so i decided to share.  Here is the implementation in Unity via the Strumpy Shader Editor:
Picture
First, we simply take the world position of the pixel being rendered and assemble a Vector2 from it. Since this was done in Unity, we ignore Y as that is world-up. In the case of UDK, we would use Y in place of Z. After we have assembled our Vector2, we multiply it by the global scale of the projection (0.1 in this example), and then add another Vector2 of 0.5,0.5 to recenter the projection. This is then used in place of MeshUVs wherever appropriate in the shader.

You will probably want the global scale as a parameter, so that you can find a projection that works for you. 
1 Comment
Owen McManus link
5/26/2013 02:29:51 pm

Thank you for this. I've been looking for a good way to achieve a similar effect for a while. The shader graph was very helpful.

Reply



Leave a Reply.

    Graphs

    Shaders graphs for different effects

    Archives

    September 2012
    March 2012
    September 2011
    April 2011

    Categories

    All

    RSS Feed

Powered by Create your own unique website with customizable templates.