Simul Support ExchangeSDK integration doubts
Raffaele Bratta asked 4 years ago

Apologize me if some of the questions below may appear dumb, but the documentation is scarce (and apparently also outdated) and the samples don’t of course cover all the edge cases.
Without going deep into details, suppose this is how my engine renders things:

frame a
{
    update scene_graph

    render reflection_probe (face +X)
    render reflection_probe (face -X)
    render reflection_probe (face +Y)

    render main_rt
}

frame b
{
    update scene_graph

    render reflection_probe (face -Y)
    render reflection_probe (face +Z)
    render reflection_probe (face -Z)

    render main_rt
}

And the rendering of frame a and frame b repeats over time. So, basically, in each frame the scene graph is updated first, then three faces (of six) of a reflection probe cubemap are rendered and, at the end, the main render target (which contains what you will see in the window) is finally rendered.
The Environment::Update method has to be invoked once per-frame right? E.g., in my scenario, between the scene graph update and the reflection probe rendering. The simulation time step is not anymore a parameter of that method, is it handled by Environment::SetRealTime now? Considering the simulation time step constant, can I invoke that method just once after Environment object creation?
Can multiple instances of Environment and BaseWeatherRenderer coexist at the same time? E.g., suppose I have two levels loaded with two different sky settings. One level is in running state (and for which update and render is called) while the other one is in pause state. Upon the occurence of certain events, I have to swap the running/pause states between the two levels.
Does DeviceContext::frame_number must be constant over all the frame, right? I mean:

frame a { update scene_graph; frame_number = n;     render ... }
frame b { update scene_graph; frame_number = n + 1; render ... }
frame a { update scene_graph; frame_number = n + 2; render ... }
frame b { update scene_graph; frame_number = n + 3; render ... }
...

And so on.
Does ViewStruct::view_id must be different for every render target? I mean:

reflection_probe (face +X) -> view_id = 1
reflection_probe (face -X) -> view_id = 2
reflection_probe (face +Y) -> view_id = 3
reflection_probe (face -Y) -> view_id = 4
reflection_probe (face +Z) -> view_id = 5
reflection_probe (face -Z) -> view_id = 6

main_rt -> view_id = 0

Does Environment::PreRenderUpdate must be called once per-view or once per-frame? I’m asking because the method takes a DeviceContext object as a parameter that contains the view/projection matrices and which, in my scenario, can be different between a view and another.

The documentation talks about a is_cubemap parameter of the Environment::Render method to lightweight the sky rendering cost, but that parameter isn’t present anymore. Has it been replaced by TrueSkyRenderMode renderMode parameter? What’s the purpose of the following parameters: crossplatform::Texture *cubemapTexture, vec3 cubemap_ground_colour and int amortization?

1 Answers
Andrew Richards Staff answered 4 years ago

Hi Raffaelle,
Environment::Update() should be called once per frame; Environment::SetRealTime() should also be called once per frame with an update rt_sec value.
As for multiple instances of Environment and BaseWeatherRender, this should be fine.
Yes, the DeviceContext::frame_number must be constant over all the frame. We use this value for any amortization rendering that trueSKY does.
There’s no need to have the separate ViewStruct::view_id per face. One for the reflection probe and for the main render target should work. See the usage of Skylight::Render(), which is updates the view and projection matrices.
BaseWeatherRenderer::PreRenderUpdate() doesn’t use deviceContext.viewStruct, so the view and projection matrices aren’t used or changed.
The ‘is_cubemap’ parameter of the BaseWeatherRender::Render() has been replaced by TrueSkyRenderMode renderMode parameter. Please use TrueSkyRenderMode::CUBEMAP.
At the moment ‘crossplatform::Texture *cubemapTexture’ isn’t being used.
‘vec3 cubemap_ground_colour’ is the ground colour used when compositing atmospherics to the screen.
‘int amortization’ is used to the set the amortization value the framebuffer associated with the view_id set in deviceContext.viewStruct.
I hope this helps you out, if you have any other question please don’t hesitate to ask.
Andrew