-
Notifications
You must be signed in to change notification settings - Fork 16
Update animated parameters by getting current time from renderer #234
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
Update animated parameters by getting current time from renderer #234
Conversation
| { | ||
| float sun_theta_deg = m_sun_theta; | ||
| float sun_phi_deg = m_sun_phi; | ||
| const TimeValue time = get_current_time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move inside the if below?
|
|
||
| void OSLMaterial::Update(TimeValue t, Interval& valid) | ||
| { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant blank line.
| auto shader_group_name = make_unique_name(assembly.shader_groups(), std::string(name) + "_shader_group"); | ||
| auto shader_group = asr::ShaderGroupFactory::create(shader_group_name.c_str()); | ||
|
|
||
| const TimeValue time = get_current_time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move inside if below?
| else | ||
| m_pblock->GetValue(tex_param.first, t, tex_map, m_params_validity); | ||
|
|
||
| if (tex_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make comparison explicit.
| { | ||
| Texmap* tex_map = nullptr; | ||
| m_pblock->GetValue(tex_param.first, t, tex_map, m_params_validity); | ||
| if (tex_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make comparison explicit.
| Texmap* texmap) | ||
| { | ||
| const auto t = GetCOREInterface()->GetTime(); | ||
| TimeValue time = get_current_time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make const.
| const float const_value) | ||
| { | ||
| const auto t = GetCOREInterface()->GetTime(); | ||
| const auto time = get_current_time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use TimeValue out of consistency with the rest of the code.
| const Color const_value) | ||
| { | ||
| const auto t = GetCOREInterface()->GetTime(); | ||
| TimeValue time = get_current_time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make const.
| Texmap* source_map; | ||
| m_pblock->GetValue(ParamIdSourceMap, t, source_map, m_params_validity); | ||
|
|
||
| if (source_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make comparison explicit.
src/appleseed-max-impl/utilities.cpp
Outdated
|
|
||
| // appleseed-max headers. | ||
| #include "appleseedoslplugin/osltexture.h" | ||
| #include "appleseedrenderer/appleseedrenderer.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it a bit concerning that utilities depends on appleseedrenderer: lower level components should never depend on higher level ones. Maybe get_current_time() should be declared in appleseedrenderer.{h,cpp}.
For the same reason I'm slightly concerned about the dependencies toward appleseedoslplugin/osltexture.h and osloutputselectormap/osloutputselector.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I make get_current_time in appleseedrenderer a global function, not the class member? So that I don't have to check and cast current renderer to get the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I meant. You could also make it a static method of AppleseedRenderer to highlight the dependency to that class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to move it to the renderer class but in some utilities I still need to call that function so I still need to include renderer header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other way is to pass time from the renderer to all that create_material and so on as an argument.
|
Hi @dictoon , |
|
This might be relevant: |
In my opinion, definitely the right solution as it makes dependencies clear. |
dictoon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Feel free to merge after you've addressed the few remaining details I reported.
| m_entities.clear(); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We conventionally keep two blank lines before block comments.
src/appleseed-max-impl/utilities.cpp
Outdated
| { | ||
| public: | ||
| explicit MaxShadeContext(const asr::SourceInputs& source_inputs) | ||
| explicit MaxShadeContext(const asr::SourceInputs& source_inputs, TimeValue time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit has become redundant here, not that it really hurts...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make time const.
src/appleseed-max-impl/utilities.cpp
Outdated
| { | ||
| public: | ||
| explicit MaxProceduralTextureSource(Texmap* texmap) | ||
| explicit MaxProceduralTextureSource(Texmap* texmap, TimeValue time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make time const.
src/appleseed-max-impl/utilities.cpp
Outdated
| private: | ||
| Texmap* m_texmap; | ||
| Texmap* m_texmap; | ||
| TimeValue m_time; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be made const here too? (I think so.)
src/appleseed-max-impl/utilities.cpp
Outdated
| { | ||
| public: | ||
| MaxProceduralTexture(const char* name, Texmap* texmap) | ||
| MaxProceduralTexture(const char* name, Texmap* texmap, TimeValue time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make time const.
Hi,
This PR fixes bug #212. OSL materials and textures were not updated during animation rendering. Now they are working. What I did is instead of getting current with the call
GetCOREInterface()->GetTime()I added a function to renderer to get currently rendered frame from the it.Thanks for review!
Sergo.