How to triplanar/box mapping normals with nodes?

Hello everyone! :slight_smile: I’m a big fan of blender and having a blast creating! I’m running into a problem with normal maps when using box mapping.

I’m working on a big environment scene so instead of using UVs I’ve decided to use vertex masking, and project the textures using Blended Box Mapping or as some call it Tri-Planar Mapping.

Everything works great thanks to the Image Texture - Box, but sadly this doesn’t work for normals as I need to set them up and blend using something like UDM or Whiteout. I’m unsure how to do this using Nodes, and I did look into OSL but I think it’s not the right time for me to try to write my own shader as I don’t have enough experience with shaders sadly…

My understanding is that I need to calculate the unique tangents and bitangents using the world axis. I’ve heard of the term “swizzle”… but I’m not sure how to put this into a node setup. Does anyone know of a good node setup to accomplish this?

EDIT: Made a mistake, I put my normal on “color” instead of ‘Non-Color Data’. In my actual environment I have it set properly this was just a demo.

A swizzle is just a normal map “format” - what each of the colors means. There are two common conventions and you can convert between them just by inverting the green channel. However, while the result looks similar, a bad swizzle is not what’s happening here. See that normal map node? It computes the tangents and bitangents based on the UV map and outputs a worldspace normal. You aren’t using a UV map, so of course the result will be wrong. I’m not sure using a tangent space normal map with blended box mapping is at all possible in cycles.

I’d advise you to do is just use a displacement map instead.

1 Like

Thank you for your reply. I was trying to render out my environment scene using the similar techniques used in Unity or UE4 like in these write ups:


As my Environment has already been modeled out and I’m not using a displacement to generate the terrain (it’s coming from a third party tool with edits to the geo), I had several textures made for rock, grass, and dirt which have their normal maps as well, and I would blend everything together on one mesh the Environment model in this case using vertex masking.

I’m not sure how using a displacement would be able to mimic my normals in this case. :frowning: It would just push the geo out.

I’m sure somebody is using some way to correct their normals, unless most people are just UV unwrapping terrain.

A displacement map can be used to push out Geo, but it can also act as an old school bump map. Or if that’s not enough, you could use the adaptive subdivision in Cycles and yeah, push out the geometry to get some lovely looking bumps on materials. :slight_smile:

Like I said, you can correct the swizzle very easily. Just invert the green channel with an RGB Curves node. But I doubt this will solve your problem. Well, try it anyway. :slight_smile:

1 Like

Thanks. :slight_smile: I tried inverting but it didn’t make a difference. I wish I could achieve this because it’s used in Unity and Unreal without a hitch.

I also tried displacements and bumping, but it wont retain the shapes the normal maps would give, and pretty much distorts the look.

I’m not sure if you’ve ever seen this post: [Cycles] Tri-planar Texturing

This actually had it done, but I wasn’t able to produce the same result using the setup for some reason. :expressionless: I also don’t believe this had normals working though, as the setup even blended would still have my issue with inverted normals I think.

I’m sure this can be done to mimic other renders. I just don’t know why it wont work.

download > https://www.blendswap.com/blends/view/78446
for normal map, after mesh editing, use cube projection mapping

1 Like

Awesome! Thank you. :slight_smile:

Unfortunately this one looks great at first sight, but based on Geometry Node ‘Position’ which means for an animated object the mapping will change during the animation.

Try this one, apparently by nudelZ. I believe this is the original one prior to me mangling it to my own needs. Unfortunately BlendSwap has a login policy which doesn’t mix well with my bad memory, so I couldn’t provide a link there (I wanted to check).
box_mapping_node_nudelZ.blend (221.6 KB)

You may want to simplify it yourself if you only need triplanar instead of the full sixplanar it supports. I always use this, or my modified version, as the vanilla box mapping just feels so broke to me.

Edit: Oh, I haven’t tried it with normal maps (I think). At least I can’t remember the results.

2 Likes