mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-25 00:23:04 -06:00
Merge pull request #3097 from ds84182/round-primary-color-swrast
Round primary color in swrast
This commit is contained in:
commit
ae7240a2cb
4 changed files with 15 additions and 13 deletions
|
@ -168,6 +168,8 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
|
||||||
glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum());
|
glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum());
|
||||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, proctex_diff_lut_buffer.handle);
|
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, proctex_diff_lut_buffer.handle);
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
// Sync fixed function OpenGL state
|
// Sync fixed function OpenGL state
|
||||||
SyncClipEnabled();
|
SyncClipEnabled();
|
||||||
SyncClipCoef();
|
SyncClipCoef();
|
||||||
|
|
|
@ -234,7 +234,7 @@ static void AppendSource(std::string& out, const PicaShaderConfig& config,
|
||||||
using Source = TevStageConfig::Source;
|
using Source = TevStageConfig::Source;
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case Source::PrimaryColor:
|
case Source::PrimaryColor:
|
||||||
out += "primary_color";
|
out += "rounded_primary_color";
|
||||||
break;
|
break;
|
||||||
case Source::PrimaryFragmentColor:
|
case Source::PrimaryFragmentColor:
|
||||||
out += "primary_fragment_color";
|
out += "primary_fragment_color";
|
||||||
|
@ -1100,8 +1100,11 @@ float LookupLightingLUTSigned(int lut_index, float pos) {
|
||||||
if (config.state.proctex.enable)
|
if (config.state.proctex.enable)
|
||||||
AppendProcTexSampler(out, config);
|
AppendProcTexSampler(out, config);
|
||||||
|
|
||||||
|
// We round the interpolated primary color to the nearest 1/255th
|
||||||
|
// This maintains the PICA's 8 bits of precision
|
||||||
out += R"(
|
out += R"(
|
||||||
void main() {
|
void main() {
|
||||||
|
vec4 rounded_primary_color = round(primary_color * 255.0) / 255.0;
|
||||||
vec4 primary_fragment_color = vec4(0.0);
|
vec4 primary_fragment_color = vec4(0.0);
|
||||||
vec4 secondary_fragment_color = vec4(0.0);
|
vec4 secondary_fragment_color = vec4(0.0);
|
||||||
)";
|
)";
|
||||||
|
|
|
@ -33,7 +33,7 @@ OpenGLState::OpenGLState() {
|
||||||
stencil.action_depth_pass = GL_KEEP;
|
stencil.action_depth_pass = GL_KEEP;
|
||||||
stencil.action_stencil_fail = GL_KEEP;
|
stencil.action_stencil_fail = GL_KEEP;
|
||||||
|
|
||||||
blend.enabled = false;
|
blend.enabled = true;
|
||||||
blend.rgb_equation = GL_FUNC_ADD;
|
blend.rgb_equation = GL_FUNC_ADD;
|
||||||
blend.a_equation = GL_FUNC_ADD;
|
blend.a_equation = GL_FUNC_ADD;
|
||||||
blend.src_rgb_func = GL_ONE;
|
blend.src_rgb_func = GL_ONE;
|
||||||
|
@ -148,9 +148,6 @@ void OpenGLState::Apply() const {
|
||||||
if (blend.enabled != cur_state.blend.enabled) {
|
if (blend.enabled != cur_state.blend.enabled) {
|
||||||
if (blend.enabled) {
|
if (blend.enabled) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
cur_state.logic_op = GL_COPY;
|
|
||||||
glLogicOp(cur_state.logic_op);
|
|
||||||
glDisable(GL_COLOR_LOGIC_OP);
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
|
@ -293,18 +293,18 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
|
||||||
};
|
};
|
||||||
|
|
||||||
Math::Vec4<u8> primary_color{
|
Math::Vec4<u8> primary_color{
|
||||||
(u8)(
|
static_cast<u8>(round(
|
||||||
GetInterpolatedAttribute(v0.color.r(), v1.color.r(), v2.color.r()).ToFloat32() *
|
GetInterpolatedAttribute(v0.color.r(), v1.color.r(), v2.color.r()).ToFloat32() *
|
||||||
255),
|
255)),
|
||||||
(u8)(
|
static_cast<u8>(round(
|
||||||
GetInterpolatedAttribute(v0.color.g(), v1.color.g(), v2.color.g()).ToFloat32() *
|
GetInterpolatedAttribute(v0.color.g(), v1.color.g(), v2.color.g()).ToFloat32() *
|
||||||
255),
|
255)),
|
||||||
(u8)(
|
static_cast<u8>(round(
|
||||||
GetInterpolatedAttribute(v0.color.b(), v1.color.b(), v2.color.b()).ToFloat32() *
|
GetInterpolatedAttribute(v0.color.b(), v1.color.b(), v2.color.b()).ToFloat32() *
|
||||||
255),
|
255)),
|
||||||
(u8)(
|
static_cast<u8>(round(
|
||||||
GetInterpolatedAttribute(v0.color.a(), v1.color.a(), v2.color.a()).ToFloat32() *
|
GetInterpolatedAttribute(v0.color.a(), v1.color.a(), v2.color.a()).ToFloat32() *
|
||||||
255),
|
255)),
|
||||||
};
|
};
|
||||||
|
|
||||||
Math::Vec2<float24> uv[3];
|
Math::Vec2<float24> uv[3];
|
||||||
|
|
Loading…
Reference in a new issue