Building a grill using meshes can result in possibly hundreds of thousands of vertices and faces. Tiling traditional image textures with alpha can save on memory, however they don’t reproduce the depth a mesh can convey.
Parallax Occlusion Mapping is a technique that distorts an image texture using normal maps to achieve an illusion of depth, however the result is sub-par compared to a mesh, and is even complicated further when transparency is involved.
Procedural Parallax Occlusion Mapping however can reproduce a high quality illusion of depth for regular textures such as grills with depth and are very cheap to compute in real time while also using very little memory.
This is my first version worth showing but it still needs some work before I release something usable by everybody.
Check out the Youtube video and let me know what you think!
EDIT: Forgot to mention that it works in Cycles and Eevee with no problems.
EDIT #2: New version 0.1.1 with one bug fix and a cleaner interface.
In the meantime, here’s something of the geometry and algebra involved in creating the shader.
If people are truly interested I can create a tutorial explaining how I worked the math using online tools and then built the nodes to make it do what it does.
Thank you for the quick reply. I think a lot of people will be interested in a tutorial. But if you can share the shader blend file people who don’t have algebra background will be more happy. For example me😁
@Saabi Nice work!! FYI, I recently added a patch to add multiply to the vector math node. Hopefully this will make node groups like yours a little bit more manageable. See: https://developer.blender.org/D3786
Also, you can get vector length from the vector math node Value socket when it is set to Normalise.
I just looked at the code adding scalar/vector product. That’s great news and thanks for adding it!
I have to ask however and perhaps you know why:
How come there are so few math functions built into the nodes?
It could really use matrix opeartions and even access to binormals besides tangents. I believe OSL does provide access to binormals, but if I were to use it in this shader it woudln’t be portable to the GPU.
The reason being that the rest of the shader is specifically tailored towards building the illusion of light reflecting inside a cylinder.
I plan to build more procedural POMs later on including rectangular and hexagonal grills, and perhaps even an image texture based POM, but it’s not there yet.
It might be useful if you post the question in https://devtalk.blender.org/ with some suggestions about which OSL functions you’d like to see added as nodes. I’m willing to make a patch adding them if they’re not too difficult!!
I think in the past, adding nodes to Cycles was not encouraged due to technical limitations. I think this is no longer the case so the core developers maybe more willing to add additional nodes. I think if there is also a push to a more intuitive UX then adding more nodes would make node trees much simpler.
While the grill hole is parallax-occlusion mapped, the beveled edge is only parallax mapped. That is, if you look at it from a very steep angle you still get to see the parts that should be occluded. But it´s parallax mapped anyway so it deforms in a way akin to what the real shape should.
In the image above you can compare a real mesh to the procedural texture and see, that up to that angle at least, it is still very similar.
But as the angle gets steeper, although the illusion is still convincing, specially from far away (you don’t want to be looking at grills from this close anyway, right?), you start to see some discrepancies with the way I chose to map the distortions.
This is why I think algebra people are aliens. Their brain is much more complicated than the normal people.
Really fantastic. Details without geometry. Hope my old laptop can handle it
Thank you.
Thanks for the compliment, but while I do enjoy figuring things out, I consider myself mostly a visual thinker that’s forced into the algebra in order to achieve what I’m imagining.
I actually solved this last year in GLSL and then forgot completely about how to solve it and had to work all the math again this time, like if I had never done it before. ¯_(ツ)_/¯
I think doing a tutorial would demystify a lot of what’s involved in doing so and show how intuition plays more of a role than actual knowledge of math.