Skip to content

Commit 8e10291

Browse files
committed
Merge remote-tracking branch 'origin/master' into gles-shaders
2 parents 97ecb88 + cb1cb56 commit 8e10291

68 files changed

Lines changed: 1435 additions & 717 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ci/post/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Mako==1.3.11
1+
Mako==1.3.12
22
requests==2.32.4
33
semantic-version==2.8.5

code/cfile/cfilesystem.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,9 @@ int cf_create_default_path_string(SCP_string& path, int pathtype, const char* fi
24372437
}
24382438

24392439
if (!root) {
2440-
Assert( filename != NULL );
2440+
if (filename == nullptr) {
2441+
return 0;
2442+
}
24412443
path.assign(filename);
24422444
return 1;
24432445
}

code/def_files/data/effects/fog-f.sdr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ layout (std140) uniform genericData {
2020
float fog_density;
2121
float zNear;
2222
float zFar;
23+
24+
float clip_inf_dist;
25+
float clip_dist;
2326
};
2427

2528
void main()
@@ -33,6 +36,9 @@ void main()
3336
// Now we compute the depth value in projection space using the clipping plane information
3437
float view_depth = 2.0 * zNear * zFar / (zFar + zNear - depth_normalized * (zFar - zNear));
3538

39+
float skybox_compat_fake = step(1.0, depth_val);
40+
view_depth = clamp(view_depth, 0.0, mix(clip_dist, clip_inf_dist, skybox_compat_fake));
41+
3642
if (isinf(view_depth)) {
3743
fragOut0.rgb = color_in.rgb;
3844
} else {

code/def_files/data/effects/main-f.sdr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ layout (std140) uniform modelData {
4747
model_light lights[MAX_LIGHTS];
4848

4949
float outlineWidth;
50-
float fogStart;
51-
float fogScale;
50+
float fogNear;
51+
float fogDensity;
5252
int buffer_matrix_offset;
5353

5454
vec4 clip_equation;
@@ -392,9 +392,10 @@ void main()
392392
#prereplace ENDIF_FLAG //MODEL_SDR_FLAG_DIFFUSE
393393
// This code will only be used by the forward renderer so we apply the fog effect to both the emissive and the base
394394
// color.
395-
baseColor.rgb = mix(emissiveColor.rgb + baseColor.rgb, finalFogColor, vertIn.fogDist);
395+
float fogDensityFinal = clamp(1 - pow(fogDensity, vertIn.fogDist) , 0.0, 1.0);
396+
baseColor.rgb = mix(emissiveColor.rgb + baseColor.rgb, finalFogColor, fogDensityFinal);
396397
emissiveColor.rgb = vec3(0.0); // Zero the emissive color since it has already been added by the previous line
397-
specColor.rgb *= vertIn.fogDist;
398+
specColor.rgb *= fogDensityFinal;
398399
#prereplace ENDIF_FLAG //MODEL_SDR_FLAG_FOG
399400

400401
#prereplace IF_FLAG MODEL_SDR_FLAG_DIFFUSE

code/def_files/data/effects/main-g.sdr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ layout (std140) uniform modelData {
5454
model_light lights[MAX_LIGHTS];
5555

5656
float outlineWidth;
57-
float fogStart;
58-
float fogScale;
57+
float fogNear;
58+
float fogDensity;
5959
int buffer_matrix_offset;
6060

6161
vec4 clip_equation;

code/def_files/data/effects/main-v.sdr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ layout (std140) uniform modelData {
5050
model_light lights[MAX_LIGHTS];
5151

5252
float outlineWidth;
53-
float fogStart;
54-
float fogScale;
53+
float fogNear;
54+
float fogDensity;
5555
int buffer_matrix_offset;
5656

5757
vec4 clip_equation;
@@ -203,7 +203,7 @@ void main()
203203
vertOut.tangentMatrix = mat3(t, b, normal);
204204

205205
#prereplace IF_FLAG MODEL_SDR_FLAG_FOG
206-
vertOut.fogDist = clamp((gl_Position.z - fogStart) * 0.75 * fogScale, 0.0, 1.0);
206+
vertOut.fogDist = gl_Position.z - fogNear;
207207
#prereplace ENDIF_FLAG //MODEL_SDR_FLAG_FOG
208208

209209
#prereplace IF_FLAG MODEL_SDR_FLAG_TRANSFORM

code/gamesnd/gamesnd.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ void gamesnd_unload_gameplay_sounds()
601601
}
602602
}
603603
}
604+
snd_unload_cleanup();
604605
}
605606

