Handling negative scale

In Urho3D the render code always respects culling set in the material.

Batch::Prepare:

        CullMode effectiveCullMode = pass_->GetCullMode();
    // Get cull mode from material if pass doesn't override it
    if (effectiveCullMode == MAX_CULLMODES)
        effectiveCullMode = isShadowPass ? material_->GetShadowCullMode() : material_->GetCullMode();

In Unity3D if Scale of an object is set to negative value so the object matrix changes handedness it flips culling mode (at least it looks like in). As a result an object with a scale (1,1,-1) still looks correct.

Should Urho3D do the same thing?

Or maybe I’m getting this wrong and there is another way to achieve same effect.

1 Like

This might be useful:

Maybe change the condition of the if-statement to one checking for a negative scale product of the ModelViewMatrix? …and then negate vNormal.

Something should be done on engine side to culling otherwise vertex shader won’t be executed. Actually this could be done in compute shader but there isn’t one available for all platforms :frowning:

vNormal has nothing to do with the culling, so shaders are not a solution.

@glebedev culling is currently configured here:

But the issue is that drawable scale is already lost at thus point, you only have an array of world transforms that may have different meanings depending on geometry type.
What’s worse, you may have instancing enabled here, and you cannot render both inverted and normal geometry in one call.
So if you want to do something, you have to do it somewhere before instancing.

1 Like

Thanks, I’m spitting in the dark here. :slightly_smiling_face: