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

Write wrap function. Cleanup of combiner code.

This commit is contained in:
S2S 2019-11-07 22:15:47 +01:00 committed by Sergey Lipskiy
parent a42e34f1b8
commit 49604f0c16

View File

@ -604,7 +604,7 @@ public:
ShaderClamp()
{
m_part =
" lowp vec4 wrappedColor = cmbRes + 2.0 * step(cmbRes, vec4(-0.51)) - 2.0*step(vec4(1.51), cmbRes); \n"
" lowp vec4 wrappedColor = WRAP(cmbRes, -0.51, 1.51); \n"
" lowp vec4 clampedColor = clamp(wrappedColor, 0.0, 1.0); \n"
;
}
@ -623,7 +623,7 @@ public:
ShaderSignExtendColorC()
{
m_part =
" color1 = color1 - 2.0*(vec3(1.0) - step(color1, vec3(1.0))); \n"
" color1 = WRAP(color1, -1.01, 1.01); \n"
;
}
};
@ -634,7 +634,7 @@ public:
ShaderSignExtendAlphaC()
{
m_part =
" alpha1 = alpha1 - 2.0*(1.0 - step(alpha1, 1.0)); \n"
" alpha1 = WRAP(alpha1, -1.01, 1.01); \n"
;
}
};
@ -655,7 +655,7 @@ public:
ShaderSignExtendColorABD()
{
m_part =
" color1 = color1 + 2.0*step(color1, vec3(-0.51)) - 2.0*step(vec3(1.51), color1); \n"
" color1 = WRAP(color1, -0.51, 1.51); \n"
;
}
};
@ -666,7 +666,7 @@ public:
ShaderSignExtendAlphaABD()
{
m_part =
" alpha1 = alpha1 + 2.0*step(alpha1, -0.51) - 2.0*step(1.51, alpha1); \n"
" alpha1 = WRAP(alpha1, -0.51,1.51); \n"
;
}
};
@ -1252,18 +1252,22 @@ public:
m_part =
"void main() \n"
"{ \n"
;
;
if (!_glinfo.isGLES2) {
m_part +=
" highp float fragDepth = writeDepth(); \n"
;
;
}
m_part +=
" lowp vec4 vec_color; \n"
" lowp float alpha1; \n"
" lowp vec3 color1, input_color; \n"
;
;
m_part += "#define WRAP(x, low, high) mod((x)-(low), (high)-(low)) + (low) \n"; // Return wrapped value of x in interval [low, high)
// m_part += "#define WRAP(x, low, high) (x) - ((high)-(low)) * floor(((x)-(low))/((high)-(low))) \n"; // Perhaps more compatible?
// m_part += "#define WRAP(x, low, high) (x) + ((high)-(low)) * (1.0-step(low,x)) - ((high)-(low)) * step(high,x) \n"; // Step based version. Only wraps correctly if input is in the range [low-(high-low), high + (high-low)). Similar to old code.
}
};
class ShaderFragmentMain2Cycle : public ShaderPart
@ -1285,6 +1289,9 @@ public:
" lowp float alpha1, alpha2; \n"
" lowp vec3 color1, color2, input_color; \n"
;
m_part += "#define WRAP(x, low, high) mod((x)-(low), (high)-(low)) + (low) \n"; // Return wrapped value of x in interval [low, high)
// m_part += "#define WRAP(x, low, high) (x) - ((high)-(low)) * floor(((x)-(low))/((high)-(low))) \n"; // Perhaps more compatible?
// m_part += "#define WRAP(x, low, high) (x) + (2.0) * (1.0-step(low,x)) - (2.0) * step(high,x) \n"; // Step based version. Only wraps correctly if input is in the range [low-(high-low), high + (high-low)). Similar to old code.
}
};