9
$\begingroup$

I'm using Cycles I want to add thickness to a texture with alpha transparency like @rich-sedman do in his nice answer here:
How can I make a hexagonal grill? But this time with an image texture (jpg+mask or png/tiff) not a mathematically generated one.
It can be separated planes or solidify modifier, I don't mind, even if solidify would be better.
I've already seen things about parallax mapping but not sure it's suitable and as good as this one.


Edit 1

A reference image of what kind of texture I use
https://www.textures.com/download/metalvarious0044/61614
The point of my question is that it can be seen from a side angle and not looks like a paper sheet.


Resolved

The answer of Rich is working, it's not perfect, no material on the volume, quite expensive and volume don't seem to work with UVmaps, only generated or object so for array it's complicate. But if it's not for a close shot it makes the joke.

$\endgroup$
  • $\begingroup$ The link provided does not point to an answer? $\endgroup$ – aliasguru Jul 9 '17 at 4:57
  • $\begingroup$ do you mean this link? blender.stackexchange.com/a/78003/1853 $\endgroup$ – cegaton Jul 9 '17 at 5:54
  • $\begingroup$ Sorry it was late ^^. Yes Cegaton it's exactly that one. I've corrected the links in my question. $\endgroup$ – Mareck Jul 9 '17 at 10:29
  • $\begingroup$ @Mareck I've added a further answer to use a similar technique to that used in the hex shader. It's far more complicated than the volumetric solution but produces very pleasing results. Hope this helps. $\endgroup$ – Rich Sedman Jul 16 '17 at 6:41
12
$\begingroup$

There is another way - using a similar technique to the procedural hex shader defined here to displace additional Image Textures to "fill in" the faked depth.

enter image description here

The following nodes will generate the required offset based on the surface Normal, the Incoming ray, and the 'depth' behind the image plane :

offset calculation

The output vector can be used as an offset to the Image Texture coordinates and used to mix between a Transparent and Diffuse shader to project a faked "shadow" where the back surface would reside based on the specified 'depth'.

material for single alpha "shadow"

add shadow

Taking this a step further we can "fill in" the depth by generating multiple 'layers' at different depths - eg, 8 layers at 0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 0.875, 1.000 - by varying the 'Factor' of the MixRGB Subtract node.

material for multiple "shadows"

animated - multiple "shadows"

