[Scummvm-git-logs] scummvm master -> 7cf428776e43e7ff7c4904dc3698a80d7049d3ec
neuromancer
noreply at scummvm.org
Sun Mar 1 14:08:02 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
7cf428776e FREESCAPE: enable thunder effect in DOS with shaders
Commit: 7cf428776e43e7ff7c4904dc3698a80d7049d3ec
https://github.com/scummvm/scummvm/commit/7cf428776e43e7ff7c4904dc3698a80d7049d3ec
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2026-03-01T15:07:46+01:00
Commit Message:
FREESCAPE: enable thunder effect in DOS with shaders
Changed paths:
engines/freescape/games/castle/dos.cpp
engines/freescape/gfx_opengl_shaders.cpp
engines/freescape/gfx_opengl_shaders.h
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index c7cb608783d..5579106ab21 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -222,7 +222,14 @@ void CastleEngine::loadAssetsDOSFullGame() {
_riddleBottomFrame = loadFrameWithHeaderDOS(stream);
_endGameThroneFrame = loadFrameWithHeaderDOS(stream);
// No header
- Graphics::ManagedSurface *thunderFrame = loadFrameFromPlanes(stream, 32, 128);
+ Graphics::ManagedSurface *thunderFrame;
+
+ thunderFrame = loadFrameFromPlanes(stream, 16, 112);
+ thunderFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+ _thunderFrames.push_back(thunderFrame);
+
+ stream->seek(-0x160,SEEK_CUR);
+ thunderFrame = loadFrameFromPlanes(stream, 16, 112);
thunderFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
_thunderFrames.push_back(thunderFrame);
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index 413b9da1f28..b689f982f95 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -202,6 +202,87 @@ void OpenGLShaderRenderer::drawSkybox(Texture *texture, Math::Vector3d camera) {
_cubemapShader->unbind();
}
+void OpenGLShaderRenderer::drawThunder(Texture *texture, const Math::Vector3d position, const float size) {
+ OpenGLTexture *glTexture = static_cast<OpenGLTexture *>(texture);
+
+ // Compute eye-space position of the thunder
+ // Convention: matrix(col, row) maps to column-major layout
+ const Math::Matrix4 &mv = _modelViewMatrix;
+ float ex = mv(0,0)*position.x() + mv(1,0)*position.y() + mv(2,0)*position.z() + mv(3,0);
+ float ey = mv(0,1)*position.x() + mv(1,1)*position.y() + mv(2,1)*position.z() + mv(3,1);
+ float ez = mv(0,2)*position.x() + mv(1,2)*position.y() + mv(2,2)*position.z() + mv(3,2);
+
+ // Build billboard model-view with Rz(-90) rotation and eye-space translation
+ // cos(-90) = 0, sin(-90) = -1
+ Math::Matrix4 billboardMV;
+ billboardMV(0, 0) = 0.0f; billboardMV(0, 1) = -1.0f; billboardMV(0, 2) = 0.0f; billboardMV(0, 3) = 0.0f;
+ billboardMV(1, 0) = 1.0f; billboardMV(1, 1) = 0.0f; billboardMV(1, 2) = 0.0f; billboardMV(1, 3) = 0.0f;
+ billboardMV(2, 0) = 0.0f; billboardMV(2, 1) = 0.0f; billboardMV(2, 2) = 1.0f; billboardMV(2, 3) = 0.0f;
+ billboardMV(3, 0) = ex; billboardMV(3, 1) = ey; billboardMV(3, 2) = ez; billboardMV(3, 3) = 1.0f;
+
+ // Build MVP using the same pattern as drawSkybox/positionCamera
+ Math::Matrix4 proj = _projectionMatrix;
+ Math::Matrix4 model = billboardMV;
+ proj.transpose();
+ model.transpose();
+ Math::Matrix4 thunderMVP = proj * model;
+ thunderMVP.transpose();
+
+ // Build quad geometry (two triangles)
+ float half = size * 0.5f;
+ float quadVerts[] = {
+ -half, -half, 0.0f,
+ half, -half, 0.0f,
+ half, half, 0.0f,
+ -half, -half, 0.0f,
+ half, half, 0.0f,
+ -half, half, 0.0f,
+ };
+ float quadTexCoords[] = {
+ 0.0f, 0.0f,
+ 0.0f, 0.72f,
+ 1.0f, 0.72f,
+ 0.0f, 0.0f,
+ 1.0f, 0.72f,
+ 1.0f, 0.0f,
+ };
+
+ _cubemapShader->use();
+ _cubemapShader->setUniform("mvpMatrix", thunderMVP);
+
+ // Upload quad vertex data
+ glBindBuffer(GL_ARRAY_BUFFER, _cubemapVertVBO);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(quadVerts), quadVerts, GL_DYNAMIC_DRAW);
+
+ // Upload quad texcoord data
+ glBindBuffer(GL_ARRAY_BUFFER, _cubemapTexCoordVBO);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(quadTexCoords), quadTexCoords, GL_DYNAMIC_DRAW);
+
+ // Bind thunder texture
+ glBindTexture(GL_TEXTURE_2D, glTexture->_id);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ // Additive blending for glow effect
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE);
+ glDisable(GL_CULL_FACE);
+
+ // Draw the textured quad
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ // Restore skybox vertex data in the VBO
+ glBindBuffer(GL_ARRAY_BUFFER, _cubemapVertVBO);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(_skyVertices), _skyVertices, GL_DYNAMIC_DRAW);
+
+ // Restore state
+ glDisable(GL_BLEND);
+ glEnable(GL_CULL_FACE);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ _cubemapShader->unbind();
+}
+
void OpenGLShaderRenderer::updateProjectionMatrix(float fov, float aspectRatio, float nearClipPlane, float farClipPlane) {
float xmaxValue = nearClipPlane * tan(Math::deg2rad(fov) / 2);
float ymaxValue = xmaxValue / aspectRatio;
diff --git a/engines/freescape/gfx_opengl_shaders.h b/engines/freescape/gfx_opengl_shaders.h
index 898bcb362ee..e6fb9d0affc 100644
--- a/engines/freescape/gfx_opengl_shaders.h
+++ b/engines/freescape/gfx_opengl_shaders.h
@@ -96,6 +96,7 @@ public:
virtual void renderPlayerShootRay(byte color, const Common::Point &position, const Common::Rect &viewPort) override;
void drawCelestialBody(Math::Vector3d position, float radius, uint8 color) override;
void drawSkybox(Texture *texture, Math::Vector3d camera) override;
+ void drawThunder(Texture *texture, Math::Vector3d position, float size) override;
virtual void renderCrossair(const Common::Point &crossairPosition) override;
More information about the Scummvm-git-logs
mailing list