[solved/explained]Why issue?

Hello, im not so familiar with gl context, so i dont know why it happends.

When i add more textures to terrain, i got:

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ArrayIndexOutOfBoundsException: 16
at com.jme3.renderer.opengl.GLRenderer.bindTextureAndUnit(GLRenderer.java:2286)


when i remove light probe generating, or parallax material params, then no error is shown.

it looks like some GPU memory overflow related?

Thanks for any help. (its for both lwjgl 2 and 3)

There is an hard limit of 16 textures per material in jme,

1 Like

why then it show only when i make a lightProbe?

anyway 16 textures seems low.

so if terrain have 3 alpha maps = 3 textures
then 11 albedo textures is 14 textures total

then when count normalmaps for all then its already not enough.’
counting parallaxmap even more.

Anyway thanks for tip. if its trully related, when would need create more terrain grids, just with different material to get more overall textures with high quality.

why then it show only when i make a lightProbe?

because the light probe uses 1 additional texture

anyway 16 textures seems low.

16 is the minimum guaranteed by the specifications.

For usecases like yours it is often a good idea to use texture arrays, doing that would increase the texture limit (you can have up to 256 layers per tx array in opengl 3.3) while also improving the quality of the code.

1 Like

thanks for explain.

heard a lot that Nehon wanted to use Texture arrays, but idk why he did not made it. seems not so easy then.

JME terrain have 9 grids, and all of them share same material. so i thought why not make in editor material edit for each grid, then i would make grid 4 texture(with albedo/normal/parallax) choose to use. so other grid would use other textures. seems like easy solution. (ofc seams would need share same texture)

I made a few, but you have to retain an order they are added in that has to be documented. They also all have to be the same dimensions, DPI and format - which can be a pain at times.

The implementation is there if you wanted to see how it’s done.

1 Like


i understand you use below to make auto-height based textures?

// texture coords
vec4 coords = vVertex;

vec4 col1 = texture2DArray( m_Textures, vec3(coords.yz * m_Tex1Scale, 1.0) );
vec4 col2 = texture2DArray( m_Textures, vec3(coords.xz * m_Tex1Scale, 1.0) );
vec4 col3 = texture2DArray( m_Textures, vec3(coords.xy * m_Tex1Scale, 1.0) );

so if i dont i should just use:

vec4 col1 = texture2DArray( m_Textures, vec3(coords.xy, 1.0) );
vec4 col2 = texture2DArray( m_Textures, vec3(coords.xy, 1.0) );
vec4 col3 = texture2DArray( m_Textures, vec3(coords.xy, 1.0) );

or maybe some one-line way for full vec4?

That part is for triplanar mapping. Notice the 3D texture coord twizzling, gives it away. There should be a material for both height based and non-height based. They are virtually direct ports of the built in materials except with arrays.

1 Like

ah right, sorry didnt seen.