mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
parent
68d9e9311e
commit
ced20400b3
15 changed files with 72 additions and 16 deletions
|
@ -29,6 +29,8 @@ uniform sampler1D texPalette;
|
|||
uniform sampler2D texAlpha;
|
||||
uniform bool paletteEnabled;
|
||||
uniform bool alphaEnabled;
|
||||
uniform bool tintEnabled;
|
||||
uniform vec3 tintColor;
|
||||
uniform int effect;
|
||||
|
||||
#ifdef OGL33C
|
||||
|
@ -65,6 +67,10 @@ void main(void) {
|
|||
OUTCOLOR = TEXTURE2D(texMain, uv);
|
||||
}
|
||||
|
||||
if (tintEnabled) {
|
||||
OUTCOLOR.rgb *= tintColor.rgb;
|
||||
}
|
||||
|
||||
if (effect == EFFECT_VIGNETTE) {
|
||||
float x_dist = vertCoords.x - 0.5;
|
||||
float y_dist = vertCoords.y - 0.5;
|
||||
|
|
|
@ -29,6 +29,8 @@ uniform sampler1D texPalette;
|
|||
uniform sampler2D texAlpha;
|
||||
uniform bool paletteEnabled;
|
||||
uniform bool alphaEnabled;
|
||||
uniform bool tintEnabled;
|
||||
uniform vec3 tintColor;
|
||||
uniform int effect;
|
||||
|
||||
#ifdef OGL33C
|
||||
|
@ -65,6 +67,10 @@ void main(void) {
|
|||
OUTCOLOR = TEXTURE2D(texMain, uv);
|
||||
}
|
||||
|
||||
if (tintEnabled) {
|
||||
OUTCOLOR.rgb *= tintColor.rgb;
|
||||
}
|
||||
|
||||
if (effect == EFFECT_VIGNETTE) {
|
||||
float x_dist = vertCoords.x - 0.5;
|
||||
float y_dist = vertCoords.y - 0.5;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
- added an option to use PS1 contrast levels, available under F8 (#1646)
|
||||
- added an option to allow disabling the developer console (#2063)
|
||||
- fixed Lara prioritising throwing a spent flare while mid-air, so to avoid missing ledge grabs (#1989)
|
||||
- fixed software renderer not applying underwater tint (#2066, regression from 0.7)
|
||||
|
||||
## [0.7.1](https://github.com/LostArtefacts/TRX/compare/tr2-0.7...tr2-0.7.1) - 2024-12-17
|
||||
- fixed a crash when selecting the sound option (#2057, regression from 0.6)
|
||||
|
|
|
@ -4657,7 +4657,7 @@ typedef enum {
|
|||
0x004D93F0 - uint8_t g_LabTextureUVFlag[2048]; // MAX_TEXTURES
|
||||
0x005251B0 - FRAME_INFO *g_AnimFrames;
|
||||
0x0051BC38 - int32_t g_IsWet;
|
||||
0x0051B308 - RGB_888 g_WaterPalette[256];
|
||||
0x0051B308 + RGB_888 g_WaterPalette[256];
|
||||
0x004BF2D8 - uint8_t g_DepthQIndex[256];
|
||||
0x004D7C74 - int32_t g_NumCameras;
|
||||
0x0051B92C - int16_t *g_AnimTextureRanges;
|
||||
|
|
|
@ -16,6 +16,8 @@ typedef enum {
|
|||
M_UNIFORM_TEXTURE_ALPHA,
|
||||
M_UNIFORM_PALETTE_ENABLED,
|
||||
M_UNIFORM_ALPHA_ENABLED,
|
||||
M_UNIFORM_TINT_ENABLED,
|
||||
M_UNIFORM_TINT_COLOR,
|
||||
M_UNIFORM_EFFECT,
|
||||
M_UNIFORM_NUMBER_OF,
|
||||
} M_UNIFORM;
|
||||
|
@ -45,6 +47,7 @@ struct GFX_2D_RENDERER {
|
|||
int32_t y;
|
||||
} repeat;
|
||||
|
||||
GFX_COLOR tint_color;
|
||||
GFX_2D_EFFECT effect;
|
||||
bool use_palette;
|
||||
bool use_alpha;
|
||||
|
@ -102,6 +105,7 @@ GFX_2D_RENDERER *GFX_2D_Renderer_Create(void)
|
|||
const GFX_CONFIG *const config = GFX_Context_GetConfig();
|
||||
|
||||
r->effect = GFX_2D_EFFECT_NONE;
|
||||
r->tint_color = (GFX_COLOR) { .r = 255, .g = 255, .b = 255 };
|
||||
r->use_palette = false;
|
||||
r->use_alpha = false;
|
||||
r->repeat.x = 1;
|
||||
|
@ -145,6 +149,8 @@ GFX_2D_RENDERER *GFX_2D_Renderer_Create(void)
|
|||
{ M_UNIFORM_TEXTURE_ALPHA, "texAlpha" },
|
||||
{ M_UNIFORM_PALETTE_ENABLED, "paletteEnabled" },
|
||||
{ M_UNIFORM_ALPHA_ENABLED, "alphaEnabled" },
|
||||
{ M_UNIFORM_TINT_ENABLED, "tintEnabled" },
|
||||
{ M_UNIFORM_TINT_COLOR, "tintColor" },
|
||||
{ M_UNIFORM_EFFECT, "effect" },
|
||||
{ -1, NULL },
|
||||
};
|
||||
|
@ -162,6 +168,10 @@ GFX_2D_RENDERER *GFX_2D_Renderer_Create(void)
|
|||
&r->program, r->loc[M_UNIFORM_PALETTE_ENABLED], r->use_palette);
|
||||
GFX_GL_Program_Uniform1i(
|
||||
&r->program, r->loc[M_UNIFORM_ALPHA_ENABLED], r->use_alpha);
|
||||
GFX_GL_Program_Uniform1i(
|
||||
&r->program, r->loc[M_UNIFORM_TINT_ENABLED],
|
||||
r->tint_color.r != 255 || r->tint_color.g != 255
|
||||
|| r->tint_color.b != 255);
|
||||
GFX_GL_Program_Uniform1i(&r->program, r->loc[M_UNIFORM_EFFECT], r->effect);
|
||||
GFX_GL_CheckError();
|
||||
|
||||
|
@ -291,7 +301,7 @@ void GFX_2D_Renderer_Upload(
|
|||
}
|
||||
|
||||
void GFX_2D_Renderer_SetPalette(
|
||||
GFX_2D_RENDERER *const r, const GFX_PALETTE_ENTRY *const palette)
|
||||
GFX_2D_RENDERER *const r, const GFX_COLOR *const palette)
|
||||
{
|
||||
ASSERT(r != NULL);
|
||||
|
||||
|
@ -355,6 +365,22 @@ void GFX_2D_Renderer_SetEffect(
|
|||
}
|
||||
}
|
||||
|
||||
void GFX_2D_Renderer_SetTint(GFX_2D_RENDERER *const r, const GFX_COLOR color)
|
||||
{
|
||||
ASSERT(r != NULL);
|
||||
if (r->tint_color.r != color.r || r->tint_color.g != color.g
|
||||
|| r->tint_color.b != color.b) {
|
||||
GFX_GL_Program_Bind(&r->program);
|
||||
GFX_GL_Program_Uniform1i(
|
||||
&r->program, r->loc[M_UNIFORM_TINT_ENABLED],
|
||||
color.r != 255 || color.g != 255 || color.b != 255);
|
||||
GFX_GL_Program_Uniform3f(
|
||||
&r->program, r->loc[M_UNIFORM_TINT_COLOR], color.r / 255.0,
|
||||
color.g / 255.0, color.b / 255.0);
|
||||
r->tint_color = color;
|
||||
}
|
||||
}
|
||||
|
||||
void GFX_2D_Renderer_Render(GFX_2D_RENDERER *const r)
|
||||
{
|
||||
ASSERT(r != NULL);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
typedef struct {
|
||||
uint8_t r, g, b;
|
||||
} GFX_PALETTE_ENTRY;
|
||||
} GFX_COLOR;
|
||||
|
||||
typedef enum {
|
||||
GFX_2D_EFFECT_NONE = 0,
|
||||
|
@ -32,8 +32,9 @@ void GFX_2D_Renderer_Upload(
|
|||
GFX_2D_RENDERER *renderer, GFX_2D_SURFACE_DESC *desc, const uint8_t *data);
|
||||
|
||||
void GFX_2D_Renderer_SetPalette(
|
||||
GFX_2D_RENDERER *renderer, const GFX_PALETTE_ENTRY *palette);
|
||||
GFX_2D_RENDERER *renderer, const GFX_COLOR *palette);
|
||||
void GFX_2D_Renderer_SetRepeat(GFX_2D_RENDERER *renderer, int32_t x, int32_t y);
|
||||
void GFX_2D_Renderer_SetEffect(GFX_2D_RENDERER *renderer, GFX_2D_EFFECT filter);
|
||||
void GFX_2D_Renderer_SetTint(GFX_2D_RENDERER *renderer, GFX_COLOR color);
|
||||
|
||||
void GFX_2D_Renderer_Render(GFX_2D_RENDERER *renderer);
|
||||
|
|
|
@ -113,9 +113,9 @@ static void M_Play(const char *const file_name)
|
|||
|
||||
// Populate the palette with a palette corresponding to
|
||||
// AV_PIX_FMT_RGB8
|
||||
GFX_PALETTE_ENTRY palette[256];
|
||||
GFX_COLOR palette[256];
|
||||
for (int32_t i = 0; i < 256; i++) {
|
||||
GFX_PALETTE_ENTRY *const col = &palette[i];
|
||||
GFX_COLOR *const col = &palette[i];
|
||||
col->r = 0x24 * (i >> 5);
|
||||
col->g = 0x24 * ((i >> 2) & 7);
|
||||
col->b = 0x55 * (i & 3);
|
||||
|
|
|
@ -510,13 +510,6 @@ static void M_LoadDepthQ(VFILE *const file)
|
|||
}
|
||||
}
|
||||
|
||||
g_IsWet = 0;
|
||||
for (int32_t i = 0; i < 256; i++) {
|
||||
g_WaterPalette[i].red = g_GamePalette8[i].red * 2 / 3;
|
||||
g_WaterPalette[i].green = g_GamePalette8[i].green * 2 / 3;
|
||||
g_WaterPalette[i].blue = g_GamePalette8[i].blue;
|
||||
}
|
||||
|
||||
Benchmark_End(benchmark, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1126,6 +1126,7 @@ void __cdecl Output_LightRoom(ROOM *const room)
|
|||
void __cdecl Output_SetupBelowWater(const bool is_underwater)
|
||||
{
|
||||
g_IsWet = is_underwater;
|
||||
Render_SetWet(is_underwater);
|
||||
g_IsWaterEffect = true;
|
||||
g_IsWibbleEffect = !is_underwater;
|
||||
g_IsShadeEffect = true;
|
||||
|
|
|
@ -364,3 +364,11 @@ void Render_InsertSprite(
|
|||
r->InsertSprite(r, z, x0, y0, x1, y1, sprite_idx, shade);
|
||||
}
|
||||
}
|
||||
|
||||
void Render_SetWet(const bool is_wet)
|
||||
{
|
||||
RENDERER *const r = M_GetRenderer();
|
||||
if (r->SetWet != NULL) {
|
||||
r->SetWet(r, is_wet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ void Render_DrawBlackRectangle(int32_t opacity);
|
|||
|
||||
void Render_ClearZBuffer(void);
|
||||
void Render_EnableZBuffer(bool z_write_enable, bool z_test_enable);
|
||||
void Render_SetWet(bool is_wet);
|
||||
|
||||
// TODO: there's too much repetition for these
|
||||
const int16_t *Render_InsertObjectG3(
|
||||
|
|
|
@ -890,7 +890,7 @@ static void M_InsertSprite_Sorted(
|
|||
}
|
||||
|
||||
const bool old_shade = g_IsShadeEffect;
|
||||
g_IsShadeEffect = 0;
|
||||
g_IsShadeEffect = false;
|
||||
M_InsertPolyTextured(num_points, z, POLY_HWR_WGTMAP, sprite->tex_page);
|
||||
g_IsShadeEffect = old_shade;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ typedef struct RENDERER {
|
|||
void (*ClearZBuffer)(struct RENDERER *);
|
||||
void (*EnableZBuffer)(struct RENDERER *, bool, bool);
|
||||
void (*DrawPolyList)(struct RENDERER *);
|
||||
void (*SetWet)(struct RENDERER *, bool);
|
||||
|
||||
const int16_t *(*InsertGT4)(
|
||||
struct RENDERER *renderer, const int16_t *obj_ptr, int32_t num,
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef struct {
|
|||
GFX_2D_RENDERER *renderer_2d;
|
||||
GFX_2D_SURFACE *surface;
|
||||
GFX_2D_SURFACE *surface_alpha;
|
||||
GFX_PALETTE_ENTRY palette[256];
|
||||
GFX_COLOR palette[256];
|
||||
} M_PRIV;
|
||||
|
||||
static VERTEX_INFO m_VBuffer[32] = { 0 };
|
||||
|
@ -1401,6 +1401,18 @@ static void M_DrawPolyList(RENDERER *const renderer)
|
|||
GFX_2D_Renderer_Render(priv->renderer_2d);
|
||||
}
|
||||
|
||||
static void M_SetWet(RENDERER *const renderer, const bool is_wet)
|
||||
{
|
||||
M_PRIV *const priv = renderer->priv;
|
||||
if (is_wet) {
|
||||
GFX_2D_Renderer_SetTint(
|
||||
priv->renderer_2d, (GFX_COLOR) { .r = 170, .g = 170, .b = 255 });
|
||||
} else {
|
||||
GFX_2D_Renderer_SetTint(
|
||||
priv->renderer_2d, (GFX_COLOR) { .r = 255, .g = 255, .b = 255 });
|
||||
}
|
||||
}
|
||||
|
||||
static const int16_t *M_InsertObjectG3(
|
||||
RENDERER *const renderer, const int16_t *obj_ptr, const int32_t num,
|
||||
const SORT_TYPE sort_type)
|
||||
|
@ -2257,6 +2269,7 @@ void Renderer_SW_Prepare(RENDERER *const renderer)
|
|||
renderer->ResetPolyList = NULL;
|
||||
renderer->EnableZBuffer = NULL;
|
||||
renderer->ClearZBuffer = NULL;
|
||||
renderer->SetWet = M_SetWet;
|
||||
|
||||
renderer->InsertObjectG3 = M_InsertObjectG3;
|
||||
renderer->InsertObjectG4 = M_InsertObjectG4;
|
||||
|
|
|
@ -268,7 +268,6 @@
|
|||
#define g_PassportMode (*(int32_t*)0x0051A2D0)
|
||||
#define g_SoundText (*(TEXTSTRING *(*)[4])0x0051A2F0)
|
||||
#define g_RoomLightTables (*(ROOM_LIGHT_TABLE(*)[32])0x0051A308)
|
||||
#define g_WaterPalette (*(RGB_888(*)[256])0x0051B308)
|
||||
#define g_PicturePalette (*(RGB_888(*)[256])0x0051B608)
|
||||
#define g_RoomLightShades (*(int32_t(*)[4])0x0051B908)
|
||||
#define g_AnimTextureRanges (*(int16_t **)0x0051B92C)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue