Skip to main content

Common Issues - Rendering

This page is dedicated to common issues surrounding rendering. If you are experiencing an issue that does not relate to rendering consider looking at one of the other pages in this section, which are also listed here.

Make sure to Update Playable!
A lot of times issues can be fixed by simply updating your plugin to the latest version, please make sure to check you are on the latest release version before looking further into this section. More info on how to do this here

Poor performance in the Safari browser#

If you are seeing a drop in performance when loading your playable in Safari, it is likely due to the fact that Safari has on average a lower performance rate than other browsers like Google Chrome.

This is due in part to reasons such as Safari having a less optimal JS array iteration.

Possible solution:

  • Optimise your playable further: E.g. reduce the amount of keyframes to no more than 10 per animation, reduce the vertex count on blendshapes to be as low as possible. Click here for more tips on optimisation.

Game flashes for a single frame when player drops an object#

If you are making use of TMP, and do not have the Resources folder marked for inclusion under Export type, this could be because the cause of the problem (As TMP settings are stored inside of the Resources folder).

Possible solution:

  • Tick the Resources option under Export type. More info on how to do this here.

Sprite images rendering on top of other sprites when they shouldn’t be#

This could be because shaders in WebGL are handled differently to shaders in Unity.

Possible solution:

  • For the sprite you wish to be rendered on top, change the renderer queue number in the shader settings to be higher than the shader for the sprite which is supposed to be underneath.

    images-small

Frame rate is low#

This could be due to having too many dense models being rendered in the scene.

Possible solution:

  • Select the model in Unity, click on the Model tab in the inspector, select Mesh Compression, and select one of the higher settings such as ‘High’. Then click ‘Apply’ at the bottom of the inspector.

    images-small

Z-fighting / flickering on iOS on a single object with multiple materials#

This is likely happening due to on iOS (and other platforms) floating point imprecision can cause flickering issues, as the vertices which make up the model can end up being slightly off.

E.g. the vertex on the first pass is at position 1.00000000003, but the second render pass the vertex is calculated at being in position 1.00000000001 which places it slightly behind the first vertex and therefore appears to be overlaying it.

The change in precision as the mesh or camera moves causes the flickering effect.

Possible solution:

  • Adjust the shader to give a slight offset between each of the render passes.
    For instance; on the first pass give the vertex a slight offset of 1.00000000001, and for the second pass offset the vertex by 1.00000000003. This forces the vertex to be rendered further forward in the Z order when being rendered.
    See below for a code example.

Pass 1. Line 10 pushes the vertex forward in the Z direction by 0.004 if running on a mobile device.

v2f vert(appdata v)                {                    v2f o;                    float3 wsNormal = normalize(UnityObjectToWorldDir(v.normal).xyz);                    float4 wsPosition = mul(unity_ObjectToWorld, v.vertex);                    wsPosition.xyz += wsNormal * _OutsideWallWidth;                    o.vertex = mul(UNITY_MATRIX_VP, wsPosition);                    o.screenCoords = ComputeScreenPos(o.vertex);#ifdef SHADER_API_MOBILE                    o.vertex.z += 0.004;#endif                    return o;

Pass 2. Line 10, pushes the vertex forward in the Z direction by 0.002 if running on a mobile device.

v2f vert(appdata v)                {                    v2f o;
                    float3 wsNormal = normalize(UnityObjectToWorldDir(v.normal).xyz);                    float4 wsPosition = mul(unity_ObjectToWorld, v.vertex);                    wsPosition.xyz += wsNormal * _OutlineWidth;                    o.vertex = mul(UNITY_MATRIX_VP, wsPosition);#ifdef SHADER_API_MOBILE                    o.vertex.z += 0.002;#endif                    return o;

Texture flickering / flashing between two different rotations each frame#

Possibly due to how Luna recalculates rotations. For example, if a rotation is being applied to the Z axis in Unity, the X axis will also have its values changed as the rotation happens. Then on the next frame the X axis has a new value, the rotation get applied to the Z axis again, which in turn causes the X axis to snap back to its original rotation. This switching happens which frame between the two rotations and therefore flickering occurs.

Possible solution:

  • In Unity, set the game object to the the correct rotation before runtime. For example, if a spinning crosshair image needs to lie flat on the a grass surface during gameplay, then ensure that the crosshair is also flat on the surface in the scene before runtime. You can then apply a the spinning rotation to a different axis.
    Also try setting the rotation values to 0 in the Unity scene before runtime, and only rotating the one axis needed to turn.
    Incorrect setup in scene (before runtime):
    images-medium
    Correct setup in scene (before runtime):
    images-medium

ParticleSystem Renderer does not contain definition for ‘material’#

Possible solution:

  • Access the material directly via code instead of through the particle system.

‘Particle system has NULL materials and won’t be rendered' error#

This could be due to some of the project's materials being either broken or unsupported within Luna. These broken materials, from a prefab, result in an error within a Luna build. Whilst in contrast Unity would omit the broken material and simply not show the associated GameObject.

Possible solution:

  • Check for a material error within the chrome dev tools console and find the game object name. Disable the GameObject that uses the broken material from within Unity and re-build for Luna.