Set A Vertex UV based on World Space Coords

I don’t know if this is the right place for this question, but it is graph related so here goes. Is there a way to ignore the UV’s of a vertex and assign my own (in the material graph) based on World Space Coords? I am procedurally generating terrain and plan on implementing Triplanar Projection. Is this possible to do in the material?

Triplanar projection is totally doable, here is an example in UDK : 3d projection texture coordinates for Terrain layers - Epic Games Forums

Basically, you just have to get the WorldPosition node, mask out only two components (since you want UV coordinates) and scale a bit the result before plugin it in your texture sample. Note however that for normal maps it will not work properly. Since your are not anymore in the UV space of the mesh/landspace, you can’t rely on its Tangent/Binormals.

Thank you so much! So the UV inputs on the samplers really just need a plain old 2D vector? I kept looking for a node that created UV’s, in hindsight I really should have just tried stuffing a 2d Vector in there. Thank you for the heads up on the tangents/binormals.

If you want to get the UVs of your mesh in the shader, you are looking for the Texture Coordinate node. By default you don’t need it (texture sample node always have access to the first UV set of the mesh used by the shader). This node is useful in case you want to translate/scale the UVs (like for repeating a texture multiple times).

But in your case, you don’t want to take the UVs of the mesh into account, therefore that’s why you only need rely on the worldposition node instead.

Regarding normal maps, I got a bit of help myself about them, over here : http://www.polycount.com/forum/showpost.php?p=2062159&postcount=1671

Wow! Thank you so much. You have really helped me out a lot. This community is amazing because of people like yourself.