Commit Graph
76 Commits
Author SHA1 Message Date
kichikuou f50c9f6d77 gfx: Add gfx_render_quadrilateral()
It draws a quadrilateral with arbitrary vertex and texture coordinates.

This is used to properly implement DrawGraph.DrawDeformedSpriteBilinear,
and will be used to implement ChipmunkSpriteEngine.
SP_SetSpriteTransformPos in a subsequent patch.
2025-05-16 09:13:06 +09:00
kichikuou 7ff5ec89e7 Implement effect number 60
Used in Rance Quest.
2025-03-23 08:22:16 +09:00
kichikuou 1cbf6125ce 3d: Implement vertex alpha
POL v2 models can have an alpha mod per vertex.
2024-10-20 08:25:42 +09:00
kichikuou 9b03741288 3d: Pack bone transform matrices
Before this, the BoneTransforms uniform block consumed
(4 * 4 * sizeof(float) * MAX_BONES) = 19712 bytes, which exceeds 16384,
the minimum possible value of GL_MAX_UNIFORM_BLOCK_SIZE in OpenGL ES
3.2.

Since the bone matrices are affine, we can drop the 4th rows and pack
them into a mat4x3 array. Now the BoneTransforms block is 14784 bytes
and it should work with all OpenGL ES 3.2 implementations.
2024-10-20 08:25:39 +09:00
kichikuou abd3a276a3 TapirEngine: Implement UVScroll mesh attribute 2024-10-20 08:16:24 +09:00
kichikuou d8ad22b638 TapirEngine: Simplify lighting
In TapirEngine, the following lighting features are not used:

- global ambient
- directional lights
- specular lights
- rim lights
- fog

