Fix MSAA stripes (#9247)

This only works when shaders are enabled.
The centroid varying avoids that the textures (which repeat themselves out of bounds) are sampled out of bounds in MSAA.
If MSAA (called FSAA in minetest) is disabled, the centroid keyword does nothing.
This commit is contained in:
HybridDog 2020-12-04 20:16:12 +01:00 committed by GitHub
parent ecd4f45318
commit e73c5d4585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 10 deletions

@ -517,8 +517,8 @@ texture_min_size (Minimum texture size) int 64
# This algorithm smooths out the 3D viewport while keeping the image sharp, # This algorithm smooths out the 3D viewport while keeping the image sharp,
# but it doesn't affect the insides of textures # but it doesn't affect the insides of textures
# (which is especially noticeable with transparent textures). # (which is especially noticeable with transparent textures).
# This option is experimental and might cause visible spaces between blocks # Visible spaces appear between nodes when shaders are disabled.
# when set above 0. # If set to 0, MSAA is disabled.
# A restart is required after changing this option. # A restart is required after changing this option.
fsaa (FSAA) enum 0 0,1,2,4,8,16 fsaa (FSAA) enum 0 0,1,2,4,8,16

@ -16,7 +16,7 @@ varying vec3 vPosition;
// precision must be considered). // precision must be considered).
varying vec3 worldPosition; varying vec3 worldPosition;
varying lowp vec4 varColor; varying lowp vec4 varColor;
varying mediump vec2 varTexCoord; centroid varying mediump vec2 varTexCoord;
varying vec3 eyeVec; varying vec3 eyeVec;
const float fogStart = FOG_START; const float fogStart = FOG_START;

@ -16,7 +16,10 @@ varying vec3 vPosition;
// precision must be considered). // precision must be considered).
varying vec3 worldPosition; varying vec3 worldPosition;
varying lowp vec4 varColor; varying lowp vec4 varColor;
varying mediump vec2 varTexCoord; // The centroid keyword ensures that after interpolation the texture coordinates
// lie within the same bounds when MSAA is en- and disabled.
// This fixes the stripes problem with nearest-neighbour textures and MSAA.
centroid varying mediump vec2 varTexCoord;
varying vec3 eyeVec; varying vec3 eyeVec;
// Color of the light emitted by the light sources. // Color of the light emitted by the light sources.

@ -9,7 +9,7 @@ varying vec3 vNormal;
varying vec3 vPosition; varying vec3 vPosition;
varying vec3 worldPosition; varying vec3 worldPosition;
varying lowp vec4 varColor; varying lowp vec4 varColor;
varying mediump vec2 varTexCoord; centroid varying mediump vec2 varTexCoord;
varying vec3 eyeVec; varying vec3 eyeVec;
varying float vIDiff; varying float vIDiff;

@ -7,7 +7,7 @@ varying vec3 vNormal;
varying vec3 vPosition; varying vec3 vPosition;
varying vec3 worldPosition; varying vec3 worldPosition;
varying lowp vec4 varColor; varying lowp vec4 varColor;
varying mediump vec2 varTexCoord; centroid varying mediump vec2 varTexCoord;
varying vec3 eyeVec; varying vec3 eyeVec;
varying float vIDiff; varying float vIDiff;