Ian wrote:good image of it
Ian wrote:Should we emulate this? I dunno I am mixed. It's probably a performance cheat they are doing on the hardware itself. But we are bound by no such limitations.
#version 400
float mipmapLevel = textureQueryLod(myTexture, textureCoord).x;
float LODLevel = textureQueryLod(myTexture, textureCoord).y;
#version 330
#extension GL_ARB_texture_query_lod : enable
float mipmapLevel = textureQueryLOD(myTexture, textureCoord).x;
float LODLevel = textureQueryLOD(myTexture, textureCoord).y;
float getMipLevel(in const vec2 coord, in const sampler2D tex)
{
vec2 texSize = textureSize(tex, 0);
vec2 coordXY = coord * texSize;
// VERSION 1 - Follows OpenGL standard
//vec2 dx_vtc = dFdx(coordXY);
//vec2 dy_vtc = dFdy(coordXY);
//float delta_max_sqr = max(dot(dx_vtc, dx_vtc), dot(dy_vtc, dy_vtc));
// VERSION 2 - Seems more uniform at some angles
float delta_max_sqr = dot(fwidth(coordXY), fwidth(coordXY));
delta_max_sqr = max(1.0, delta_max_sqr); // Safety check for paranoids
//float mml = 0.5 * log2(delta_max_sqr); // == log2(sqrt(delta_max_sqr)); // Harder transition
float mml = 0.5 * log(delta_max_sqr); // Softer transition
mml = max(0.0, mml); // Avoids negative MIPs
return mml;
}
// Fetch mipmapped microTexture
//micro = texture2D(tex2, coord.st * microScale * textureRatio);
// Fetch only LOD=0, disabling mipmapping in microTextures, seems to be more consistent to arcade version
micro = textureLod(tex2, coord.st * microScale * textureRatio, 0);
float lod, lodBias, blendFactor;
lodBias = -1.3;
lod = getMipLevel(coord.st, tex1) + lodBias; // Offsets LOD, "tex1" is the base texture
lod = max(0.0, lod);
lod = min(5.0, lod);
blendFactor = min(one, 0.5 + lod * 0.5);
fragment.rgb = mix(micro.rgb, base.rgb, blendFactor);
Users browsing this forum: No registered users and 1 guest