improved cloud draw perf

This commit is contained in:
minjaesong
2023-08-22 17:43:53 +09:00
parent a21f986f30
commit 52938a4b60
11 changed files with 38 additions and 49 deletions

View File

@@ -1,4 +1,4 @@
#version 150
#version 400
#ifdef GL_ES
precision mediump float;
#endif
@@ -16,5 +16,6 @@ const vec2 boolean = vec2(0.0, 1.0);
void main(void) {
vec4 colorTex0 = texture(u_texture, v_texCoords); // lightmap (RGB) pre-mixed
vec4 colorTex1 = texture(tex1, v_texCoords); // lightmap (A) pre-mixed
fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + (colorTex0 * boolean.xxxy);
// fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + (colorTex0 * boolean.xxxy);
fragColor = fma(max(colorTex0, colorTex1), boolean.yyyx, colorTex0 * boolean.xxxy);
}

View File

@@ -1,4 +1,4 @@
#version 150
#version 400
#ifdef GL_ES
precision mediump float;
#endif
@@ -150,7 +150,10 @@ void main(void) {
); // c = c0..c1
fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + boolean.xxxy;
// fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + boolean.xxxy;
fragColor = fma(max(colorTex0, colorTex1), boolean.yyyx, boolean.xxxy);
// fragColor = colorTex1;
// fragColor = randomness * boolean.yyyx + boolean.xxxy;
// fragColor = (randomness.rrrr + (colorTex1 * vec4(2.0, -2.0, 2.0, 1.0))) * boolean.yyyx + boolean.xxxy;

View File

@@ -1,4 +1,4 @@
#version 150
#version 400
#ifdef GL_ES
#define LOWP lowp
@@ -7,7 +7,7 @@ precision mediump float;
#define LOWP
#endif
in LOWP vec4 v_color;
in LOWP vec4 v_color; // lightCol.rgb + cloud's alpha
in vec2 v_texCoords;
uniform sampler2D u_texture;
out vec4 fragColor;
@@ -16,10 +16,15 @@ const vec2 boolean = vec2(0.0, 1.0);
uniform vec2 gamma = vec2(10, 2.0); // vec2(gamma for RGB, gamma for A)
uniform LOWP vec4 shadeCol;
void main() {
// r: bw diffuse map, g: normal, b: normal, a: bw diffuse alpha
vec4 inCol = texture(u_texture, v_texCoords);
vec4 rawCol = pow(inCol, gamma.xxxy);
vec4 outCol = pow(inCol, gamma.xxxy);
// do gradient mapping here
vec4 outCol = fma(mix(shadeCol, v_color, rawCol.r), boolean.yyyx, rawCol * boolean.xxxy);
fragColor = outCol * v_color;
fragColor = outCol * fma(v_color, boolean.xxxy, boolean.yyyx);
}

View File

@@ -1,4 +1,4 @@
#version 150
#version 400
#ifdef GL_ES
precision mediump float;
#endif
@@ -41,7 +41,8 @@ vec4 getDitherredDot(vec4 inColor) {
void main(void) {
float scale = v_texCoords.y * (1.0 - parallax_size) + (parallax_size / 2.0) + (parallax * parallax_size / 2.0);
float parallaxAdder = 0.5 * (parallax + 1.0) * parallax_size;
float scale = fma(v_texCoords.y, 1.0 - parallax_size, parallaxAdder);
float zoomSamplePoint = (1.0 - zoomInv) / 2.0;// will never quite exceed 0.5

View File

@@ -1,4 +1,4 @@
#version 150
#version 400
in vec4 v_color;
in vec2 v_texCoords;
uniform sampler2D u_texture;
@@ -11,5 +11,6 @@ void main(void) {
vec4 incolour = texture(u_texture, v_texCoords);
float lum = dot(incolour * desaturate, boolean.yyyx) * 0.5 + 0.5;
fragColor = v_color * (vec4(lum) * boolean.yyyx + incolour * boolean.xxxy);
// fragColor = v_color * (vec4(lum) * boolean.yyyx + incolour * boolean.xxxy);
fragColor = v_color * fma(vec4(lum), boolean.yyyx, incolour * boolean.xxxy);
}

View File

@@ -3,7 +3,7 @@
* http://momentsingraphics.de/BlueNoise.html
*/
#version 150
#version 400
#ifdef GL_ES
precision mediump float;
#endif
@@ -79,7 +79,7 @@ void main(void) {
// Dither the output
vec4 graded = ycocg_to_rgb * newColour;
vec4 selvec = getDitherredDot(graded);
vec4 outcol = selvec * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A
vec4 outcol = fma(selvec, boolean.yyyx, boolean.xxxy); // use quantised RGB but not the A
fragColor = outcol;
// ivec4 bytes = ivec4(255.0 * outcol);

View File

@@ -3,7 +3,7 @@
* http://momentsingraphics.de/BlueNoise.html
*/
#version 150
#version 400
#ifdef GL_ES
precision mediump float;
#endif
@@ -60,5 +60,5 @@ void main(void) {
// Dither the output
vec4 graded = ycocg_to_rgb * newColour;
fragColor = graded * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A
fragColor = fma(graded, boolean.yyyx, boolean.xxxy); // use quantised RGB but not the A
}

View File

@@ -2,7 +2,7 @@
*/
#version 150
#version 400
#ifdef GL_ES
precision mediump float;
#endif
@@ -107,7 +107,7 @@ void main() {
vec4 finalBreakage = drawBreakage * texture(tilesAtlas, finalUVCoordForBreakage); // drawBreakeage = 0 to not draw, = 1 to draw
vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx);
vec4 finalColor = fma(mix(finalTile, finalBreakage, finalBreakage.a), bc.xxxy, finalTile * bc.yyyx);
fragColor = mix(colourFilter, colourFilter * finalColor, mulBlendIntensity);

View File

@@ -2,7 +2,7 @@
*/
#version 150
#version 400
#ifdef GL_ES
precision mediump float;
#endif
@@ -121,5 +121,5 @@ void main() {
vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize));
float bayerThreshold = float(bayer[int(entry.y) * int(bayerSize) + int(entry.x)]) / bayerDivider;
fragColor = undithered * bc.xxxy + vec4((undithered.a > bayerThreshold) ? 1.0 : 0.0) * bc.yyyx;
fragColor = fma(undithered, bc.xxxy, vec4((undithered.a > bayerThreshold) ? 1.0 : 0.0) * bc.yyyx);
}