Since the faked depth is generated on the image plane (it's all one flat surface rather than additional geometry), the surface normal is the same for the projected 'edges' as it is for the rest of the image. For additional realism we need to be able to generate a faked Normal for the projected layers and for this we need to be able to detect the 'direction' of the closest edge for any point in the original image.

To achieve this, take the Alpha channel from the original image and pass it through a Blur filter in an external graphics package such as Gimp (you could potentially use Blender compositor nodes to do this and save as a separate image but it's far simpler to use a tool more suited to the job).

original alpha channel blurred alpha channel

Passing this blurred image into a Bump node will generate a Normal for each point - which will tend to point "outwards" towards the edge of the alpha "island" for each pixel in the image.

bump

We can use the Cross Product vector math node to generate a faked normal based on the bump map that is perpendicular to the actual surface normal and is pointing in the direction of the closest edge from that point.

cross product normal material

The Cross Product produces a vector that is perpendicular to both of the input vectors. Therefore, the first Cross Product with Normal produces a vector that is along the surface but that is at 90 degrees to the bump map generated 'normal' while the second Cross Product produces a vector that is at 90 degrees to that (so it's in the direction of the 'bump') which is also at 90 degrees to the surface normal (so it's along the direction of the surface) - ie, the Normal of the 'edge' of the projection.

cross product normal

The generated Normal can then be applied to each of the 'layers' to build up into the associated 'edge'.

Note that the 'edge' will not be correctly shadowed since the 'image' is still only rendered on a single plane - ie, it will not cast shadows on itself and shadows on other geometry will be limited to rays that pass through the image plane. it will also become distorted when viewed at progressively shallower angles. Note also that this will only work be effective if the 'layers' are sufficiently close together to prevent the rays traveling too far 'into' the image (otherwise the normal will be calculated for the opposite edge). However, it can produce quite pleasing results providing the viewing angle is not too shallow.

final material

Note that there are multiple Image Texture nodes and each must be set appropriately - the 'main' Image Texture and the first column should be set to the actual image while the second column set to the 'blurred alpha' image.

Here's the final result :

final result - animated

Despite appearances there is no additional geometry here - the depth is purely faked and the only geometry is the plane.

Blend file attached

While not suited to UV mapping (since the material cannot determine the scale or orientation of the face), it can be used with Object coordinates to allow the pattern to be repeated (change the Image Texture nodes to Repeat). Also, the Color of the Diffuse shaders can be fed from each 'layer' image rather than being set to a single color - so that the 'surface' color bleeds back along the projected surface. This can produce the following effect :

chainlink fence

$\endgroup$
10
$\begingroup$

A simple solution is to extrude the image plane (or add a Solidify modifier) and use volumetrics to add the depth by driving the Density using the image Alpha channel.

image

Use the following material :

material

Here the image Alpha is used to mix between Diffuse and a Transparent shaders to produce the Surface. In addition, the Image is also used to control the density of volumetric Absorbtion and Scatter shaders. By using a Multiply node to increase the density the volumetrics can be made to appear more 'solid'.

The Color Ramp has been added to allow for control of the 'sharpness' of the edge by compressing the transition to one end of the alpha range.

This can produce the following result :

result

Note the MixRGB node set to 'Divide' used to manipulate the Color fed to the volumetric shader nodes. This is to allow the 'brightness' of the edges of the extruded image to be adjusted (darker Grey results in brightening of the color) - the volumetrics absorb some of the incident light which results in a much darker apparent surface so 'brightening' the color (by dividing by a value less than 1.0) adjusts for the absorption.

Blend file attached

$\endgroup$
  • $\begingroup$ Thanks, nice approach, a bit heavy but nice. Downside is that it works well in your configuration, thick mesh, light and point of view. In my case I try to use it for a fence chain, or usually thin mesh (I don't speak about depth). I continu exploring on that base but perhaps it's more something with angle calculation... $\endgroup$ – Mareck Jul 10 '17 at 13:02
  • $\begingroup$ It's not the most efficient solution, certainly, but should work with any input image, given a low enough step size in the volumetric settings (which will, of course, hit the performance even further). Without any reference image this was the best I could suggest. Depending on your particular case there could be a much better way... but requiring manipulation of the images used to drive it (I'm thinking an extra image to make each 'hole' distinct so we can detect edges in the same way as for the procedural hex grill) - although this would also require that any 'hole' is purely "concave". $\endgroup$ – Rich Sedman Jul 10 '17 at 13:14
  • $\begingroup$ If you can provide a reference image of what you require I'll see if I can come up with a suitable alternative approach. $\endgroup$ – Rich Sedman Jul 10 '17 at 13:28
  • $\begingroup$ I've forgot about geometry settings, it can change a lot, perhaps I'll have what I want. $\endgroup$ – Mareck Jul 10 '17 at 13:29
  • $\begingroup$ @RichSedman can i uses this node and just replace the image and use it $\endgroup$ – atek Oct 22 at 10:12
-2
$\begingroup$

using bump maps can kind of do what you want, I recommend just adding a solidify modifier, that's the best path

$\endgroup$
  • $\begingroup$ Thank you to help but bump maps are really not what I'm looking for. It don't make the effect at all. $\endgroup$ – Mareck Jul 9 '17 at 10:34
-2
$\begingroup$

Instead of using solidify modifier you can just add the texture to plane and extrude it.That will give you the effect you want.

$\endgroup$
  • 1
    $\begingroup$ Thanks too but solidify or extrude is the same result, and it's not what I'm looking for, there is no thickness, only a kind of on the border of the mesh. $\endgroup$ – Mareck Jul 9 '17 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.