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

Light tree #1505

Closed
wants to merge 195 commits into from
Closed

Light tree #1505

wants to merge 195 commits into from

Conversation

gospodnetic
Copy link
Member

Initial integration of the LightTree sampling. The tree can handle only point source lights. The point lights are flagged as LightTreeCompatible and, as such, extracted into a separate vector within the LightSampler

Since we know the lights within the LightTree can only be non physical for now, contributions from the LightTree within the DirectLightingIntegrator are added using the add_non_physical_light_sample_contribution(). It is something that works now but should be changed/expanded once I add other types of lights to the tree. I wouldn't change it now because I am not sure yet what and how should I change. I can duplicate the add_non_physical_light_sample_contribution() function and rename it into add_light_tree_sample_contribution() just to mark the spot that will be expanded.

Compare the retrieved position and calculated center of the bbox for both NPL and EM.
@@ -285,8 +285,8 @@ namespace
{
float node_probability(
const LightTreeNode<foundation::AABB3d>& node,
const foundation::AABB3d bbox,
const foundation::Vector3d surface_point)
const foundation::AABB3d& bbox,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation (1 indentation = 4 spaces only).

const foundation::Vector3d surface_point,
float s) const
const foundation::Vector3d& surface_point,
float s) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing I don't think I mentioned: whenver we indent stuff, we try to stick to tab "stops", i.e. multiples of 4 spaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spacing between the first argument and it's type should be multiple of 4 or the character column? (I tend to stick to column).

// Retrieve the importance multiplier.
float get_uncached_importance_multiplier() const;

// Set the light transformation.
void set_transform(const foundation::Transformd& transform);

// Set the flag that the light is LightTreeCompatible
bool is_light_tree_compatible() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I respectfully disagree, I think it somewhat clutters the renderer::Light interface by giving this flag a predominant place and by duplicating what can already be accomplished by checking the flags.

I think that

if (m_flags & LightTreeCompatible)`

is fairly readable, don't you think?

@@ -118,9 +113,13 @@ bool Light::on_frame_begin(
if (!ConnectableEntity::on_frame_begin(project, parent, recorder, abort_switch))
return false;

m_flags = 0;
if (is_light_tree_compatible())
if (m_flags & LightTreeCompatible)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's another approach indeed. The downside is that it won't work if we add another flag.

What I proposed is different, see the description on Slack.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as proposed

Copy link
Member

@dictoon dictoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second round of reviews. Almost there!!

import os

import appleseed as asr

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant blank line.

import numpy as np

import appleseed as asr

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant blank line.

output_scene_name = "output/" + str(grid_lights_count) + "x" + str(grid_lights_count) + "_" + color + "_point_lights"

def build_project():

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant blank line.

light.set_transform(asr.Transformd(mat))
assembly.lights().insert(light)
else:
print "Unknown color: ", color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to use Python 3's print syntax.

Add:

from __future__ import print_function

and then:

print("Unknown color: " + color)

or:

print("Unknown color: {0}".format(color))

'intensity_multiplier': "3"

})
light_position = asr.Vector3d( i, j, 0.2 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like in C++, no spaces before or after parentheses:

light_position = asr.Vector3d(i, j, 0.2)

{
public:
const AssemblyInstance* m_assembly_instance;
size_t m_object_instance_index;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include <cstddef>.

size_t m_object_instance_index;
size_t m_region_index;
size_t m_triangle_index;
foundation::Vector3d m_v0, m_v1, m_v2; // world space vertices of the triangle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include foundation/math/vector.h.

//

class LightSource
: public foundation::NonCopyable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include foundation/core/concepts/noncopyable.h.

// Destructor
virtual ~LightSource();

// Get the reference to the source position.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Get the light source position.

@@ -77,6 +77,9 @@ namespace
m_inputs.declare("intensity", InputFormatSpectralIlluminance);
m_inputs.declare("intensity_multiplier", InputFormatFloat, "1.0");
m_inputs.declare("exposure", InputFormatFloat, "0.0");

// Point lights can be used by the LightTree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End full line comment with a .

@gospodnetic
Copy link
Member Author

Updated with the requested changes :)

@gospodnetic gospodnetic closed this Jul 8, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants