Updated shaders to use 'round' glsl instead of 'floor'

This commit is contained in:
Richard Davey 2023-11-07 15:23:57 +00:00
parent 91b145915c
commit e36d43533c
6 changed files with 6 additions and 10 deletions

View file

@ -17,7 +17,7 @@ module.exports = [
' gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);',
' if (uRoundPixels == 1)',
' {',
' gl_Position.xy = floor((gl_Position.xy + 1.0) * 0.5 * uResolution) / uResolution * 2.0 - 1.0;',
' gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;',
' }',
' outTexCoord = inTexCoord;',
' outTint = inTint;',

View file

@ -13,16 +13,12 @@ module.exports = [
'varying float outTexId;',
'varying float outTintEffect;',
'varying vec4 outTint;',
'vec2 roundPixels (vec2 position, vec2 targetSize)',
'{',
' return (floor((position * 0.5 + 0.5) * targetSize) / targetSize) * 2.0 - 1.0;',
'}',
'void main ()',
'{',
' gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);',
' if (uRoundPixels == 1)',
' {',
' gl_Position.xy = roundPixels(gl_Position.xy, uResolution);',
' gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;',
' }',
' outTexCoord = inTexCoord;',
' outTexId = inTexId;',

View file

@ -17,7 +17,7 @@ module.exports = [
' gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);',
' if (uRoundPixels == 1)',
' {',
' gl_Position.xy = floor((gl_Position.xy + 1.0) * 0.5 * uResolution) / uResolution * 2.0 - 1.0;',
' gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;',
' }',
' outTexCoord = inTexCoord;',
' outTint = inTint;',

View file

@ -22,7 +22,7 @@ void main ()
if (uRoundPixels == 1)
{
gl_Position.xy = floor((gl_Position.xy + 1.0) * 0.5 * uResolution) / uResolution * 2.0 - 1.0;
gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;
}
outTexCoord = inTexCoord;

View file

@ -23,7 +23,7 @@ void main ()
if (uRoundPixels == 1)
{
gl_Position.xy = floor((gl_Position.xy + 1.0) * 0.5 * uResolution) / uResolution * 2.0 - 1.0;
gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;
}
outTexCoord = inTexCoord;

View file

@ -22,7 +22,7 @@ void main ()
if (uRoundPixels == 1)
{
gl_Position.xy = floor((gl_Position.xy + 1.0) * 0.5 * uResolution) / uResolution * 2.0 - 1.0;
gl_Position.xy = floor(((gl_Position.xy + 1.0) * 0.5 * uResolution) + 0.5) / uResolution * 2.0 - 1.0;
}
outTexCoord = inTexCoord;