spritebatch with hdr colour

This commit is contained in:
minjaesong
2023-09-14 23:17:37 +09:00
parent f8b74f2445
commit d6fea9889e
9 changed files with 1410 additions and 103 deletions

View File

@@ -1,49 +1,15 @@
#version 400
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
in LOWP vec4 v_color; // lightCol.rgb + cloud's alpha
in vec4 v_color; // lightCol
in vec4 v_generic; // gamma values
in vec2 v_texCoords;
uniform sampler2D u_texture;
out vec4 fragColor;
const vec2 boolean = vec2(0.0, 1.0);
uniform LOWP vec4 shadeCol;
const float rgbGammas[16] = float[](
0.2,
0.3,
0.4,
0.5,
0.6,
0.7,
0.8,
0.9,
1.0,
1.25,
1.5,
1.75,
2.0,
2.5,
3.0,
3.5
);
const float aGammas[4] = float[](
1.6,
2.0,
2.4,
2.8
);
uniform vec4 shadeCol;
void main() {
// vertex colour format:
@@ -54,15 +20,10 @@ void main() {
// bbbbbb: 6-bit blue component
// MMLL: index to the rgbGammas
// AA: index to the aGammas
vec4 cloudCol = vec4(
(int(v_color.r * 255) >> 2) * 4.0 / 255.0,
(int(v_color.g * 255) >> 2) * 4.0 / 255.0,
(int(v_color.b * 255) >> 2) * 4.0 / 255.0,
v_color.a
);
float rgbGamma = rgbGammas[((int(v_color.r * 255) & 3) << 2) | (int(v_color.g * 255) & 3)];
float aGamma = aGammas[int(v_color.b * 255) & 3];
vec4 gamma = vec4(rgbGamma, rgbGamma, rgbGamma, aGamma);
vec4 cloudCol = v_color;
float rgbGamma = v_generic.x;
float aGamma = v_generic.y;
vec4 gamma = v_generic.xxxy;
vec4 range = vec4(vec3(min(rgbGamma, 1.0 / rgbGamma)), 1.0);
vec4 offset = vec4(vec3(max(0.0, 1.0 - rgbGamma)), 0.0);

View File

@@ -2,16 +2,18 @@
in vec4 a_position;
in vec4 a_color;
in vec4 a_generic;
in vec2 a_texCoord0;
uniform mat4 u_projTrans;
out vec4 v_color;
out vec2 v_texCoords;
out vec4 v_generic;
void main() {
v_color = a_color;
v_color.a = v_color.a * (255.0/254.0); // GDX will crush the alpha value to 0,2,4,6,8,10,...,254; see com.badlogic.gdx.utils.NumberUtils.intToFloatColor
v_texCoords = a_texCoord0;
v_generic = a_generic;
gl_Position = u_projTrans * a_position;
}

View File

@@ -1,13 +1,11 @@
#version 150
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
in LOWP vec4 v_color;
in vec4 v_color;
in vec4 v_generic;
in vec2 v_texCoords;
uniform sampler2D u_texture;
out vec4 fragColor;

View File

@@ -2,16 +2,18 @@
in vec4 a_position;
in vec4 a_color;
in vec4 a_generic;
in vec2 a_texCoord0;
uniform mat4 u_projTrans;
out vec4 v_color;
out vec2 v_texCoords;
out vec4 v_generic;
void main() {
v_color = a_color;
v_color.a = v_color.a * (255.0/254.0);
v_texCoords = a_texCoord0;
v_generic = a_generic;
gl_Position = u_projTrans * a_position;
}
}