1

I need an help with shaders in Threejs. I've a plane where i must have a mixing between 10 different texture; now I use ShaderMaterial and I pass all textures that next are used for combining. Here my Fragment Shader code

vec3 CFull = texture2D(tFull, vUv).rgb;
vec3 CIndustria = texture2D(tIndustria, vUv ).rgb;
vec3 CCave = texture2D(tCave, vUv).rgb;
vec3 CRifiuti = texture2D(tRifiuti, vUv).rgb;
vec3 CEdile = texture2D(tEdile, vUv).rgb;
vec3 CEventi = texture2D(tEventi, vUv).rgb;
vec3 CMarine = texture2D(tMarine, vUv).rgb;
vec3 COil = texture2D(tOil, vUv).rgb;
vec3 CStrade = texture2D(tStrade, vUv).rgb;
vec3 CVerde = texture2D(tVerde, vUv).rgb; 

c = CFull * CIndustria * CCave * CRifiuti * CEdile * CEventi * CMarine * COil * CStrade * CVerde;
gl_FragColor = vec4(c, 1.0); 

It works well on Android or desktop but in iOS not work. If i use only 4/5 texture it works also in iOS...

Maybe it doesn't work because is too heavy? Do you have any tips to optimize my code? (or other solutions)

1 Answer 1

1

WebGL spec requires the browser to support at least 8 combined texture units. I presume your iOS device meets that minimum requirement of 8, but you're requesting 10.

You can visit webglreport.com on your iOS device and look for "Textures > Max Combined Texture Image Units" to see what its maximum support is. For example, my desktop allows up to 32, but my iPhone's limit is lower.

enter image description here

If all you're doing to the textures is multiplying them together, you could use a 2D <canvas> context, blend them together there, then use THREE.CanvasTexture to convert the layered canvas into a single texture you can use in Three.js

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.