top of page

Week 9 - Building a Library of Triplanar textures

Updated: Dec 11, 2019

Learning by doing

We have a limited time to design and develop a full game project and while we were working on various design aspects for our game at this stage, I started working on an idea that would save us time and effort for our development phase.

My vision for this design idea was to make a texture library for Abbie and Kerris that makes it so that they can seamlessly paint the texture on the 3d environment of our world without needing to UV unwrap. I started researching for answers as I needed more information on how I could implement this and found some very good resources.


The process they used fascinated me to no bounds. The end result of this was basically mind blowing. I had no idea that this was a thing until i researched into what it was and how people use it. I still was clueless to how to go about it so I watched some tutorials and read some interesting write ups about Triplanars. I found out this very interesting article that explained why you use it and what are the advantages of using this technique. It allows us to freely use our imagination to paint any texture onto a terrain or an environment without worrying about the UV coordinates. To start up with a simple Triplanar Shader I started off in a bit of an extreme way.


I used the different x, y and z axis to project the texture on and to do that I used the Position node in Shader graph and set it to world space (I could have used object space but in my opinion, world space is gives me more space to work with) and then used the Split node to get the access to the x, y and z axis of the object.


RGBA channels in the Split node basically refer to the different axis (R - X axis, G - Y axis, B - Z axis, A - Alpha Channel) and combining two axis together would give me different faces (Front, Side, Top) of the object allowing me to have different texture for each face. After this, I set up some properties to adjust the tiling of the texture in the inspector as it would give us more accessibility. I did that by dividing and multiplying the Combines and connecting them to the Sample Texture 2D node.

I used Normal Vector node set to world space and connected it to the Absolute node which further is multiplied by itself and split into its individual axis. This was used to get world projection of XYZ axis onto our object so that the different texture can wrap around the object with respect to the projection.

In the images above, The texture would wrap around the white areas while seamlessly blending with the grey onto the black. the First image shows the X-Projection (the texture would wrap around the sides), Second image shows the Y-Projection (the texture would wrap on top [could be used for adding snow to the environment]) and the Third image shows the Z-Projection (the texture would wrap on the front).

The last thing I did was add the Blend node to blend the world space projections with the custom texture. I made three Sample Texture 2D nodes for each projection so I can test having different texture on the top and the sides of the object.

After finishing the shader, I added the textures that me and Abbie had made and it looked okay, I was happy with the progress although I know i can work hard and do better but this was my first test and I was happy with the progress that I made.


Later on I added some environment around this object and wanted to see how flexible and effective this method is.


 
Polybrush Setup

After Understanding how Triplanar textures work and how they can be used, I went onto designing a vertex painting system. I wanted to assign Triplanar Textures to different vertex colours so that Abbie and Kerris could spend time painting the environment without having to worry about UV Unwrapping or any other technical restraints. Successfully setting this up would mean that we can reduce our workload and be more time efficient, and time is the most valuable. I understood the basics of polybrush through some youtube videos published by Unity itself. Its a fairly simple tool that lets you work on terrains and paint colours, textures and scattering environmental models like trees and rocks.

I did some research on how people use polybrush and talked to Adam and my team about it, they seemed on-board with the idea of having a texture library that they can access and customize for doing environment design.


I installed the Polybrush package into unity and did some testing by painting and sculpting on an empty plain. After I got the hang of all the different features of the software, I moved onto making the Shader that would use different colour channels of vertex painting to paint custom environment texture. For prototype purposes I only used the red channel to paint a Specular reflection texture onto an object to add a wet/glossy look to objects.




To get access to the red channel in polybrush, I had to make a Vertex Color node and Split it into its 4 channels (RGBA) to get access to different colour channels. I used the R-channel and added it to the Specular Effect Group and the Sample Texture 2D node.





For the Specular Reflection Effect, The most important thing that I needed was the Fresnel node and the Step node (Per component, returns 1 if the value of input In is greater than or equal to the value of input Edge, otherwise returns 0, basically meaning it either gives me White or Black depending on the values). The Power node was just used to adjust the Fresnel effect. The whole thing was multiplied and added to the Texture 2D and the Vertex Color's R-Channel. After finishing this Shader, I went on and tested if i can paint the effect or not. It worked as I suspected and I could use the Red colour channel to paint the Specular Shader.

I am planning on expanding the texture library and have multiple textures accessible through different colour channels.

This process was a very exciting one as I got to learn so much about different Software and different techniques that people use for designing efficient ways of painting textures.

 

26 views0 comments

Recent Posts

See All
bottom of page