#Multiple camera.Render() by frame + lights

1 messages · Page 1 of 1 (latest)

pseudo zealot
#

Hello,

I have a pretty specific project on Unity 6 hdrp, where I create several textures filled with camera.render() while changing the materials (with a global parameter) in the scene, so it doesn't have the same color. And I do some other math with all the textures to generate the final one.

So far I managed to have materials and skybox working fine. And then i realized than lights won't work (swapping color or enabled/disabled isn't scheduled like my other stuff in the pipeline). Is it possible to make this work without rewriting the hdrp pipeline ? Maybe some custom pass magic or something ?
To be precise, I need to have any lights in the scene to switch to a specific color "between each" camera.render().

Thanks !

young pollen
#

This is outside of my knowledge but it may help to demonstrate what the result is meant to be?
From what I understand Camera.Render() incurs the massive overhead costs of HDRP cameras
Custom pass feature is worth looking into

grave kernel
#

So, if I get it correctly and sum it up, you want to have a way to render the same objects and point of view multiple times, with different materials and light settings.
Am I right ?

Indeed the out of the box approach is to use multiple calls of camera.render and change the settings in between. I'm surprised that changing the light parameters doesn't work though.

Does it have all to be in one frame ? Can't you delay this over multiple frames, for better performance and scheduling ?

The ultimate approach would be to use a custom pass (or maybe even modify HDRP like you mentioned) to reuse the culling results over multiple render calls, and only change the light data array. You could even save on time with deferred rendering by reusing the GBuffers.

pseudo zealot
# grave kernel So, if I get it correctly and sum it up, you want to have a way to render the sa...

All in one frame was the goal to remove any chance of lag, especially because I had a hard time to not have artefacts with double buffering. But of course I'll do that if no choice ( I already do it for several use case, like with path tracing).

I remember trying things with custom pass and failed miserably. But I don't remember why. Maybe just because I'm a newbie. Could you tell me more about the light data array access and reusing gbuffer ?

Thanks anyway!

Ps : to resume the context, I use one moving camera and X rendering cameras which copy the transform (several camera because of hdri cubemap cached). And I record X render texture with the same view, except I change material colour, hdri cubemap and light color between each texture. Then I use a compute shader with all the textures and display the result.

grave kernel
#

That setup must tank the performances quite heavily :/

The light data array is a big global buffer containing structs of all the lightings visible during a frame.
In theory, it should be possible to re-use all the culling that a camera already did, just change some values of that buffer, and render again.

But I'm not sure it could be done only with a custom pass and the custom pass API, it might need to alter the HDRP source code.

As for the GBuffer, in deferred all the surface data of opaque objects are rendered in screen space buffers and lit in a single pass afterwards.
If you only change material color of opaque objects, in theory you don't have to re-render everything, just keep the existing GBuffer and overwrite the objects with the changed materials. Then call the deferred lighting compute again.
But here also, I'm not sure that it can be achieved only with a custom pass.

pseudo zealot