Identifying render viewport of render target Topic is solved

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Identifying render viewport of render target

Post by slapin »

Hi, all!
I render 4 viewports on same render target texture. I have RenderTargetListener attached and RenderQueue::RenderableListener,
I need to change material for all objects rendered to one of viewports. How can I identify particular viewport?

All examples doing this (i.e. depth) use separate render target and identify by render target, but I need to identify by viewport,
how can I do this?

@paroj ...

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: Identifying render viewport of render target

Post by rpgplayerrobin »

I guess you are writing to the same texture in different regions of it, and using 4 viewports, one for each 1/4 of the texture.
Then when you use "renderTarget->update()" (or if it is auto updated) you want the "preRenderTargetUpdate" function to understand which viewport is which? But that happens before any viewport is actually rendered to, so that will never work.

But, you could instead use "preViewportUpdate", which is also a part of the RenderTargetListener.
That way you know which viewport it comes from, since evt.source is a viewport.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Identifying render viewport of render target

Post by slapin »

rpgplayerrobin wrote: Sun Sep 07, 2025 12:11 pm

I guess you are writing to the same texture in different regions of it, and using 4 viewports, one for each 1/4 of the texture.
Then when you use "renderTarget->update()" (or if it is auto updated) you want the "preRenderTargetUpdate" function to understand which viewport is which? But that happens before any viewport is actually rendered to, so that will never work.

But, you could instead use "preViewportUpdate", which is also a part of the RenderTargetListener.
That way you know which viewport it comes from, since evt.source is a viewport.

Aw, thanks a lot for this one! You're right with everything and it solved my problem!