Instancing geometries with texture AND normal map?

Hi! I am instancing Geometries with their own texture as in the Operator Snippets: Geometry/texture instancing example.

Now I also want all of them to have unique normal maps, and maybe height maps et cetera. How to go about this? I found some solutions which were close with the GLSL MAT but that did not work on Mac M1. I’m on version 2023.12000.

Any ideas?

Hi @maaark,

The idea might be that you combine all normal maps and respectively height maps into single textures for which you then use the instanced texture coordinates of each instance to retrieve the necessary information in a glsl shader. This should work without issue also on a mac.

if you setup all maps in a Phong Shader and then output the shader as GLSL, you should see pretty early on in the vertex shader a call to define the heightMapColor:

vec4 heightMapColor = texture(sHeightMap, heightMapCoord.st);

instead of it using the heightMapCoord as the uv lookup, use the instance texcoord

Hope this helps
cheers
Markus

Thanks Markus! So with a texture atlas essentially. As I’m loading folders with all differently sized images, this will require some complex coding. I’ll try to wrap my head around it in the following weeks and will let you know how it goes!

Hi @maaark,

you could stretch all images to the largest resolution. Not sure of the amount of images - might become a big texture but this would avoid you having to do complex calculations.

cheers
Markus