Hello !
I wrote a shader that unpacks mesh data for a voxel game and everything was working fine until I tested it on my Android phone … 3 FPS
After a lot of testing I found out where the problem comes from :
float3 normalVector = normals[normal];
If I replace that line by anything else (a switch for example), my FPS goes up to 30 !
normals is a constant array and normal is a uint :
static const float3 normals[] = {
float3(1,0,0), // x+
float3(0,0,1), // z+
float3(0,1,0), // y+
float3(-1,0,0), // x-
float3(0,0,-1), // z-
float3(0,-1,0), // y-
};
I don’t understand how this particular array can cause such a huge performance loss. The other constant arrays that I use in the shader don’t seem to cause any problems, I tried to remove the colors or the faceLightLevels array and that did not improve my frame rate.
Is there something I’m doing wrong ?
Here is the full shader :
VoxelShader.shader (4.6 KB)