Skip to content

A piece of code, I want to know his inner workings #2379

@shanfl

Description

@shanfl

There is a piece code in file 'sources/engine/Stride.Rendering/Rendering/Lights/LightClusteredPointSpotGroupRenderer.cs', I find it in many project ,like tiled forward rendering . but I reall hard to understand what it mean .

private static void UpdateClipRegion(
                        float lc,          // Light x/y coordinate (view space)
                        float lz,          // Light z coordinate (view space)
                        float lightRadius,
                        float cameraScale, // Project scale for coordinate (_11 or _22 for x/y respectively)
                        float cameraOffset, // Project offset for coordinate (_31 or _32 for x/y respectively)
                        ref float clipMin,
                        ref float clipMax)
            {
                float rSq = lightRadius * lightRadius;
                float lcSqPluslzSq = lc * lc + lz * lz;
                float d = rSq * lc * lc - lcSqPluslzSq * (rSq - lz * lz);

                '''
            }

In begin of this function , there is

                float rSq = lightRadius * lightRadius;
                float lcSqPluslzSq = lc * lc + lz * lz;
                float d = rSq * lc * lc - lcSqPluslzSq * (rSq - lz * lz);

I wonder about his rationale! plz.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions