mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-08 14:56:12 -04:00
OpenGL2: Avoid a division/reciprocal for linear fog calculation
This commit is contained in:
parent
7a39d2a4ee
commit
1abb1f39f5
@ -266,7 +266,7 @@ static void GenFragmentShader(const struct GLShader* shader, cc_string* dst) {
|
||||
else String_AppendConst(dst, " vec4 col = out_col;\n");
|
||||
if (al) String_AppendConst(dst, " if (col.a < 0.5) discard;\n");
|
||||
if (fm) String_AppendConst(dst, " float depth = 1.0 / gl_FragCoord.w;\n");
|
||||
if (fl) String_AppendConst(dst, " float f = clamp((fogEnd - depth) / fogEnd, 0.0, 1.0);\n");
|
||||
if (fl) String_AppendConst(dst, " float f = clamp(1.0 - depth * fogEnd, 0.0, 1.0);\n");
|
||||
if (fd) String_AppendConst(dst, " float f = clamp(exp(fogDensity * depth), 0.0, 1.0);\n");
|
||||
if (fm) String_AppendConst(dst, " col.rgb = mix(fogCol, col.rgb, f);\n");
|
||||
|
||||
@ -402,7 +402,7 @@ static void ReloadUniforms(void) {
|
||||
s->uniforms &= ~UNI_FOG_COL;
|
||||
}
|
||||
if ((s->uniforms & UNI_FOG_END) && (s->features & FTR_LINEAR_FOG)) {
|
||||
glUniform1f(s->locations[3], gfx_fogEnd);
|
||||
glUniform1f(s->locations[3], 1.0f / gfx_fogEnd);
|
||||
s->uniforms &= ~UNI_FOG_END;
|
||||
}
|
||||
if ((s->uniforms & UNI_FOG_DENS) && (s->features & FTR_DENSIT_FOG)) {
|
||||
|
@ -490,7 +490,6 @@ void MapRenderer_Refresh(void) {
|
||||
|
||||
if (mapChunks && World.Blocks) {
|
||||
DeleteChunks();
|
||||
RefreshChunks();
|
||||
|
||||
oldCount = MapRenderer_1DUsedCount;
|
||||
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
||||
@ -750,7 +749,7 @@ static void OnTerrainAtlasChanged(void* obj) {
|
||||
}
|
||||
|
||||
static void OnBlockDefinitionChanged(void* obj) {
|
||||
RefreshChunks();
|
||||
MapRenderer_Refresh();
|
||||
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
||||
ResetPartFlags();
|
||||
}
|
||||
|
@ -741,3 +741,4 @@ static cc_result GetMachineID(cc_uint32* key) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user