Hey Patrice,
I've just noticed that the mip_/nomip_ feature for shader samplers isn't yet implemented in OR. Thus, if you run the tinyclouds.fs background shader, you'll notice that the darker cloud areas seem dithered. That's because the noise texture used in the shader gets mipmapped when loaded while in fact it shouldn't.
So in the tinyclouds.fs shader code, change the two occurrences of colornoise_png to nomip_colornoise_png, and in shaders.h, change the glsl_LoadShaderFromFile() code as follows:
GLuint glsl_LoadShaderFromFile(IN WCHAR* fName) {
// Mobj_createGlTextureFromFileEX OUT parms
BYTE* lpArray = NULL;
long X = 0, Y = 0;
BKSHADER* cs = &gP.tCurAniBkgndShader;
WCHAR wTmp[MAX_PATH] = { 0 };
GLuint program = 0, vertShader = 0, fragShader = 0;
char* p = NULL;
char samplerMap[MAX_PATH] = { 0 };
BOOL bNoMip = FALSE;
if (wcsstr(fName, L"\\")) { // PAT: 12-12-2019
wcscopy(wTmp, fName);
} else {
Path_Combine(wTmp, EXEresource(), L"Animated\\");
Add_Str(wTmp, fName);
}
FILE* pFile = _wfopen(wTmp, L"r");
if (!pFile)
return 0;
DWORD fSize = FileSize(wTmp);
char* fs = (char*)calloc(1, fSize + 1);
fread(fs, 1, fSize, pFile);
fclose(pFile);
vertShader = glsl_CompileShader(GL_VERTEX_SHADER, vsReusable, lstrlenA(vsReusable));
fragShader = glsl_CompileShader(GL_FRAGMENT_SHADER, fs, lstrlenA(fs));
free(fs);
if (vertShader && fragShader) {
program = cs->nShaderID = glsl_LinkShaders(vertShader, fragShader);
glDeleteShader(vertShader); // this only marks shaders for deletion; they'll be
glDeleteShader(fragShader); // deleted together with program in resetCurAniShader()
}
// Store shader file name
wcscpy(cs->shFileName, wTmp); // don't know if we need it yet
// Locate sampler uniforms and create textures
for (int idx = 0; idx <= 3; idx++) { // up to 4 2D samplers
if (cs->samplerName[idx][0]) {
strcpy(samplerMap, cs->samplerName[idx]);
cs->samplerLoc[idx] = glGetUniformLocation(program, samplerMap); // still name, not map!
if (strstr(samplerMap, "nomip_")) {
strcpy(samplerMap, &samplerMap[6]);
bNoMip = TRUE;
}
else if (strstr(samplerMap, "mip_"))
strcpy(samplerMap, &samplerMap[4]);
if (p = strstr(samplerMap, "_")) // replace '_' with '.' to get valid map file name
*p = '.';
Path_Combine(wTmp, EXEresource(), L"Animated\\");
Add_Str(wTmp, cswconv(samplerMap));
if (Mobj_createGlTextureFromFileEX(wTmp, X, Y, lpArray, TEX_REPEAT)) {
glGenTextures(1, &(cs->samplerMapID[idx]));
glBindTexture(GL_TEXTURE_2D, cs->samplerMapID[idx]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (bNoMip) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, X, Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA8, X, Y, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
}
glBindTexture(GL_TEXTURE_2D, 0);
delete[] lpArray; lpArray = NULL;
}
}
}
// Locate float and vector uniforms (common for all background shaders)
cs->nTimeLoc = glGetUniformLocation(program, "iTime");
cs->nResLoc = glGetUniformLocation(program, "iResolution");
cs->nMouseLoc = glGetUniformLocation(program, "iMouse");
cs->nDateLoc = glGetUniformLocation(program, "iDate");
return program;
}
Now if you run this shader, you'll see the darker clouds are crisp and clear and devoid of dither at any main window sizes.