1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Fix 2 cycle texturing.

This commit is contained in:
Sergey Lipskiy 2013-05-18 22:48:54 +07:00
parent baf51c449b
commit b7e89b71b1
2 changed files with 56 additions and 8 deletions

View File

@ -355,7 +355,7 @@ CachedCombiner *Combiner_Compile( u64 mux )
Combiner_SimplifyCycle( &ac[i], &alpha.stage[i] );
}
if (numCycles == 2)
if (numCycles == 2 && combiner.compiler != GLSL_COMBINE)
{
// Attempt to merge the two stages into one
Combiner_MergeStages( &color );

View File

@ -38,7 +38,7 @@ void display_warning(const char *text, ...)
}
}
const char *ColorInput[] = {
const char *ColorInput_1cycle[] = {
"combined_color.rgb",
"readtex0.rgb",
"readtex1.rgb",
@ -62,7 +62,31 @@ const char *ColorInput[] = {
"vec3(0.0)"
};
const char *AlphaInput[] = {
const char *ColorInput_2cycle[] = {
"combined_color.rgb",
"readtex1.rgb",
"readtex0.rgb",
"prim_color.rgb",
"vec_color.rgb",
"env_color.rgb",
"center_color.rgb",
"scale_color.rgb",
"combined_color.a",
"readtex1.a",
"readtex0.a",
"prim_color.a",
"vec_color.a",
"env_color.a",
"lod_frac", // TODO: emulate lod_fraction
"vec3(prim_lod)",
"vec3(0.5 + 0.5*snoise(noiseCoord2D))",
"vec3(k4)",
"vec3(k5)",
"vec3(1.0)",
"vec3(0.0)"
};
const char *AlphaInput_1cycle[] = {
"combined_color.a",
"readtex0.a",
"readtex1.a",
@ -86,6 +110,30 @@ const char *AlphaInput[] = {
"0.0"
};
const char *AlphaInput_2cycle[] = {
"combined_color.a",
"readtex1.a",
"readtex0.a",
"prim_color.a",
"vec_color.a",
"env_color.a",
"center_color.a",
"scale_color.a",
"combined_color.a",
"readtex1.a",
"readtex0.a",
"prim_color.a",
"vec_color.a",
"env_color.a",
"lod_frac", // TODO: emulate lod_fraction
"prim_lod",
"1.0",
"k4",
"k5",
"1.0",
"0.0"
};
static const char* fragment_shader_header_common_variables =
"uniform sampler2D texture0; \n"
"uniform sampler2D texture1; \n"
@ -584,7 +632,7 @@ int CompileCombiner(const CombinerStage & _stage, const char** _Input, char * _f
nRes |= 1 << _stage.op[i].param1;
break;
case INTER:
sprintf(buf, "mix(%s, %s, %s)", ColorInput[_stage.op[0].param2], _Input[_stage.op[0].param1], _Input[_stage.op[0].param3]);
sprintf(buf, "mix(%s, %s, %s)", _Input[_stage.op[0].param2], _Input[_stage.op[0].param1], _Input[_stage.op[0].param3]);
strcat(_fragment_shader, buf);
nRes |= 1 << _stage.op[i].param1;
nRes |= 1 << _stage.op[i].param2;
@ -609,18 +657,18 @@ GLSLCombiner::GLSLCombiner(Combiner *_color, Combiner *_alpha) {
char strCombiner[256];
strcpy(strCombiner, " alpha1 = ");
m_nInputs = CompileCombiner(_alpha->stage[0], AlphaInput, strCombiner);
m_nInputs = CompileCombiner(_alpha->stage[0], AlphaInput_1cycle, strCombiner);
strcat(strCombiner, " color1 = ");
m_nInputs |= CompileCombiner(_color->stage[0], ColorInput, strCombiner);
m_nInputs |= CompileCombiner(_color->stage[0], ColorInput_1cycle, strCombiner);
strcat(strCombiner, " combined_color = vec4(color1, alpha1); \n");
if (_alpha->numStages == 2) {
strcat(strCombiner, " alpha2 = ");
m_nInputs |= CompileCombiner(_alpha->stage[1], AlphaInput, strCombiner);
m_nInputs |= CompileCombiner(_alpha->stage[1], AlphaInput_2cycle, strCombiner);
} else
strcat(strCombiner, " alpha2 = alpha1; \n");
if (_color->numStages == 2) {
strcat(strCombiner, " color2 = ");
m_nInputs |= CompileCombiner(_color->stage[1], ColorInput, strCombiner);
m_nInputs |= CompileCombiner(_color->stage[1], ColorInput_2cycle, strCombiner);
} else
strcat(strCombiner, " color2 = color1; \n");