1
\$\begingroup\$

I have this hexagonal grate floor:

Hexagonal grate floor

Which is a flat plane with the following shader:

enter image description here

The hex lattice created using the method by Andrew Hung. Albedo and metallic/smoothness shader are just simple textures.

I would like the hex grate to have a little depth without adding lots of polygons (and then using vertex position shifting).

Perhaps a little like an outline shader but offset below the grate? Is it even possible?

Many thanks.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

If I'm following your node graph right here, you should be able to take a copy of your alpha map, offset it a bit based on the view angle, and then subtract the original alpha map from your offset one, and use the resulting image as a mask for whatever you want your extrusion/depth to look like. Then mix that in with the rest of the grid, using the sum of the alphas added together for your alpha channel (to make sure both the original grid and the extruded bit are visible).

The illusion will probably break at extreme angles, but with some tweaking it should be possible to get something at least passable until further inspection.

One way of doing this, would be to

  1. Get the dot product of the camera forward direction and the surface normal. This will give you a number between -1 to 1, where 1 means they are entirely aligned, -1 they point in exactly opposite directions, and anything else means something in-between.

  2. Use this value as a scaling factor for how much offset your "extrusion layer" needs; when looking from above, you'd want this to be zero, and the more parallel to the plane, closer to one, so something like 1 - abs(dot(cameraForward, normal)) could work.

  3. To then find the actual values to offset by, you could take the cross product of the camera forward direction and the surface normal, to give you a new vector perpendicular to both, which lies on the plane of the surface.

  4. Use the components of that cross product to offset; exactly how will depend on your coordinate system, and order of the operand of the cross product, in my case it ended up working with (-y, x).

  5. Then multiply that offset by the scaling factor from step 2, and potentially some other factor to make the effect more or less subtle if needed, and the result should then be our offset vector.

  6. Take your original alpha map use to render your grid transparency, create a new copy of it offset by the offset vector, then subtract the original alpha map from it. The resulting map should then be white only where the extrusion is supposed to be visible.

  7. Calculate color/roughness etc. for your extrusion however you want, for example, as a tweaked copy of the original version.

  8. Use the map from step 6 to mix your original grid, and the extrusion, keeping the original wherever the map is black, and the extrusion where it is white.

  9. Use your original alpha map and your extrusion alpha map added together as the final alpha map, which should then be white (opaque) everywhere the original grid was, as well as wherever the extrusion now is.

I took a quick stab at doing this in Blender, with a node graph like so:

node graph

resulting in an effect roughly like this:

resulting effect

where black is then the "extrusion".

You will likely have to tweak the exact scales etc. to get this to look right for you, but an approach roughly like that should get you something similar to a 3D effect on your plane.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .