urho3d/urho3d

Cluster forward/deferred rendering?

swq0553 opened this issue · 2 comments

Has anyone tried to implement a “Cluster forward/deferred rendering” renderpath?

Yes. It wasn't pleasant and required implementing even more primitive compute than I submitted to RBFX. I Gave Clustered, Spherical-Coordinate cells, and Sphere-tree BVH the run. I've stuck to Sphere-tree BVH as I moved to a pulling pipeline.

Atlasing shadowmaps is where most attempts will fail as the shader changes for those aren't really obvious.

You can classify analytic lights via:

bool Light::IsAnalytic() const
{
    if (auto renderer = GetSubsystem<Renderer>())
    {
        // must use defaults, which we can reproduce with math in the shader
        if (renderer->GetDefaultLightRamp() != rampTexture_ ||
            renderer->GetDefaultLightSpot() != shapeTexture_)
            return false;
    }

    // Although analytic it doesn't make sense for a directional light to not cast-shadows except
    // in some really odd situations (non-photoreal)
    if (lightType_ == LIGHT_DIRECTIONAL)
        return false;

    // Must not cast shadows to be analytic
    return !GetCastShadows();
}

Chopping lights into analytical and non-analytical lights means you can bunch them up according. Analytical lights can just be pumped through a renderpass in bulk repurposing the vertex-lighting basepass, while non-analytical lights require proper passes.

Today I see what I did wrong years ago, but it's impossible to implement in current Urho3D core.

Marking this stale since there has been no activity for 30 days.
It will be closed if there is no activity for another 15 days.