diff --git a/shaders/dimensions/all_solid.fsh b/shaders/dimensions/all_solid.fsh index 21d93eb..c26ff5b 100644 --- a/shaders/dimensions/all_solid.fsh +++ b/shaders/dimensions/all_solid.fsh @@ -6,6 +6,10 @@ #include "/lib/items.glsl" #include "/lib/hsv.glsl" +#ifdef IRIS_FEATURE_TEXTURE_FILTERING +#include "/lib/texture_filtering.glsl" +#endif + #ifdef HAND #undef POM #endif @@ -333,9 +337,9 @@ float getTrimEmission(vec3 Albedo) { return sqrt(hsv.z); } -// #if defined HAND || (defined WORLD && !defined ENTITIES && !defined BLOCKENTITIES) -// uniform float alphaTestRef; -// #endif +#if defined HAND || (defined WORLD && !defined ENTITIES && !defined BLOCKENTITIES) + uniform float alphaTestRef; +#endif //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -406,7 +410,7 @@ void main() { // this fixes create multiblock entity thingies like train wheels (but probably breaks something else, didn't notice anything tho) #ifndef COLORWHEEL - adjustedTexCoord = fract(data_in.texcoord.st)*data_in.texcoordam.pq+data_in.texcoordam.st; + // adjustedTexCoord = fract(data_in.texcoord.st)*data_in.texcoordam.pq+data_in.texcoordam.st; #endif // vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); @@ -522,13 +526,17 @@ void main() { // don't fix vanilla ao on some custom block models. // if (Color.a < 0.3) Color.a = 1.0; // fix vanilla ao on some custom block models. - vec4 Albedo = Color; + vec4 Albedo = vec4(Color.rgb, 1.0); #if !defined BLOCKENTITIES && !defined ENTITIES && !defined HAND && defined SHADER_GRASS && defined WORLD if (!ShaderGrass) #endif { + #ifdef IRIS_FEATURE_TEXTURE_FILTERING + Albedo *= textureFilteringMode == 1 ? sampleRGSS(gtexture, adjustedTexCoord.xy, 1.0 / vec2(textureSize(gtexture, 0))) : sampleNearest(gtexture, adjustedTexCoord.xy, 1.0 / vec2(textureSize(gtexture, 0))); + #else Albedo *= texture2D_POMSwitch(gtexture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD); + #endif } #else vec4 Albedo = texture2D_POMSwitch(gtexture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD); @@ -557,7 +565,7 @@ void main() { #endif #if defined HAND || (defined WORLD && !defined ENTITIES && !defined BLOCKENTITIES) - if (Albedo.a < 0.1) discard; + if (Albedo.a < alphaTestRef) discard; #endif #if defined IRIS_FEATURE_FADE_VARIABLE && VANILLA_CHUNK_FADING > 0 && !defined HAND diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index ce98acc..6626a8c 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -151,6 +151,10 @@ uniform float dhVoxyFarPlane; #include "/lib/sky_gradient.glsl" #include "/lib/waterBump.glsl" +#ifdef IRIS_FEATURE_TEXTURE_FILTERING +#include "/lib/texture_filtering.glsl" +#endif + #ifdef OVERWORLD_SHADER flat varying float Flashing; #include "/lib/lightning_stuff.glsl" @@ -530,7 +534,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec2 lightmap = lmtexcoord.zw; #ifndef COLORWHEEL + #ifdef IRIS_FEATURE_TEXTURE_FILTERING + gl_FragData[0] = textureFilteringMode == 1 ? sampleRGSS(gtexture, lmtexcoord.xy, 1.0 / vec2(textureSize(gtexture, 0))) : sampleNearest(gtexture, lmtexcoord.xy, 1.0 / vec2(textureSize(gtexture, 0))) * color; + #else gl_FragData[0] = texture2D(gtexture, lmtexcoord.xy, mipmapBias) * color; + #endif #else vec4 _color = texture2D(gtexture, lmtexcoord.xy, mipmapBias); float ao; diff --git a/shaders/lang/en_us.lang b/shaders/lang/en_us.lang index 8e62cd4..d3f5a27 100644 --- a/shaders/lang/en_us.lang +++ b/shaders/lang/en_us.lang @@ -1,6 +1,6 @@ option.SHADER_VERSION_LABEL = §d§lECLIPSE§r - A Bliss Edit prefix.SHADER_VERSION_LABEL = V - value.SHADER_VERSION_LABEL.482 = 5.7.0 + value.SHADER_VERSION_LABEL.482 = 5.8.0 # if you're here to translate, this is not a joke, these do what they say profile.POTATO=§4Potato diff --git a/shaders/lang/zh_cn.lang b/shaders/lang/zh_cn.lang index c868546..a29adf7 100644 --- a/shaders/lang/zh_cn.lang +++ b/shaders/lang/zh_cn.lang @@ -1,6 +1,6 @@ option.SHADER_VERSION_LABEL = §d§lECLIPSE§r - Bliss 编辑版 prefix.SHADER_VERSION_LABEL = 版本 - value.SHADER_VERSION_LABEL.482 = 5.7.0 + value.SHADER_VERSION_LABEL.482 = 5.8.0 # 如果你是来翻译的,这不是玩笑,这些选项的功能正如其名 profile.POTATO=§4土豆 (极低配置) diff --git a/shaders/lib/texture_filtering.glsl b/shaders/lib/texture_filtering.glsl new file mode 100644 index 0000000..60baf2b --- /dev/null +++ b/shaders/lib/texture_filtering.glsl @@ -0,0 +1,73 @@ +uniform int textureFilteringMode; + +vec4 sampleNearest(sampler2D sampler, vec2 uv, vec2 pixelSize, vec2 du, vec2 dv, vec2 texelScreenSize) { + // Convert our UV back up to texel coordinates and find out how far over we are from the center of each pixel + vec2 uvTexelCoords = uv / pixelSize; + vec2 texelCenter = round(uvTexelCoords) - 0.5f; + vec2 texelOffset = uvTexelCoords - texelCenter; + + // Move our offset closer to the texel center based on texel size on screen + texelOffset = (texelOffset - 0.5f) * pixelSize / texelScreenSize + 0.5f; + texelOffset = clamp(texelOffset, 0.0f, 1.0f); + + uv = (texelCenter + texelOffset) * pixelSize; + return textureGrad(sampler, uv, du, dv); +} + +vec4 sampleNearest(sampler2D source, vec2 uv, vec2 pixelSize) { + vec2 du = dFdx(uv); + vec2 dv = dFdy(uv); + vec2 texelScreenSize = sqrt(du * du + dv * dv); + return sampleNearest(source, uv, pixelSize, du, dv, texelScreenSize); +} + +// Rotated Grid Super-Sampling +vec4 sampleRGSS(sampler2D source, vec2 uv, vec2 pixelSize) { + vec2 du = dFdx(uv); + vec2 dv = dFdy(uv); + + vec2 texelScreenSize = sqrt(du * du + dv * dv); + float maxTexelSize = max(texelScreenSize.x, texelScreenSize.y); + + float minPixelSize = min(pixelSize.x, pixelSize.y); + + float transitionStart = minPixelSize * 1.0; + float transitionEnd = minPixelSize * 2.0; + float blendFactor = smoothstep(transitionStart, transitionEnd, maxTexelSize); + + float duLength = length(du); + float dvLength = length(dv); + float minDerivative = min(duLength, dvLength); + float maxDerivative = max(duLength, dvLength); + + float effectiveDerivative = sqrt(minDerivative * maxDerivative); + + float mipLevelExact = max(0.0, log2(effectiveDerivative / minPixelSize)); + + float mipLevelLow = floor(mipLevelExact); + float mipLevelHigh = mipLevelLow + 1.0; + float mipBlend = fract(mipLevelExact); + + const vec2 offsets[4] = vec2[]( + vec2(0.125, 0.375), + vec2(-0.125, -0.375), + vec2(0.375, -0.125), + vec2(-0.375, 0.125) + ); + + vec4 rgssColorLow = vec4(0.0); + vec4 rgssColorHigh = vec4(0.0); + for (int i = 0; i < 4; ++i) { + vec2 sampleUV = uv + offsets[i] * pixelSize; + rgssColorLow += textureLod(source, sampleUV, mipLevelLow); + rgssColorHigh += textureLod(source, sampleUV, mipLevelHigh); + } + rgssColorLow *= 0.25; + rgssColorHigh *= 0.25; + + vec4 rgssColor = mix(rgssColorLow, rgssColorHigh, mipBlend); + + vec4 nearestColor = sampleNearest(source, uv, pixelSize, du, dv, texelScreenSize); + + return mix(nearestColor, rgssColor, blendFactor); +} \ No newline at end of file diff --git a/shaders/shaders.properties b/shaders/shaders.properties index c757ab5..e614b3b 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -27,7 +27,7 @@ separateAo = true rain.depth = false beacon.beam.depth = true -iris.features.optional = ENTITY_TRANSLUCENT REVERSED_CULLING COMPUTE_SHADERS CUSTOM_IMAGES BLOCK_EMISSION_ATTRIBUTE SSBO TESSELLATION_SHADERS FADE_VARIABLE +iris.features.optional = ENTITY_TRANSLUCENT REVERSED_CULLING COMPUTE_SHADERS CUSTOM_IMAGES BLOCK_EMISSION_ATTRIBUTE SSBO TESSELLATION_SHADERS FADE_VARIABLE TEXTURE_FILTERING #ifdef REALMOON customTexture.moon = texture/moon.png