mirror of https://github.com/xemu-project/xemu.git
nv2a: Partially handle SET_LIGHT_CONTROL
This commit is contained in:
parent
ebec5e3028
commit
c4bf201bfc
|
@ -315,11 +315,14 @@
|
|||
#define NV_PGRAPH_CSV0_C 0x00000FB8
|
||||
# define NV_PGRAPH_CSV0_C_CHEOPS_PROGRAM_START 0x0000FF00
|
||||
# define NV_PGRAPH_CSV0_C_SPECULAR_ENABLE (1 << 16)
|
||||
# define NV_PGRAPH_CSV0_C_ALPHA_FROM_MATERIAL_SPECULAR (1 << 17)
|
||||
# define NV_PGRAPH_CSV0_C_SEPARATE_SPECULAR (1 << 18)
|
||||
# define NV_PGRAPH_CSV0_C_SPECULAR (3 << 19)
|
||||
# define NV_PGRAPH_CSV0_C_DIFFUSE (3 << 21)
|
||||
# define NV_PGRAPH_CSV0_C_AMBIENT (3 << 23)
|
||||
# define NV_PGRAPH_CSV0_C_EMISSION (3 << 25)
|
||||
# define NV_PGRAPH_CSV0_C_NORMALIZATION_ENABLE (1 << 27)
|
||||
# define NV_PGRAPH_CSV0_C_LOCALEYE (1 << 30)
|
||||
# define NV_PGRAPH_CSV0_C_LIGHTING (1 << 31)
|
||||
#define NV_PGRAPH_CSV1_B 0x00000FBC
|
||||
#define NV_PGRAPH_CSV1_A 0x00000FC0
|
||||
|
@ -882,6 +885,10 @@
|
|||
# define NV097_SET_CONTROL0_STENCIL_WRITE_ENABLE (1 << 0)
|
||||
# define NV097_SET_CONTROL0_Z_FORMAT (1 << 12)
|
||||
# define NV097_SET_CONTROL0_Z_PERSPECTIVE_ENABLE (1 << 16)
|
||||
# define NV097_SET_LIGHT_CONTROL 0x00000294
|
||||
# define NV097_SET_LIGHT_CONTROL_SEPARATE_SPECULAR 1
|
||||
# define NV097_SET_LIGHT_CONTROL_LOCALEYE (1 << 16)
|
||||
# define NV097_SET_LIGHT_CONTROL_ALPHA_FROM_MATERIAL_SPECULAR (1 << 17)
|
||||
# define NV097_SET_COLOR_MATERIAL 0x00000298
|
||||
# define NV097_SET_FOG_MODE 0x0000029C
|
||||
# define NV097_SET_FOG_MODE_V_LINEAR 0x2601
|
||||
|
|
|
@ -384,13 +384,25 @@ GLSL_DEFINE(materialEmissionColor, GLSL_LTCTXA(NV_IGRAPH_XF_LTCTXA_CM_COL) ".xyz
|
|||
mstring_append(body, " oD1 = specular;\n");
|
||||
}
|
||||
|
||||
if (!state->specular_enable) {
|
||||
mstring_append(body, " oD1 = vec4(0.0, 0.0, 0.0, 1.0);\n");
|
||||
}
|
||||
|
||||
mstring_append(body, " oB0 = backDiffuse;\n");
|
||||
mstring_append(body, " oB1 = backSpecular;\n");
|
||||
|
||||
if (!state->specular_enable) {
|
||||
mstring_append(body, " oD1 = vec4(0.0, 0.0, 0.0, 1.0);\n");
|
||||
mstring_append(body, " oB1 = vec4(0.0, 0.0, 0.0, 1.0);\n");
|
||||
} else {
|
||||
if (!state->separate_specular) {
|
||||
mstring_append(body, " oD1 = specular;\n");
|
||||
mstring_append(body, " oB1 = backSpecular;\n");
|
||||
}
|
||||
if (state->ignore_specular_alpha) {
|
||||
mstring_append(body,
|
||||
" oD1.w = 1.0;\n"
|
||||
" oB1.a = 1.0;\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fog */
|
||||
if (state->fog_enable) {
|
||||
|
||||
|
|
|
@ -256,6 +256,13 @@ MString *pgraph_gen_vsh_glsl(const ShaderState *state, bool prefix_outputs)
|
|||
" vtxD1 = clamp(oD1, 0.0, 1.0);\n"
|
||||
" vtxB1 = clamp(oB1, 0.0, 1.0);\n"
|
||||
);
|
||||
|
||||
if (state->ignore_specular_alpha) {
|
||||
mstring_append(body,
|
||||
" vtxD1.w = 1.0;\n"
|
||||
" vtxB1.w = 1.0;\n"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
mstring_append(body,
|
||||
" vtxD1 = vec4(0.0, 0.0, 0.0, 1.0);\n"
|
||||
|
|
|
@ -27,6 +27,7 @@ DEF_METHOD(NV097, SET_COMBINER_SPECULAR_FOG_CW0)
|
|||
DEF_METHOD(NV097, SET_COMBINER_SPECULAR_FOG_CW1)
|
||||
DEF_METHOD_CASE_4(NV097, SET_TEXTURE_ADDRESS, 64)
|
||||
DEF_METHOD(NV097, SET_CONTROL0)
|
||||
DEF_METHOD(NV097, SET_LIGHT_CONTROL)
|
||||
DEF_METHOD(NV097, SET_COLOR_MATERIAL)
|
||||
DEF_METHOD(NV097, SET_FOG_MODE)
|
||||
DEF_METHOD(NV097, SET_FOG_GEN_MODE)
|
||||
|
|
|
@ -1075,6 +1075,18 @@ DEF_METHOD(NV097, SET_CONTROL0)
|
|||
z_perspective);
|
||||
}
|
||||
|
||||
DEF_METHOD(NV097, SET_LIGHT_CONTROL)
|
||||
{
|
||||
PG_SET_MASK(NV_PGRAPH_CSV0_C, NV_PGRAPH_CSV0_C_SEPARATE_SPECULAR,
|
||||
(parameter & NV097_SET_LIGHT_CONTROL_SEPARATE_SPECULAR) != 0);
|
||||
|
||||
PG_SET_MASK(NV_PGRAPH_CSV0_C, NV_PGRAPH_CSV0_C_LOCALEYE,
|
||||
(parameter & NV097_SET_LIGHT_CONTROL_LOCALEYE) != 0);
|
||||
|
||||
PG_SET_MASK(NV_PGRAPH_CSV0_C, NV_PGRAPH_CSV0_C_ALPHA_FROM_MATERIAL_SPECULAR,
|
||||
(parameter & NV097_SET_LIGHT_CONTROL_ALPHA_FROM_MATERIAL_SPECULAR) != 0);
|
||||
}
|
||||
|
||||
DEF_METHOD(NV097, SET_COLOR_MATERIAL)
|
||||
{
|
||||
PG_SET_MASK(NV_PGRAPH_CSV0_C, NV_PGRAPH_CSV0_C_EMISSION,
|
||||
|
|
|
@ -92,6 +92,11 @@ ShaderState pgraph_get_shader_state(PGRAPHState *pg)
|
|||
pgraph_reg_r(pg, NV_PGRAPH_CSV0_C), NV_PGRAPH_CSV0_C_SPECULAR);
|
||||
}
|
||||
|
||||
state.separate_specular = GET_MASK(
|
||||
pgraph_reg_r(pg, NV_PGRAPH_CSV0_C), NV_PGRAPH_CSV0_C_SEPARATE_SPECULAR);
|
||||
state.ignore_specular_alpha = !GET_MASK(
|
||||
pgraph_reg_r(pg, NV_PGRAPH_CSV0_C), NV_PGRAPH_CSV0_C_ALPHA_FROM_MATERIAL_SPECULAR);
|
||||
|
||||
/* vertex program stuff */
|
||||
state.vertex_program = vertex_program,
|
||||
state.z_perspective = pgraph_reg_r(pg, NV_PGRAPH_CONTROL_0) &
|
||||
|
|
|
@ -79,6 +79,9 @@ typedef struct ShaderState {
|
|||
enum MaterialColorSource diffuse_src;
|
||||
enum MaterialColorSource specular_src;
|
||||
|
||||
bool separate_specular;
|
||||
bool ignore_specular_alpha;
|
||||
|
||||
bool lighting;
|
||||
enum VshLight light[NV2A_MAX_LIGHTS];
|
||||
|
||||
|
|
Loading…
Reference in New Issue