Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance for Area Light #186

Open
zjxeditor opened this issue Aug 15, 2018 · 2 comments
Open

Instance for Area Light #186

zjxeditor opened this issue Aug 15, 2018 · 2 comments

Comments

@zjxeditor
Copy link

Hi, can we create instance for area light? I want to create multi area light with the same mesh geometry. But when I create the second light geometry use instancing, the program will crash. After experiment, I have to create a individual mesh geometry data for the second area light, then it will work.

@zjxeditor
Copy link
Author

I found it. In the following code:

RadeonRays::float3 AreaLight::GetPower(Scene1 const& scene) const
    {
        auto mesh = std::static_pointer_cast<Mesh>(m_shape);
        auto indices = mesh->GetIndices();
        auto vertices = mesh->GetVertices();

        auto i0 = indices[m_prim_idx * 3];
        auto i1 = indices[m_prim_idx * 3 + 1];
        auto i2 = indices[m_prim_idx * 3 + 2];

        auto v0 = vertices[i0];
        auto v1 = vertices[i1];
        auto v2 = vertices[i2];

        float area = 0.5f * std::sqrt(cross(v2 - v0, v1 - v0).sqnorm());
        return PI * GetEmittedRadiance() * area;
    }

@harokyang
Copy link

I think this GetPower() of AreaLight should respect the transform matrix of the shape
If a scale matrix is applied, the calculation of area here gives incorrect result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants