From 76cdf4adf351780be65fecc4e83823ddc2a77a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilhelm=20Bj=C3=B6rkstr=C3=B6m?= <143391787+Grantallkotten@users.noreply.github.com> Date: Fri, 9 May 2025 16:07:22 +0200 Subject: [PATCH] Accretion disk texture Co-Authored-By: Emil Wallberg <49481622+EmilWallberg@users.noreply.github.com> --- modules/blackhole/rendering/accretion_disk.png | Bin 0 -> 601 bytes .../blackhole/rendering/renderableblackhole.cpp | 15 ++++++++++++++- .../blackhole/rendering/renderableblackhole.h | 3 ++- modules/blackhole/shaders/kerr_fs.glsl | 3 ++- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 modules/blackhole/rendering/accretion_disk.png diff --git a/modules/blackhole/rendering/accretion_disk.png b/modules/blackhole/rendering/accretion_disk.png new file mode 100644 index 0000000000000000000000000000000000000000..b73562e529e216abb35c0bd8cb28ea58ba8048f3 GIT binary patch literal 601 zcmeAS@N?(olHy`uVBq!ia0vp^>wuV%g9%8UP+@8Uaf*Z7ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS1YyP<6SLm}1tm&cBT9nv(@M${i&7Z^5;OBk^!!{y6ioFD z^~}4keYXUv*_ImNnda%K#lQjNurf$7vNA9NSzbUa4P}E|qru1w76-Yvp@3Xlx~Oh9v) zz$$|*Er2YjE<*zYkZks@YtoZ`O9X?$$kW9!L?d`@??%7F4gxOs*L{DN!>-uq!%|}M zhxPw|-UbZ~50xen1;Ng@*7~j@F7Agjy25SFo{;@7%-YJO#gQP;_xEhwmAWU)+8h=> z29B0aZA?s6cQO;$9$sJE$hj<}NlT2=bfv0ki^igJ53g@%aCJK3vqea7=A20>F@L)^ zFW2qZx7P2O)+^QD8&Y?t{C%^!b$|U%t-Gw#&5O*on@rYvVAq>G^Nz0PjL`Z#zng}E zo9k@#-k-kB&GdZkoU(1dPn>rDe<#7yD`o3fU$tFZ1U{-<(Oo$)f7|Jj^S3XxgQAGR M)78&qol`;+0H~F;umAu6 literal 0 HcmV?d00001 diff --git a/modules/blackhole/rendering/renderableblackhole.cpp b/modules/blackhole/rendering/renderableblackhole.cpp index 2de52e38b3..9469fc0058 100644 --- a/modules/blackhole/rendering/renderableblackhole.cpp +++ b/modules/blackhole/rendering/renderableblackhole.cpp @@ -190,6 +190,13 @@ namespace openspace { LWARNING("UniformCache is missing 'colorBVMap'"); } +#ifdef M_Kerr + ghoul::opengl::TextureUnit accretionDiskUnit; + if (!bindTexture(_uniformCache.accretionDisk, accretionDiskUnit, _accretionDiskTexture)) { + LWARNING("UniformCache is missing 'accretionDisk'"); + } +#endif // M_Kerr + SendSchwarzschildTableToShader(); SendStarKDTreeToShader(); @@ -343,7 +350,13 @@ namespace openspace { else { LWARNING(std::format("Failed to load environment texture from path '{}'", absPath(_colorBVMapTexturePath).string())); } - +#if M_Kerr + _accretionDiskTexture = ghoul::io::TextureReader::ref().loadTexture(absPath("${MODULE_BLACKHOLE}/rendering/accretion_disk.png"), 1); + + if (_accretionDiskTexture) { + _accretionDiskTexture->uploadTexture(); + } +#endif } void RenderableBlackHole::bindFramebuffer() { diff --git a/modules/blackhole/rendering/renderableblackhole.h b/modules/blackhole/rendering/renderableblackhole.h index 2ccc7a02e2..3f60b92301 100644 --- a/modules/blackhole/rendering/renderableblackhole.h +++ b/modules/blackhole/rendering/renderableblackhole.h @@ -79,11 +79,12 @@ namespace openspace { GLuint _ssboStarKDTree = 0; GLuint _ssboStarKDTreeIndices = 0; - UniformCache(environmentTexture, viewGrid, worldRotationMatrix, cameraRotationMatrix, colorBVMap, r_0) _uniformCache; + UniformCache(environmentTexture, viewGrid, worldRotationMatrix, cameraRotationMatrix, colorBVMap, r_0, accretionDisk) _uniformCache; std::unique_ptr _warpTableTex; std::unique_ptr _environmentTexture; std::unique_ptr _colorBVMapTexture; + std::unique_ptr _accretionDiskTexture; }; } // openspace namespace diff --git a/modules/blackhole/shaders/kerr_fs.glsl b/modules/blackhole/shaders/kerr_fs.glsl index 2ff087e761..16377be00a 100644 --- a/modules/blackhole/shaders/kerr_fs.glsl +++ b/modules/blackhole/shaders/kerr_fs.glsl @@ -10,6 +10,7 @@ in vec2 TexCoord; uniform sampler2D environmentTexture; uniform sampler2D viewGrid; +uniform sampler1D accretionDisk; uniform mat4 cameraRotationMatrix; uniform mat4 worldRotationMatrix; @@ -184,7 +185,7 @@ Fragment getFragment() { frag.color = vec4(0.0f); return frag; } else if(sphericalCoords.x == DISK){ - frag.color = vec4(clamp(sphericalCoords.y, 0.0, 1.0), 0.3*clamp(sphericalCoords.y, 0.0, 1.0), 0.15*clamp(sphericalCoords.y, 0.0, 1.0), 1.0f); + frag.color = vec4(texture(accretionDisk, sphericalCoords.y).rgb, 1.0f); return frag; } vec4 starColor = searchNearestStar(vec3(0.0f, sphericalCoords.x, sphericalCoords.y), l);