606607
/**
@@ -636,6 +637,7 @@ void gamesnd_unload_interface_sounds()
636637
}
637638
}
638639
}
640+
snd_unload_cleanup();
639641
}
640642

641643
void parse_gamesnd_old(game_snd* gs)

code/graphics/material.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,12 @@ bool model_material::is_batched() const
674674
return Batched;
675675
}
676676

677-
void model_material::set_fog(int r, int g, int b, float _near, float _far)
677+
void model_material::set_fog(int r, int g, int b)
678678
{
679679
Fog_params.enabled = true;
680680
Fog_params.r = r;
681681
Fog_params.g = g;
682682
Fog_params.b = b;
683-
Fog_params.dist_near = _near;
684-
Fog_params.dist_far = _far;
685683
}
686684

687685
void model_material::set_fog()

code/graphics/material.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ class model_material : public material
172172
int r = 0;
173173
int g = 0;
174174
int b = 0;
175-
float dist_near = -1.0f;
176-
float dist_far = -1.0f;
177175
};
178176

179177
private:
@@ -255,7 +253,7 @@ class model_material : public material
255253
int get_shader_runtime_early_flags() const;
256254
int get_shader_runtime_flags() const;
257255

258-
void set_fog(int r, int g, int b, float near, float far);
256+
void set_fog(int r, int g, int b);
259257
void set_fog();
260258
bool is_fogged() const;
261259
const fog& get_fog() const;

code/graphics/opengl/es_compatibility.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
2828
#define GL_BGR 0x80E0
2929
#define GL_MULTISAMPLE 0x809D
30+
#define GL_CLAMP_READ_COLOR 0x891C
31+
#define GL_CLAMP_VERTEX_COLOR 0x891A
32+
#define GL_CLAMP_FRAGMENT_COLOR 0x891B
33+
#define GL_FIXED_ONLY 0x891D
3034

3135
//Enums Redefinitions
3236
#define GL_CLIP_DISTANCE0 GL_CLIP_DISTANCE0_EXT // GL_EXT_clip_cull_distance
@@ -268,6 +272,8 @@ static inline void glTexImage2D(GLenum target, GLint level, GLint internalformat
268272
glad_glTexImage2D(target, level, internalformat, width, height, border, GL_RGBA, GL_UNSIGNED_BYTE, data);
269273
} else if (internalformat == GL_DEPTH_COMPONENT24) {
270274
glad_glTexImage2D(target, level, internalformat, width, height, border, format, GL_UNSIGNED_INT, data);
275+
} else if (internalformat == GL_DEPTH24_STENCIL8) {
276+
glad_glTexImage2D(target, level, internalformat, width, height, border, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, data);
271277
} else {
272278
glad_glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
273279
}
@@ -307,6 +313,9 @@ static inline void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
307313
Missing functions for ES 3.2 compatibility
308314
*/
309315

316+
// Used during screenshots, that dont work anyway.
317+
#define glClampColor(target, clamp) ((void)0)
318+
310319
// Not present on ES, emulating with glDrawBuffers
311320
// Positional mapping: element i must be COLOR_ATTACHMENTi o NONE.
312321
// ONLY for blits/clears. For draw calls the location of frag shader

0 commit comments

Comments
 (0)