#One frame delay after teleportation, SCREEN_UV shader.

1 messages · Page 1 of 1 (latest)

gleaming blaze
#

I am making an impossible geometry game using portals to fake the effect (subviewport as a texture).
Then, a shader and some math make the illusion, as in the video. A teleporter is in the middle to switch gate while keeping the same angle / velocity. The shader has culling off.

Problem is, while going at normal speed, there is a flicker caused by the camera, as you can see in the video.

Analyzing frame by frame, while teleporting the camera very briefly stand inside the teleporter, making it display the other side, causing a frame to flicker when finally exiting.

TL;DR

Player walks in World A, camera displays a preview of World B.
Player teleports into World B, but camera briefly shows World A since we swapped world (it shows the preview).
Player exits the teleporter, camera displays World B normally.

How to get rid of that singular frame previewing the world we just exited ?

I tried a few techniques, to make the teleporter a thick cube as seen here (https://youtu.be/cWpFZbjtSQg?si=67kca2XLB9MZ0RjM&t=567). But it persists.
I tried to make some math, but it goes over my head. I know the problem seems to be with the camera itself, but i've not worked with those settings much for my projects.

Here's my current shader logic.

`shader_type spatial;
render_mode blend_mix, cull_disabled, specular_schlick_ggx, unshaded;

uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;

void fragment() {

vec4 albedo_tex = texture(texture_albedo, SCREEN_UV);
ALBEDO = albedo_tex.rgb;

}`

Let me know if you have any questions. Appreciate any help.

Experimenting with portals, for science.

The project is available here: https://github.com/SebLague/Portals/tree/master
If you'd like to get early access to new projects, or simply want to support me in creating more videos, please visit https://www.patreon.com/SebastianLague

Resources I used:
http://tomhulton.blogspot.com/2015/08/portal-rende...

▶ Play video
unique stratus
#

your camera still seems to clip the portal plane

#

It's not just about having a single incorrect frame, you have frames where both worlds are showing at once

#

How did you set up the thick cube teleporter?

#

In any case, the solution will involve you somehow ensuring that the portal surface and the camera always have some minimum distance between them, so this clipping can't happen

#

You could move the portal surface away from the player before the teleport, for example

#

and after the teleport, have the other portal be already behind the player

#

You could do something like this: you simply push the surface a set amount into the direction the player is coming from

#

So when the player is in the position indicated by the green circle, the portal surface would be where the green line is

#

and when the player is in the position of the red circle, the portal surface is on the red line

#

You simply look at which side of the portal the player is on, and you give it an offset

#

if I am imagining this correctly, this should make your portals work correctly

#

Also!! You'd never use the offset position for determining when to teleport the player!

#

The teleport should always happen based on where the "real" position of the portal (aka the white line) is

#

Why this should fix the issue: there is a buffer zone between the line where the teleport happens & the surface where the other side is rendered