mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 08:36:07 +09:00
much more elegant solution than stretching texture using batch
This commit is contained in:
@@ -11,9 +11,10 @@ uniform sampler2D u_texture; // world texture, has alpha value that is meaningfu
|
||||
uniform sampler2D tex1; // glow texture, SHOULD contain alpha of all 1.0
|
||||
out vec4 fragColor;
|
||||
|
||||
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 = vec4(max(colorTex0.rgb, colorTex1.rgb), colorTex0.a);
|
||||
fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + (colorTex0 * boolean.xxxy);
|
||||
}
|
||||
22
src/shaders/blendMax.frag
Normal file
22
src/shaders/blendMax.frag
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 150
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
in vec4 v_color;
|
||||
in vec2 v_texCoord0;
|
||||
in vec2 v_texCoord1;
|
||||
uniform sampler2D u_texture; // world texture, has alpha value that is meaningful
|
||||
|
||||
uniform sampler2D tex1; // glow texture, SHOULD contain alpha of all 1.0
|
||||
out vec4 fragColor;
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
|
||||
void main(void) {
|
||||
vec4 colorTex0 = texture(u_texture, v_texCoord0); // lightmap (RGB) pre-mixed
|
||||
vec4 colorTex1 = texture(tex1, v_texCoord1); // lightmap (A) pre-mixed
|
||||
// fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + boolean.xxxy;
|
||||
fragColor = colorTex0;
|
||||
}
|
||||
19
src/shaders/blendMax.vert
Normal file
19
src/shaders/blendMax.vert
Normal file
@@ -0,0 +1,19 @@
|
||||
#version 150
|
||||
|
||||
in vec4 a_position;
|
||||
in vec4 a_color;
|
||||
in vec2 a_texCoord0;
|
||||
in vec2 a_texCoord1;
|
||||
|
||||
uniform mat4 u_projTrans; // camera.combined
|
||||
|
||||
out vec4 v_color;
|
||||
out vec2 v_texCoord0;
|
||||
out vec2 v_texCoord1;
|
||||
|
||||
void main() {
|
||||
v_color = a_color;
|
||||
v_texCoord0 = a_texCoord0;
|
||||
v_texCoord1 = a_texCoord1;
|
||||
gl_Position = u_projTrans * a_position;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#version 150
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
in vec4 v_color;
|
||||
in vec2 v_texCoords;
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(void) {
|
||||
fragColor = vec4(texture(u_texture, v_texCoords).rgb, 1.0);
|
||||
}
|
||||
@@ -8,5 +8,5 @@ vec2 boolean = vec2(0.0, 1.0);
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(void) {
|
||||
fragColor = texture(u_texture, v_texCoords).rgba * boolean.yyyx + boolean.xxxy;
|
||||
fragColor = texture(u_texture, v_texCoords) * boolean.yyyx + boolean.xxxy;
|
||||
}
|
||||
Reference in New Issue
Block a user