Update animated parameters by getting current time from renderer#234
Update animated parameters by getting current time from renderer#234usakhelo merged 3 commits intoappleseedhq:masterfrom
Conversation
| { | ||
| float sun_theta_deg = m_sun_theta; | ||
| float sun_phi_deg = m_sun_phi; | ||
| const TimeValue time = get_current_time(); |
|
|
||
| void OSLMaterial::Update(TimeValue t, Interval& valid) | ||
| { | ||
|
|
| 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(); |
| else | ||
| m_pblock->GetValue(tex_param.first, t, tex_map, m_params_validity); | ||
|
|
||
| if (tex_map) |
| { | ||
| Texmap* tex_map = nullptr; | ||
| m_pblock->GetValue(tex_param.first, t, tex_map, m_params_validity); | ||
| if (tex_map) |
| Texmap* texmap) | ||
| { | ||
| const auto t = GetCOREInterface()->GetTime(); | ||
| TimeValue time = get_current_time(); |
| const float const_value) | ||
| { | ||
| const auto t = GetCOREInterface()->GetTime(); | ||
| const auto time = get_current_time(); |
There was a problem hiding this comment.
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(); |
| Texmap* source_map; | ||
| m_pblock->GetValue(ParamIdSourceMap, t, source_map, m_params_validity); | ||
|
|
||
| if (source_map) |
|
|
||
| // appleseed-max headers. | ||
| #include "appleseedoslplugin/osltexture.h" | ||
| #include "appleseedrenderer/appleseedrenderer.h" |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
We conventionally keep two blank lines before block comments.
| { | ||
| public: | ||
| explicit MaxShadeContext(const asr::SourceInputs& source_inputs) | ||
| explicit MaxShadeContext(const asr::SourceInputs& source_inputs, TimeValue time) |
There was a problem hiding this comment.
explicit has become redundant here, not that it really hurts...
| { | ||
| public: | ||
| explicit MaxProceduralTextureSource(Texmap* texmap) | ||
| explicit MaxProceduralTextureSource(Texmap* texmap, TimeValue time) |
| private: | ||
| Texmap* m_texmap; | ||
| Texmap* m_texmap; | ||
| TimeValue m_time; |
There was a problem hiding this comment.
Can it be made const here too? (I think so.)
| { | ||
| public: | ||
| MaxProceduralTexture(const char* name, Texmap* texmap) | ||
| MaxProceduralTexture(const char* name, Texmap* texmap, TimeValue time) |
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.