Jump to content

[SOLVED] How to combine the render of two cameras?


photo

Recommended Posts

I'm making a first-person shooter and I want two cameras to work for me. The first - rendered the environment, and the second - hands with weapons. But I ran into a problem - Unigine shows the render only from the camera that has the Main Player check mark and ignores all other cameras. An attempt to set the Main Player check mark on two or more cameras only led to the fact that Unigine took the render of the lowest camera in the hierarchy, also ignoring all the others. How can I combine a render from two cameras?

Link to comment

@Zhenya

It is unclear for me to understand what do you mean by Combine a render from two cameras?

I generally do a two camera render and use it for multi viewing application. 

Some may use one render to show in virtual displays of main camera render.

What exactly you want to achieve? May you clarify?

Rohit

Link to comment
14 minutes ago, silent said:

I guess the main idea would be to render additional viewort on top of the main one with a help of WidgetSpriteViewort (similar to this example: https://developer.unigine.com/en/docs/latest/code/usage/mirrors_viewports_materials/).

Exactly, But it will require to do certain programming. Using the additional RenderTarget, rendert to texture and then use that texture, for next rendering.

But the above question asks for do it in scene graph. As @Zhenya trying to achieve it in editor.

Rohit

Link to comment

I think they mean "render in two passes/textures: 1 for the world, and 1 with the avatar". The final view combines the two.
But anyway, the solution is still based on the answer already given by silent:

1. `renderTexture2D` for the scene

2. `renderTexture2D` for the player's hands

3. use custom shader to combine Tex1 and Tex2 (Warning: there's going to be overdraw where the pixels for the player's hand overlap the world)

Edited by gr7.76
Link to comment
4 hours ago, rohit.gonsalves said:

@Zhenya

Мне непонятно, что вы подразумеваете под объединением рендеринга с двух камер?

Обычно я делаю рендеринг с двумя камерами и использую его для нескольких приложений просмотра.

Некоторые могут использовать один рендеринг для отображения в виртуальных дисплеях рендеринга основной камеры.

Чего именно вы хотите достичь? Можете ли вы уточнить?

Rohit

I want the renderers of the two cameras to overlap each other giving a result similar to this -

Link to comment
5 hours ago, silent said:

I guess the main idea would be to render additional viewort on top of the main one with a help of WidgetSpriteViewort (similar to this example: https://developer.unigine.com/en/docs/latest/code/usage/mirrors_viewports_materials/).

Yes, it looks like what I need. I tried to repeat the code and I got this code - https://paste.myst.rs/57w6e9rx . At startup, it gives me this error -image.thumb.png.39ad5056b4c95787459cb46b28d8c446.png

Link to comment
  • silent changed the title to [SOLVED] How to combine the render of two cameras?
×
×
  • Create New...