Open treellama opened 2 years ago
Possibly related to #272
void main(void) {
vec3 facev = vec3(cos(yaw), sin(yaw), sin(pitch));
vec3 relv = (relDir);
float x = relv.x / (relv.z * zoom) + atan(facev.x, facev.y);
float y = relv.y / (relv.z * zoom) - (facev.z * pitch_adjust);
vec4 color = texture2D(texture0, vec2(offsetx - x * scalex, offsety - y * scaley));
vec3 intensity = color.rgb;
if (usefog > 0.0) {
intensity = gl_Fog.color.rgb;
}
gl_FragColor = vec4(intensity, 1.0)
}
relv.y is negative when below eye center, and relv.z is always negative. y is negative over horizon, positive under horizon
double TexScale = ABS(TMgr->U_Scale);
short AdjustedVertExp = opts->VertExp + opts->OGL_AspRatExp;
double VertScale = (AdjustedVertExp >= 0) ? double(1 << AdjustedVertExp)
: 1/double(1 << (-AdjustedVertExp));
s->setFloat(Shader::U_ScaleY, VertScale * TexScale * Radian2Circle);
s->setFloat(Shader::U_OffsetY, (0.5 + TMgr->U_Offset) * TexScale);
U_ScaleY=4/(2*π)=0.63661977236758138, U_OffsetY=-0.5
Examining this again, it appears that t is always in [0.0, 1.0]. However, it is always mirroring, instead of respecting the vert_repeat option in landscapes MML.
It's masked by the fact that we use GL_MIRRORED_REPEAT, but the UV mapping for landscape is inverted. The T coordinate is always negative, which without GL_MIRRORED_REPEAT would just clamp to the edge.