godot-texture-painter icon indicating copy to clipboard operation
godot-texture-painter copied to clipboard

Shader Android support

Open dnikic opened this issue 2 years ago • 1 comments

Hello,

I am currently porting your app to Android, and planing to make a PR if I succeed. Unfortunate what seems to be blocking me are the shaders.

Using GLES3 works fine on desktop (Ubuntu 22.04), while it causes the Suzanne mesh to disappear on Android. Strangely, I can see the texture being drawn on the albedo texture, so It's not an issue with loading the mesh.

Using GLES2 shown the mesh on both desktop and Android, but causes the texture painting to break because the shaders rely on textureSize, texelFetch and maybe some other logic which is GLES3 specific.

I've read the official docs for conversions between GLES2 and GLES3, but did not have much success. https://docs.godotengine.org/en/stable/tutorials/rendering/gles2_gles3_differences.html You can see a code snippet of my attempt to port the sahder to GLES2:

			//Skip pixels outside bounds (TODO ensure this actually makes it faster)
			// if (point.x < 0 || point.x >= textureSize(SCREEN_TEXTURE, 0).x || point.y < 0 || point.y >= textureSize(SCREEN_TEXTURE, 0).y)
			if (point.x < 0 || float(point.x) >= SCREEN_PIXEL_SIZE.x || point.y < 0 || float(point.y) >= SCREEN_PIXEL_SIZE.y)
				continue;
			
			//Okay, fixed it, must use SCREEN_TEXTURE instead of meshtex_pos here
			// vec4 pos_col = texelFetch(SCREEN_TEXTURE, point, 0);
			vec4 pos_col = texture(SCREEN_TEXTURE, UV);

Could you please provide me some hints on how to handle these shader issues?

dnikic avatar Feb 12 '23 21:02 dnikic

These are my current findings. Materials on android only support "Depth Draw Mode" set to "Opaque only". I still need to do something about loading images int oGLES3 on android, so they don't turn out only black.

Turning off the mipmapping on the material did not help with the back textures as stated here: https://www.reddit.com/r/godot/comments/lizvg1/how_to_avoid_black_textures_on_android_with_gles3/

dnikic avatar Feb 18 '23 21:02 dnikic