Is it OK for a camera to see its camtex?

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Is it OK for a camera to see its camtex?

Postby Enjay » Wed Jan 20, 2021 1:49 pm

Simple question that I should know the answer too - is it OK for a camera that is the source viewpoint for a camera texture to be in a position where the camera can "see" the camera texture that it is projecting too?

It doesn't seem to be a problem, so I guess there is something preventing infinite recursions, but I just wanted to check.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Is it OK for a camera to see its camtex?

Postby Rachael » Wed Jan 20, 2021 3:15 pm

Well technically what will happen is you will simply see the previous frame when the current one is rendered, so no, it shouldn't be too much of an issue. The problem with infinite recursion would simply come from marking the texture as needing a refresh as it is being shown, but if it works now then that's not likely going to be an issue.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Is it OK for a camera to see its camtex?

Postby Enjay » Wed Jan 20, 2021 6:20 pm

OK, thanks, that gives me peace of mind.

I wanted the player to be able to see himself on a monitor but that, obviously, means that the camera needs to be able to see the player, and the player needs to be near the monitor.

I've actually managed to set it up so that most, maybe even all, of the camera texture is just out of view behind a wall as far as the camera is concerned. The player can see the monitor in its alcove, can't get right into the alcove so the camera can see the player but I don't *think* it can quite see the monitor.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Is it OK for a camera to see its camtex?

Postby phantombeta » Wed Jan 20, 2021 6:29 pm

Rachael wrote:Well technically what will happen is you will simply see the previous frame when the current one is rendered, so no, it shouldn't be too much of an issue. The problem with infinite recursion would simply come from marking the texture as needing a refresh as it is being shown, but if it works now then that's not likely going to be an issue.

It also depends on how it's being rendered. It needs to be using a separate buffer for rendering, or it'll try to read from the same texture it's drawing to, which is undefined behaviour on all the hardware rendering APIs GZDoom supports, as far as I know.
It generally shouldn't crash, just result in garbage input, but since it's undefined behaviour, there's no guarantees.
If it's using a separate buffer, though (e.g., for double buffering), it should do exactly as Rachael described.
User avatar
phantombeta
Tired of being treated like trash by control freaks
 
Joined: 02 May 2013

Re: Is it OK for a camera to see its camtex?

Postby Graf Zahl » Fri Jan 22, 2021 12:55 am

The rendering is directed to a framebuffer which only gets converted into a texture after rendering is complete.

BTW, the first camera to be found in Duke3D also points directly to a monitor where its view can be seen on.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Is it OK for a camera to see its camtex?

Postby Ravick » Sun Jan 24, 2021 12:11 am

An old and never released map of mine uses a camtex in a computer monitor to show some content to the player, and, if the player continues to use the console, it eventually turns the player into the cam himself and he is still able to watch the monitor:

Spoiler:


This map is many years old now, and I never run into problems with that.

In older (can't rly tell which ones) versions of GZDoom, the view got rendered multiple times into the camtex. Current version seems to render it only twice and then render just black in place of the next smaller inner ones.
User avatar
Ravick
Do what thou wilt, since you don't bug the hell out of me!
 
Joined: 22 Aug 2010
Location: Tubarão, Brasil


Return to Mapping

Who is online

Users browsing this forum: No registered users and 0 guests