(The setters / getters for these parameters are still there, but they
don't affect rendering.)

This implementation disables those features in GLSL using #ifdefs. The C
code that sets up the lighting remains almost unchanged --
glGetUniformLocation() will return -1 if the specified uniform variable
name is not found, and glUniform*(-1, ...) will be no-op.
2024-10-19 08:43:31 +09:00
kichikuou c04aa8a844 TapirEngine: Outline rendering
This implements outline (called "edge" in the game config) rendering of
3D objects, using the "inverted hull" method.
2024-10-13 07:18:49 +09:00
kichikuou 87b1e2abe2 Make variable names consistent between reign.v.glsl and reign_shadow.v.glsl
Pure refactoring, no behavior changes.
2024-10-13 07:18:49 +09:00
kichikuou c1ce2c88c6 3d: Increase MAX_BONES to 308
This is the maximum number of bones in a model for Rance Quest
(pasuteru_full.POL).

Now bone transform matrices are stored in a uniform buffer object,
because its size exceeds GL_MAX_VERTEX_UNIFORM_COMPONENTS in iOS Safari.
2024-10-12 07:35:51 +09:00
kichikuou 22a06b1da9 3d: Implement vertex colors
3D objects can have a color per vertex, which is multiplied with the
texture color.
2024-10-05 07:41:17 +09:00
kichikuou 2a7f58c187 Fix compile error of dungeon_raster.f.glsl on WebGL
`sample` is a reserved word in GLSL ES 3.0.
2024-09-19 12:55:21 +09:00
Nunuhara Cabbage 921c0b699c Fix glitch in EFFECT_TURN_PAGE shader
The first frame of this effect was not displayed correctly.
2024-08-05 10:57:41 -07:00
kichikuou b155b4b79f Add a parameter to gfx_draw_glyph() for controlling blending behavior
This adds a new parameter `blend` to `gfx_draw_glyph()`. When `blend` is
true, the function performs normal alpha blending (same as
`gfx_draw_glyph_to_pmap()`).

If `blend` is false, the resulting pixel color will be the text color
and the alpha value will be copied from the glyph texture. However, if
the alpha value is less than 0.01, the pixel will not be written.

If you are drawing on a transparent texture (which will later be blended
into another texture), `blend` should be false. If you are drawing on top
of an image, `blend` should be true.

`gfx_draw_glyph()` used to fill transparent pixels with text color, but
this step is no longer needed and has been removed.
2024-06-15 14:34:58 +09:00
kichikuou afae3fc9a6 DrawDungeon14: Implement raster effect
It is implemented as a post-processing effect. The hack for the
projection transform matrix has been removed, because now the image is
flipped upside down in the post-processing stage.
2023-09-01 21:45:46 +09:00
kichikuou 0e5d41a728 Implement DrawGraph.CopyGrayscale
Used in Daiteikoku.
2023-06-18 20:57:00 +09:00
Nunuhara Cabbage 2237bb814c Implement various HLL functions for Rance Quest
Most of the functionality of gfx_render_texture (draw method, blend
rate) is moved into sprite_render, since this was the only place using
it.
The draw method and blend rate are now stored in sact_sprite objects
instead of textures.
sact_sprite now has two renderers: the old SACT2 renderer (with blend
rate as the only shader parameter) and the new ChipmunkSpriteEngine
renderer, which supports multiply/add colors and the "surface area"
feature from PartsEngine.

Rance Quest now runs up to the first Flash-related function call
(Flash?!?!).
2023-02-12 15:59:36 -08:00
kichikuou de2db1af93 Implement DrawMovie, DrawMovie2 and PlayMovie HLLs
These HLLs play .mpg movie files (later games use .alm file extension,
but the format is the same, i.e. MPEG-PS) that contain MPEG1 video and
MP2 audio streams.

pl_mpeg.h is the PL_MPEG library (https://github.com/phoboslab/pl_mpeg)
imported from commit 5aeef4d07593be1960a0e4c7fe204809cfae30bd.

This adds a few mixer functions (mixer_stream_*) for playing custom
audio streams under the master mixer.
2023-01-06 12:12:07 +09:00
kichikuou 82407a1d59 Fix shader compilation errors in OpenGL ES 2023-01-01 11:50:03 +09:00
Nunuhara Cabbage f23d713f46 Merge pull request #91 from kichikuou/effect
Implement EFFECT_NOISE_CROSSFADE and EFFECT_SEPIA_NOISE_CROSSFADE
2022-12-27 10:11:54 -08:00
kichikuou 8aafb271f9 Implement EFFECT_NOISE_CROSSFADE and EFFECT_SEPIA_NOISE_CROSSFADE
EFFECT_SEPIA_NOISE_CROSSFADE is frequently used in Toushin Toshi 3.
2022-12-27 21:13:01 +09:00
kichikuou 2de5132803 ReignEngine: Support (sprite) mesh attribute
It has the same effect as the (sprite) material attribute.

Also, now sprite objects are rendered in the DRAW_OPAQUE phase.
2022-12-24 16:54:40 +09:00
kichikuou 70b4071350 ReignEngine: Support "shadow darkness" material parameter
It is a value between 0.0 and 1.0, where 0.0 means no shadows are drawn
on the material.
2022-12-24 16:54:40 +09:00
kichikuou 8c72c5b5e0 ReignEngine: Normalize vectors after applying normal_transform
normal_transform can be non-orthogonal, so after transforming with it
direction vectors must be normalized.

This fixes a bug where President Garter is rendered too specular.
2022-12-17 10:59:16 +09:00
kichikuou 581593f9b5 ReignEngine: Support (env) mesh attribute
If specified, the mesh should be rendered with environment mapping
using the material's COLOR_MAP as a matcap texture.
2022-11-05 20:56:26 +09:00
kichikuou 814ebb7d3d ReignEngine: Support (sprite) material attribute
If specified, alpha test is used instead of alpha blend.
2022-11-05 20:56:25 +09:00
Nunuhara Cabbage bc852567f2 Merge pull request #73 from kichikuou/gles
Fix shader compilation errors in OpenGL ES
2022-10-01 10:37:52 -07:00
kichikuou 1ae812ff03 Fix shader compilation errors in OpenGL ES 2022-10-01 16:41:51 +09:00
kichikuou 3615223b52 ReignEngine: Implement alpha mapping 2022-10-01 16:24:20 +09:00
kichikuou 909168acdb ReignEngine: Implement particle rendering
This completes the implementation of the particle effect system, except
for the camera quake effect.
2022-09-25 10:39:37 +09:00
kichikuou 06a630ea62 ReignEngine: Implement Fog
There are two types of fog, linear fog and atmospheric scattering. The
formula for light scattering is incorrect (see the comment in
reign.v.glsl) and therefore not physically correct.
2022-08-06 09:38:48 +09:00
kichikuou d185ae71bf ReignEngine: Implement CalcInstanceHeightDetection
This is used to compute Y-positions of map objects.

It is called quite often, so this implementation creates and caches a
height map of the instance by (re)using the shader for shadow mapping.
2022-07-30 15:17:08 +09:00
kichikuou 233b2a4f20 ReignEngine: Implement shadow mapping 2022-07-24 16:01:16 +09:00
kichikuou af7127580c ReignEngine: Implement light mapping 2022-07-16 15:26:41 +09:00
kichikuou c86ca5de87 ReignEngine: Implement bump mapping 2022-07-16 12:59:35 +09:00
kichikuou 80c6b62074 ReignEngine: Implement specular map 2022-07-10 13:33:50 +09:00
kichikuou fe02c8f401 ReignEngine: Implement rim lighting
Lighting parameters are per-material and are stored in the .amt file.
2022-07-10 13:20:50 +09:00
kichikuou b42032c9f8 ReignEngine: Implement basic lighting
This implements a Phong shading with ambient, diffuse and specular
components, using up to three directional lights and one specular light.

The light calculation is made to match the "high quality" 3D mode of
Toushin Toshi 3.
2022-07-09 14:36:44 +09:00
Nunuhara Cabbage 8ee136b287 parts: various fixes and improvements
* SetAddColor and SetMultiplyColor implemented
* additive draw filter implemented
* GetPartsUpperLeftPos{X,Y} implemented
* various parameters are now applied from parent to child parts
* misc. bug fixes

The first dungeon screen in Rance 01 now renders correctly.
2022-06-21 19:57:36 -07:00
kichikuou db97942393 Implement ReignEngine.SetInstanceAlpha 2022-06-12 21:27:49 +09:00
kichikuou a2bbe15b20 ReignEngine: Implement skeletal animation 2022-06-11 13:28:02 +09:00
Nunuhara Cabbage 09f2c3e1ed parts: implement Parts_Set*SurfaceArea functions
These functions apply a clipping rectangle to the parts texture.
2022-06-08 16:51:06 -07:00
kichikuou 9da9f53671 Implement FillAngle HLL
This is used in Toushin Toshi III for the "clock" effect of battle
command icons.
2022-06-05 10:06:42 +09:00
kichikuou dca30c3aab Initial implementation of ReignEngine HLL
ReignEngine is the 3D rendering engine used in Toushin Toshi III, and is
the predecessor of the 3D engines for Rance Quest, Rance 9, Evenicle,
etc.

This implements minimal functionality to be able to draw the first 3D
dungeon scene. Many important parts such as motion and lighting are not
implemented yet.
2022-06-04 11:29:07 +09:00
Nunuhara Cabbage 2262f7067c Use FreeType2 instead of SDL_ttf
SDL_ttf isn't really designed to be used with OpenGL. It caches glyph
bitmaps in memory, whereas we want to cache glyph textures on the GPU.
By using FreeType directly we avoid creating and destroying a new
texture every time a glyph is rendered.

Additionally, all glyph textures (including fnl-derived glyphs) now use
the GL_RED internal format instead of GL_RGBA.
2022-05-08 16:11:25 -07:00
Nunuhara Cabbage 44891458f1 Implement DrawGraph.SaturDP_DPxSA 2022-05-03 20:01:48 -07:00
Nunuhara Cabbage 54f6ece82d Implement DrawGraph.FillAMapGradationUD 2022-05-03 18:49:40 -07:00
Nunuhara Cabbage 65be47e05b Implement DrawGraph.BlendUseAMapColor 2022-05-02 20:35:02 -07:00
Nunuhara Cabbage 9108ce19ea Implement DrawGraph.BlendAMapAlphaSrcBright 2022-05-02 18:19:09 -07:00
Nunuhara Cabbage 2f573803c4 Implement DrawGraph.BlendAMapBright 2022-05-02 17:01:23 -07:00
Nunuhara Cabbage d085951f68 Implement EFFECT_BLUR_FADEOUT
Used in Sengoku Rance (when Ran summons Suzaku).
2022-05-02 11:25:42 -07:00