Normalized grey/gray namings and added emil comments

This commit is contained in:
KiritoDev 2022-04-25 14:44:10 -05:00
commit 811bf7b4e2
3 changed files with 27 additions and 29 deletions

View file

@ -173,7 +173,7 @@
/* GFX Effects */
// RDP Cmd
#define G_SET_GRAYSCALE 0x39
#define G_SETGRAYSCALE 0x39
#define G_SETINTENSITY 0x40
/*
@ -441,8 +441,6 @@
#define G_CCMUX_1 6
#define G_CCMUX_0 31
#define G_CCMUX_INTENSITY 32
/* Alpha combiner constants: */
#define G_ACMUX_COMBINED 0
#define G_ACMUX_TEXEL0 1

View file

@ -240,8 +240,8 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
}
if (cc_features.opt_grayscale) {
append_line(vs_buf, &vs_len, "attribute vec4 aGreyscaleColor;");
append_line(vs_buf, &vs_len, "varying vec4 vGreyscaleColor;");
append_line(vs_buf, &vs_len, "attribute vec4 aGrayscaleColor;");
append_line(vs_buf, &vs_len, "varying vec4 vGrayscaleColor;");
num_floats += 4;
}
@ -265,7 +265,7 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
append_line(vs_buf, &vs_len, "vFog = aFog;");
}
if (cc_features.opt_grayscale) {
append_line(vs_buf, &vs_len, "vGreyscaleColor = aGreyscaleColor;");
append_line(vs_buf, &vs_len, "vGrayscaleColor = aGrayscaleColor;");
}
for (int i = 0; i < cc_features.num_inputs; i++) {
vs_len += sprintf(vs_buf + vs_len, "vInput%d = aInput%d;\n", i + 1, i + 1);
@ -290,7 +290,7 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
append_line(fs_buf, &fs_len, "varying vec4 vFog;");
}
if (cc_features.opt_grayscale) {
append_line(fs_buf, &fs_len, "varying vec4 vGreyscaleColor;");
append_line(fs_buf, &fs_len, "varying vec4 vGrayscaleColor;");
}
for (int i = 0; i < cc_features.num_inputs; i++) {
fs_len += sprintf(fs_buf + fs_len, "varying vec%d vInput%d;\n", cc_features.opt_alpha ? 4 : 3, i + 1);
@ -370,7 +370,7 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
if(cc_features.opt_grayscale) {
append_line(fs_buf, &fs_len, "float intensity = (texel.r + texel.g + texel.b) / 3.0;");
append_line(fs_buf, &fs_len, "texel.rgb = vGreyscaleColor.rgb * intensity;");
append_line(fs_buf, &fs_len, "texel.rgb = vGrayscaleColor.rgb * intensity;");
}
if (cc_features.opt_alpha) {
@ -421,9 +421,9 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
GLint max_length = 0;
glGetShaderiv(fragment_shader, GL_INFO_LOG_LENGTH, &max_length);
char error_log[1024];
fprintf(stderr, "Fragment shader compilation failed\n");
//fprintf(stderr, "Fragment shader compilation failed\n");
glGetShaderInfoLog(fragment_shader, max_length, &max_length, &error_log[0]);
fprintf(stderr, "%s\n", &error_log[0]);
//fprintf(stderr, "%s\n", &error_log[0]);
abort();
}
@ -465,7 +465,7 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
}
if (cc_features.opt_grayscale) {
prg->attrib_locations[cnt] = glGetAttribLocation(shader_program, "aGreyscaleColor");
prg->attrib_locations[cnt] = glGetAttribLocation(shader_program, "aGrayscaleColor");
prg->attrib_sizes[cnt] = 4;
++cnt;
}

View file

@ -158,7 +158,7 @@ static struct RDP {
bool grayscale;
uint8_t prim_lod_fraction;
struct RGBA env_color, prim_color, fog_color, fill_color, intensity_color;
struct RGBA env_color, prim_color, fog_color, fill_color, grayscale_color;
struct XYWidthHeight viewport, scissor;
bool viewport_or_scissor_changed;
void *z_buf_address;
@ -1394,10 +1394,10 @@ static void gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t vtx3_idx, bo
}
if (use_grayscale) {
buf_vbo[buf_vbo_len++] = rdp.intensity_color.r / 255.0f;
buf_vbo[buf_vbo_len++] = rdp.intensity_color.g / 255.0f;
buf_vbo[buf_vbo_len++] = rdp.intensity_color.b / 255.0f;
buf_vbo[buf_vbo_len++] = rdp.intensity_color.a / 255.0f; // Unused
buf_vbo[buf_vbo_len++] = rdp.grayscale_color.r / 255.0f;
buf_vbo[buf_vbo_len++] = rdp.grayscale_color.g / 255.0f;
buf_vbo[buf_vbo_len++] = rdp.grayscale_color.b / 255.0f;
buf_vbo[buf_vbo_len++] = rdp.grayscale_color.a / 255.0f; // Unused
}
for (int j = 0; j < num_inputs; j++) {
@ -1800,11 +1800,11 @@ static inline uint32_t alpha_comb(uint32_t a, uint32_t b, uint32_t c, uint32_t d
return (a & 7) | ((b & 7) << 3) | ((c & 7) << 6) | ((d & 7) << 9);
}
static void gfx_dp_set_intensity_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
rdp.intensity_color.r = r;
rdp.intensity_color.g = g;
rdp.intensity_color.b = b;
rdp.intensity_color.a = a;
static void gfx_dp_set_grayscale_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
rdp.grayscale_color.r = r;
rdp.grayscale_color.g = g;
rdp.grayscale_color.b = b;
rdp.grayscale_color.a = a;
}
static void gfx_dp_set_env_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
@ -2480,7 +2480,7 @@ static void gfx_run_dl(Gfx* cmd) {
//gfx_dp_set_texture_image(C0(21, 3), C0(19, 2), C0(0, 10), texPtr);
break;
}
case G_SET_GRAYSCALE:
case G_SETGRAYSCALE:
{
rdp.grayscale = cmd->words.w1;
break;
@ -2513,7 +2513,7 @@ static void gfx_run_dl(Gfx* cmd) {
gfx_dp_set_fill_color(cmd->words.w1);
break;
case G_SETINTENSITY:
gfx_dp_set_intensity_color(C1(24, 8), C1(16, 8), C1(8, 8), C1(0, 8));
gfx_dp_set_grayscale_color(C1(24, 8), C1(16, 8), C1(8, 8), C1(0, 8));
break;
case G_SETCOMBINE:
gfx_dp_set_combine_mode(