Class EmissivePowerSampler

Synopsis

#include <Source/Falcor/Experimental/Scene/Lights/EmissivePowerSampler.h>

class dlldecl EmissivePowerSampler : public EmissiveLightSampler

Description

Sample geometry proportionally to its emissive power.

Inheritance

Ancestors: EmissiveLightSampler

Structures

AliasTable

Methods

EmissivePowerSampler
~EmissivePowerSampler
createCreates a EmissivePowerSampler for a given scene.
generateAliasTableGenerate an alias table
setShaderDataBind the light sampler data to a given shader variable.
updateUpdates the sampler to the current frame.

Source

Lines 36-86 in Source/Falcor/Experimental/Scene/Lights/EmissivePowerSampler.h.

class dlldecl EmissivePowerSampler : public EmissiveLightSampler
{
public:
    using SharedPtr = std::shared_ptr<EmissivePowerSampler>;
    using SharedConstPtr = std::shared_ptr<const EmissivePowerSampler>;
    struct AliasTable
    {
        float weightSum;                ///< Total weight of all elements used to create the alias table
        uint32_t N;                     ///< Number of entries in the alias table (and # elements in the buffers)
        Buffer::SharedPtr fullTable;    ///< A compressed/packed merged table.  Max 2^24 (16 million) entries per table.
    };
    virtual ~EmissivePowerSampler() = default;
    /** Creates a EmissivePowerSampler for a given scene.
        \param[in] pRenderContext The render context.
        \param[in] pScene The scene.
        \param[in] options The options to override the default behavior.
    */
    static SharedPtr create(RenderContext* pRenderContext, Scene::SharedPtr pScene);
    /** Updates the sampler to the current frame.
        \param[in] pRenderContext The render context.
        \return True if the sampler was updated.
    */
    virtual bool update(RenderContext* pRenderContext) override;
    /** Bind the light sampler data to a given shader variable.
        \param[in] var Shader variable.
        \return True if successful, false otherwise.
    */
    virtual bool setShaderData(const ShaderVar& var) const override;
protected:
    EmissivePowerSampler(RenderContext* pRenderContext, Scene::SharedPtr pScene);
    /** Generate an alias table
        \param[in] weights  The weights we'd like to sample each entry proportional to
        \returns The alias table
    */
    AliasTable generateAliasTable(std::vector<float> weights);
    // Internal state
    bool                            mNeedsRebuild = true;   ///< Trigger rebuild on the next call to update(). We should always build on the first call, so the initial value is true.
    LightCollection::SharedConstPtr mpLightCollection;
    std::mt19937                    mAliasTableRng;
    AliasTable                      mTriangleTable;
};





Add Discussion as Guest

Log in