Skip to content

Commit fa515d4

Browse files
committed
texture rendering issue. fixes #204
1 parent 7fa093e commit fa515d4

11 files changed

+62
-37
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ ChangeLog
197197

198198
- 3.3.1 (12/09/2022)
199199
- (f) fixed texture issue + color issue + blending issue. fixed #214
200+
- (f) fixed texture issue #204
200201
- 3.3.0 (23/06/2022)
201202
- (n) interactive object orientation
202203
- (n) isometric, orthographic and free camera view
309 Bytes
Binary file not shown.
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
precision mediump float;
22

33
// colors
4-
uniform vec4 vColorMask;
54
varying vec4 v_Color;
5+
uniform vec4 vColorMask;
66

77
// texture
88
uniform bool u_Textured;
99
uniform sampler2D u_Texture;
1010
varying vec2 v_TexCoordinate;
1111

1212
void main(){
13-
if (u_Textured){
14-
gl_FragColor = v_Color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
13+
vec4 color = v_Color;
14+
if (u_Textured && length(vec3(color)) > 0.0){
15+
gl_FragColor = color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
16+
} else if (u_Textured){
17+
gl_FragColor = texture2D(u_Texture, v_TexCoordinate) * vColorMask;
1518
} else {
16-
gl_FragColor = v_Color * vColorMask;
19+
gl_FragColor = color * vColorMask;
1720
}
18-
gl_FragColor[3] = v_Color[3];
21+
gl_FragColor[3] = color[3];
1922
}

engine/src/main/res/raw/shader_anim_light_texture_frag

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ uniform sampler2D u_Texture;
1010
varying vec2 v_TexCoordinate;
1111

1212
void main(){
13-
if (u_Textured){
14-
gl_FragColor = v_Color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
13+
vec4 color = v_Color;
14+
if (u_Textured && length(vec3(color)) > 0.0){
15+
gl_FragColor = color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
16+
} else if (u_Textured){
17+
gl_FragColor = texture2D(u_Texture, v_TexCoordinate) * vColorMask;
1518
} else {
16-
gl_FragColor = v_Color * vColorMask;
19+
gl_FragColor = color * vColorMask;
1720
}
18-
gl_FragColor[3] = v_Color[3];
21+
gl_FragColor[3] = color[3];
1922
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
precision mediump float;
22

33
// colors
4-
uniform vec4 vColorMask;
54
varying vec4 v_Color;
5+
uniform vec4 vColorMask;
66

77
// texture
88
uniform bool u_Textured;
99
uniform sampler2D u_Texture;
1010
varying vec2 v_TexCoordinate;
1111

1212
void main(){
13-
if (u_Textured){
14-
gl_FragColor = v_Color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
13+
vec4 color = v_Color;
14+
if (u_Textured && length(vec3(color)) > 0.0){
15+
gl_FragColor = color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
16+
} else if (u_Textured){
17+
gl_FragColor = texture2D(u_Texture, v_TexCoordinate) * vColorMask;
1518
} else {
16-
gl_FragColor = v_Color * vColorMask;
19+
gl_FragColor = color * vColorMask;
1720
}
18-
gl_FragColor[3] = v_Color[3];
21+
gl_FragColor[3] = color[3];
1922
}

engine/src/main/res/raw/shader_anim_texture_frag

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ uniform sampler2D u_Texture;
1010
varying vec2 v_TexCoordinate;
1111

1212
void main(){
13-
if (u_Textured){
14-
gl_FragColor = vColor * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
13+
vec4 color = vColor;
14+
if (u_Textured && length(vec3(color)) > 0.0){
15+
gl_FragColor = color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
16+
} else if (u_Textured){
17+
gl_FragColor = texture2D(u_Texture, v_TexCoordinate) * vColorMask;
1518
} else {
16-
gl_FragColor = vColor * vColorMask;
19+
gl_FragColor = color * vColorMask;
1720
}
18-
gl_FragColor[3] = vColor[3];
21+
gl_FragColor[3] = color[3];
1922
}

engine/src/main/res/raw/shader_light_colors_frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
precision mediump float;
22

33
// colors
4-
uniform vec4 vColorMask;
54
varying vec4 v_Color;
5+
uniform vec4 vColorMask;
66

77
void main(){
88
gl_FragColor = v_Color * vColorMask;
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
precision mediump float;
22

33
// colors
4-
uniform vec4 vColorMask;
54
varying vec4 v_Color;
5+
uniform vec4 vColorMask;
66

77
// texture
88
uniform bool u_Textured;
99
uniform sampler2D u_Texture;
1010
varying vec2 v_TexCoordinate;
1111

1212
void main(){
13-
if (u_Textured){
14-
gl_FragColor = v_Color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
13+
vec4 color = v_Color;
14+
if (u_Textured && length(vec3(color)) > 0.0){
15+
gl_FragColor = color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
16+
} else if (u_Textured){
17+
gl_FragColor = texture2D(u_Texture, v_TexCoordinate) * vColorMask;
1518
} else {
16-
gl_FragColor = v_Color * vColorMask;
19+
gl_FragColor = color * vColorMask;
1720
}
18-
gl_FragColor[3] = v_Color[3];
21+
gl_FragColor[3] = color[3];
1922
}

engine/src/main/res/raw/shader_light_texture_frag

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ uniform sampler2D u_Texture;
1010
varying vec2 v_TexCoordinate;
1111

1212
void main(){
13-
if (u_Textured){
14-
gl_FragColor = v_Color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
13+
vec4 color = v_Color;
14+
if (u_Textured && length(vec3(color)) > 0.0){
15+
gl_FragColor = color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
16+
} else if (u_Textured){
17+
gl_FragColor = texture2D(u_Texture, v_TexCoordinate) * vColorMask;
1518
} else {
16-
gl_FragColor = v_Color * vColorMask;
19+
gl_FragColor = color * vColorMask;
1720
}
18-
gl_FragColor[3] = v_Color[3];
21+
gl_FragColor[3] = color[3];
1922
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
precision mediump float;
22

33
// colors
4-
uniform vec4 vColorMask;
54
varying vec4 v_Color;
5+
uniform vec4 vColorMask;
66

77
// texture
88
uniform bool u_Textured;
99
uniform sampler2D u_Texture;
1010
varying vec2 v_TexCoordinate;
1111

1212
void main(){
13-
if (u_Textured){
14-
gl_FragColor = v_Color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
13+
vec4 color = v_Color;
14+
if (u_Textured && length(vec3(color)) > 0.0){
15+
gl_FragColor = color * texture2D(u_Texture, v_TexCoordinate) * vColorMask;
16+
} else if (u_Textured){
17+
gl_FragColor = texture2D(u_Texture, v_TexCoordinate) * vColorMask;
1518
} else {
16-
gl_FragColor = v_Color * vColorMask;
19+
gl_FragColor = color * vColorMask;
1720
}
18-
gl_FragColor[3] = v_Color[3];
21+
gl_FragColor[3] = color[3];
1922
}

0 commit comments

Comments
 (0)