My own buggy portal implementation

This commit is contained in:
Vojta committed 2025-03-03 22:31:31 +01:00
1 parent ded1600175
commit 50314f1ad8
14 files changed
+446 -21

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
shader_type spatial;
render_mode unshaded;
uniform sampler2D albedo: hint_default_black, source_color;
varying float pixel_distance;
void vertex() {
// Calculate the world-space distance between the pixel and camera.
// Pass the distance to the fragment shader using a varying attribute.
vec3 world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
vec3 camera_position = (INV_VIEW_MATRIX * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
pixel_distance = distance(world_position, camera_position);
}
void fragment() {
// The portal color is simply the screen-space color of the exit camera render target.
// This is because the exit camera views the exit portal from the perspective of the player watching
// the entrance portal, meaning the exit portal will occupy the same screen-space as the entrance portal.
vec3 portal_color = texture(albedo, SCREEN_UV).rgb;
ALBEDO = portal_color;
}