Box Mapping instances.

   3205   5   1
User Avatar
Member
41 posts
Joined: Feb. 2014
Offline
Hi!

How can I project a texture (Box Mapping) onto instances?
The issue I have is that the texture is always facing the camera, as shown in the following screenshots:

Thanks in advance.

Attachments:
mapping.hipnc (174.0 KB)
2.jpg (62.6 KB)
1.jpg (63.1 KB)

User Avatar
Member
606 posts
Joined: May 2007
Offline
Shading in Mantra happens in camera coordinates. You need to add a transform vop before the uv mapping vop to work in object coordinates.

Attachments:
mappinge.hipnc (193.4 KB)

User Avatar
Member
41 posts
Joined: Feb. 2014
Offline
eetu
Shading in Mantra happens in camera coordinates. You need to add a transform vop before the uv mapping vop to work in object coordinates.

Thanks for the quick response eetu!

I had to do a minor tweak to the scene you submitted, the texture was being projected on each instance and not as a whole, so I changed “To Space” to space:world.

Now, to fully address my problem I need to project the texture on each side of the instances (Box Mapping), right now the shader is only doing an Orthographic Projection. Any tips?

Attachments:
mappinge_147_fix.hipnc (200.2 KB)
after.jpg (52.6 KB)
before.jpg (225.8 KB)

User Avatar
Member
606 posts
Joined: May 2007
Offline
If you want to have a sharp edge, check which axis is the closest to your normal, and choose between 3 mapping nodes based on that. Theer is an implementation of that inside an old ubershader [forums.odforce.net] I did, if you feel brave enough to dig in.

Incidentally I just happened to redo this in Unity. I wanted smooth transitions between the directions, so this time I did it by raising the normal vector to n'th power (n being the transition tightness), re-normalizing, and then blending between the three axis-aligned mapping results according to the vector components. (added bonus - no branches on gpu)
User Avatar
Member
41 posts
Joined: Feb. 2014
Offline
eetu
If you want to have a sharp edge, check which axis is the closest to your normal, and choose between 3 mapping nodes based on that.

Ok, I implemented what you said and is working fine.

Now, the last problem is that the texture is not moving with the points/instances, and this causes the uv coordinates to “shift”. like in the following pictures. How can I fix this?

Thanks in advance.

Attachments:
5 units up.jpg (56.1 KB)
rest position.jpg (45.8 KB)

User Avatar
Member
606 posts
Joined: May 2007
Offline
I suppose there is a way to get the instance transforms - but at this point I have to ask is there really no way to use uvs, offset in some way by the initial position of the instance point, for example?
  • Quick Links