From 72cd2bdbe8c164892ee0406051099829a075da35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilhelm=20Bj=C3=B6rkstr=C3=B6m?= <143391787+Grantallkotten@users.noreply.github.com> Date: Tue, 20 May 2025 11:52:32 +0200 Subject: [PATCH] Made world alignment a const Co-Authored-By: Emil Wallberg <49481622+EmilWallberg@users.noreply.github.com> --- .../blackhole/shaders/schwarzschild_fs.glsl | 40 ++++--------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/modules/blackhole/shaders/schwarzschild_fs.glsl b/modules/blackhole/shaders/schwarzschild_fs.glsl index ed01e08004..54f78ce9ff 100644 --- a/modules/blackhole/shaders/schwarzschild_fs.glsl +++ b/modules/blackhole/shaders/schwarzschild_fs.glsl @@ -22,6 +22,13 @@ layout (std430) buffer ssbo_warp_table { const float PI = 3.1415926535897932384626433832795f; const float VIEWGRIDZ = -1.0f; +const mat4 alignToWorldAxisRotation = mat4( + 1.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, -1.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 1.0 +); + int layerCount, tableSize, num_rays; /********************************************************** @@ -40,36 +47,6 @@ float atan2(float a, float b){ return 0.0f; } -/********************************************************** - Init rotations -***********************************************************/ - -mat4 rotationToKerrPosition() { - float angle = -PI/2; - float c = cos(angle); - float s = sin(angle); - - mat4 rotX = mat4( - 1.0, 0.0, 0.0, 0.0, - 0.0, c, -s, 0.0, - 0.0, s, c, 0.0, - 0.0, 0.0, 0.0, 1.0 - ); - mat4 rotY = mat4( - c, 0.0, -s, 0.0, - 0.0, 1.0, 0.0, 0.0, - s, 0.0, c, 0.0, - 0.0, 0.0, 0.0, 1.0 - ); - mat4 rotZ = mat4( - -c, s, 0.0, 0.0, - -s, -c, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 - ); - return rotY * rotX * rotZ; -} - /********************************************************** Conversions ***********************************************************/ @@ -192,8 +169,7 @@ Fragment getFragment() { vec4 envMapCoords = vec4(sphericalToCartesian(envMapSphericalCoords.x, envMapSphericalCoords.y), 0.0f); // User world input rotation of the black hole - envMapCoords = worldRotationMatrix * envMapCoords; - envMapCoords = rotationToKerrPosition() * envMapCoords; + envMapCoords = alignToWorldAxisRotation * worldRotationMatrix * envMapCoords; sphericalCoords = cartesianToSpherical(envMapCoords.xyz); vec4 starColor = searchNearestStar(vec3(0.0f, sphericalCoords.x, sphericalCoords.y), l);