Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Jan 2, 2025
1 parent 4e26864 commit ddc7154
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions flixel/graphics/tile/FlxDrawQuadsItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class FlxDrawQuadsItem extends FlxDrawBaseItem<FlxDrawQuadsItem>
shader.colorOffset.value = colorOffsets;
}

setParameterValue(shader.hasTransform, true);
setParameterValue(shader.hasColorTransform, colored || hasColorOffsets);

#if (openfl > "8.7.0")
Expand Down
1 change: 1 addition & 0 deletions flixel/graphics/tile/FlxDrawTrianglesItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class FlxDrawTrianglesItem extends FlxDrawBaseItem<FlxDrawTrianglesItem>
shader.colorOffset.value = null;
}

setParameterValue(shader.hasTransform, true);
setParameterValue(shader.hasColorTransform, colored || hasColorOffsets);

#if (openfl > "8.7.0")
Expand Down
16 changes: 11 additions & 5 deletions flixel/graphics/tile/FlxGraphicsShader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,31 @@ class FlxGraphicsShader extends GraphicsShader
}
")
@:glFragmentHeader("
// Note: this is being set to false somewhere!
uniform bool hasTransform;
uniform bool hasColorTransform;
vec4 transform(vec4 color, vec4 mult, vec4 offset, float alpha)
{
color = clamp(offset + (color * mult), 0.0, 1.0);
alpha *= color.a;
return vec4 (color.rgb * alpha, alpha);
return vec4 (color.rgb, 1.0) * color.a * alpha;
}
vec4 transformIf(bool hasTransform, vec4 color, vec4 mult, vec4 offset, float alpha)
{
return mix(color, transform(color, mult, offset, alpha), float(hasTransform));
return mix(color * alpha, transform(color, mult, offset, alpha), float(hasTransform));
}
vec4 flixel_texture2D(sampler2D bitmap, vec2 coord)
{
vec4 color = texture2D(bitmap, coord);
bool hasTransform = openfl_HasColorTransform || hasColorTransform;
return transformIf(hasTransform, color, openfl_ColorMultiplierv, openfl_ColorOffsetv, openfl_Alphav);
if (!hasTransform && !openfl_HasColorTransform)
return color;
color = mix(color, vec4(0.0), float(color.a == 0.0));
bool _hasTransform = openfl_HasColorTransform || hasColorTransform;
return transformIf(_hasTransform, color, openfl_ColorMultiplierv, openfl_ColorOffsetv, openfl_Alphav);
}
")
@:glFragmentBody("
Expand Down

0 comments on commit ddc7154

Please sign in to comment.