Skip to content

Commit dc56d78

Browse files
authored
Update all shaders to GLSL version 1.4.0 (#11)
* Update CI * Update mipmap bias * Update fonts * Update all shaders to version 140
1 parent f6c3f40 commit dc56d78

36 files changed

+249
-661
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
if [ "${BOB_LOCAL_SHA1}" != "${BOB_SHA1}" ]; then wget --progress=dot:mega -O build/bundle/bob.jar "https://d.defold.com/archive/${BOB_SHA1}/bob/bob.jar"; fi
3939
java -jar build/bundle/bob.jar --version
4040
41-
java -jar build/bundle/bob.jar --email foo@bar.com --auth 12345 --texture-compression true --bundle-output build/bundle/js-web --platform js-web --archive --variant release resolve build bundle
41+
java -jar build/bundle/bob.jar --email foo@bar.com --auth 12345 --texture-compression true --bundle-output build/bundle/js-web --platform js-web --archive --variant debug resolve build bundle
4242
4343
- name: Upload Result
4444
uses: actions/upload-artifact@v4

demo/assets/font.font

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
font: "/builtins/fonts/vera_mo_bd.ttf"
2-
material: "/sharp_sprite/rgss/fonts/font.material"
2+
material: "/sharp_sprite/rgss/fonts/font-singlelayer.material"
33
size: 72
4-
antialias: 1
5-
alpha: 1.0
6-
outline_alpha: 0.0
7-
outline_width: 0.0
8-
shadow_alpha: 0.0
9-
shadow_blur: 0
10-
shadow_x: 0.0
11-
shadow_y: 0.0
12-
extra_characters: ""
13-
output_format: TYPE_BITMAP
14-
all_chars: false
15-
cache_width: 0
16-
cache_height: 0
17-
render_mode: MODE_SINGLE_LAYER
4+
characters: " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
varying highp vec2 var_texcoord0;
2-
varying lowp vec4 var_color;
1+
#version 140
32

4-
uniform lowp sampler2D texture_sampler;
3+
in highp vec2 var_texcoord0;
4+
in mediump vec4 var_color;
5+
6+
out vec4 out_fragColor;
7+
8+
uniform mediump sampler2D texture_sampler;
59

610
void main()
711
{
8-
lowp vec4 tex = texture2D(texture_sampler, var_texcoord0.xy, -1.0);
9-
gl_FragColor = tex * var_color;
12+
out_fragColor = texture(texture_sampler, var_texcoord0.xy, -1.0) * var_color;
1013
}

sharp_sprite/mipmap_bias/materials/gui.material

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@ name: "gui"
22
tags: "gui"
33
vertex_program: "/builtins/materials/gui.vp"
44
fragment_program: "/sharp_sprite/mipmap_bias/materials/gui.fp"
5-
vertex_space: VERTEX_SPACE_WORLD
65
vertex_constants {
76
name: "view_proj"
87
type: CONSTANT_TYPE_VIEWPROJ
9-
value {
10-
x: 0.0
11-
y: 0.0
12-
z: 0.0
13-
w: 0.0
14-
}
158
}
169
samplers {
1710
name: "texture_sampler"
1811
wrap_u: WRAP_MODE_CLAMP_TO_EDGE
1912
wrap_v: WRAP_MODE_CLAMP_TO_EDGE
2013
filter_min: FILTER_MODE_MIN_LINEAR_MIPMAP_LINEAR
2114
filter_mag: FILTER_MODE_MAG_LINEAR
22-
}
15+
}
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
varying highp vec2 var_texcoord0;
2-
varying lowp vec4 var_color;
1+
#version 140
32

4-
uniform lowp sampler2D texture_sampler;
5-
uniform lowp vec4 tint;
3+
in highp vec2 var_texcoord0;
4+
in mediump vec4 var_color;
5+
6+
out vec4 out_fragColor;
7+
8+
uniform mediump sampler2D texture_sampler;
9+
uniform fs_uniforms
10+
{
11+
mediump vec4 tint;
12+
};
613

714
void main()
815
{
916
// Pre-multiply alpha since all runtime textures already are
10-
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
17+
mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
1118
// var_color is vertex color from the particle system, pre-multiplied in vertex program
12-
gl_FragColor = texture2D(texture_sampler, var_texcoord0.xy, -1.0) * var_color * tint_pm;
19+
out_fragColor = texture(texture_sampler, var_texcoord0.xy, -1.0) * var_color * tint_pm;
1320
}

sharp_sprite/mipmap_bias/materials/particlefx.material

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
name: "particlefx"
1+
name: "particle"
22
tags: "particle"
33
vertex_program: "/builtins/materials/particlefx.vp"
44
fragment_program: "/sharp_sprite/mipmap_bias/materials/particlefx.fp"
5-
vertex_space: VERTEX_SPACE_WORLD
65
vertex_constants {
76
name: "view_proj"
87
type: CONSTANT_TYPE_VIEWPROJ
9-
value {
10-
x: 0.0
11-
y: 0.0
12-
z: 0.0
13-
w: 0.0
14-
}
158
}
169
fragment_constants {
1710
name: "tint"
@@ -29,4 +22,4 @@ samplers {
2922
wrap_v: WRAP_MODE_CLAMP_TO_EDGE
3023
filter_min: FILTER_MODE_MIN_LINEAR_MIPMAP_LINEAR
3124
filter_mag: FILTER_MODE_MAG_LINEAR
32-
}
25+
}
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
varying highp vec2 var_texcoord0;
2-
varying lowp vec4 var_color;
1+
#version 140
32

4-
uniform lowp sampler2D texture_sampler;
5-
uniform lowp vec4 tint;
3+
in highp vec2 var_texcoord0;
4+
in mediump vec4 var_color;
5+
6+
out vec4 out_fragColor;
7+
8+
uniform mediump sampler2D texture_sampler;
9+
uniform fs_uniforms
10+
{
11+
mediump vec4 tint;
12+
};
613

714
void main()
815
{
916
// Pre-multiply alpha since var_color and all runtime textures already are
10-
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
11-
lowp vec4 color_pm = var_color * tint_pm;
12-
gl_FragColor = texture2D(texture_sampler, var_texcoord0.xy, -1.0) * color_pm;
17+
mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
18+
mediump vec4 color_pm = var_color * tint_pm;
19+
// var_color is vertex color from the particle system, pre-multiplied in vertex program
20+
out_fragColor = texture(texture_sampler, var_texcoord0.xy, -1.0) * color_pm;
1321
}
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
varying highp vec2 var_texcoord0;
1+
#version 140
22

3-
uniform lowp sampler2D texture_sampler;
4-
uniform lowp vec4 tint;
3+
in highp vec2 var_texcoord0;
4+
5+
out vec4 out_fragColor;
6+
7+
uniform mediump sampler2D texture_sampler;
8+
uniform fs_uniforms
9+
{
10+
mediump vec4 tint;
11+
};
512

613
void main()
714
{
815
// Pre-multiply alpha since all runtime textures already are
9-
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
10-
gl_FragColor = texture2D(texture_sampler, var_texcoord0.xy, -1.0) * tint_pm;
16+
mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
17+
out_fragColor = texture(texture_sampler, var_texcoord0.xy, -1.0) * tint_pm;
1118
}

sharp_sprite/mipmap_bias/materials/sprite.material

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ name: "sprite"
22
tags: "tile"
33
vertex_program: "/builtins/materials/sprite.vp"
44
fragment_program: "/sharp_sprite/mipmap_bias/materials/sprite.fp"
5-
vertex_space: VERTEX_SPACE_WORLD
65
vertex_constants {
76
name: "view_proj"
87
type: CONSTANT_TYPE_VIEWPROJ
9-
value {
10-
x: 0.0
11-
y: 0.0
12-
z: 0.0
13-
w: 0.0
14-
}
158
}
169
fragment_constants {
1710
name: "tint"
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
varying highp vec2 var_texcoord0;
1+
#version 140
22

3-
uniform lowp sampler2D texture_sampler;
4-
uniform lowp vec4 tint;
3+
in highp vec2 var_texcoord0;
4+
5+
out vec4 out_fragColor;
6+
7+
uniform mediump sampler2D texture_sampler;
8+
uniform fs_uniforms
9+
{
10+
mediump vec4 tint;
11+
};
512

613
void main()
714
{
815
// Pre-multiply alpha since all runtime textures already are
9-
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
10-
gl_FragColor = texture2D(texture_sampler, var_texcoord0.xy, -1.0) * tint_pm;
16+
mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
17+
out_fragColor = texture(texture_sampler, var_texcoord0.xy, -1.0) * tint_pm;
1118
}

sharp_sprite/mipmap_bias/materials/tile_map.material

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,9 @@ name: "tile_map"
22
tags: "tile"
33
vertex_program: "/builtins/materials/tile_map.vp"
44
fragment_program: "/sharp_sprite/mipmap_bias/materials/tile_map.fp"
5-
vertex_space: VERTEX_SPACE_WORLD
65
vertex_constants {
76
name: "view_proj"
87
type: CONSTANT_TYPE_VIEWPROJ
9-
value {
10-
x: 0.0
11-
y: 0.0
12-
z: 0.0
13-
w: 0.0
14-
}
15-
}
16-
vertex_constants {
17-
name: "world"
18-
type: CONSTANT_TYPE_WORLD
19-
value {
20-
x: 0.0
21-
y: 0.0
22-
z: 0.0
23-
w: 0.0
24-
}
258
}
269
fragment_constants {
2710
name: "tint"

sharp_sprite/rgss/fonts/font-fnt.fp

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,15 @@
1-
#ifdef GL_OES_standard_derivatives
2-
#extension GL_OES_standard_derivatives : enable
3-
#endif
1+
#version 140
42

5-
varying highp vec2 var_texcoord0;
6-
varying lowp vec4 var_face_color;
3+
#include "/sharp_sprite/rgss/rgss.glsl"
74

8-
uniform mediump sampler2D texture_sampler;
9-
10-
// Derivative functions are available on:
11-
// - OpenGL (desktop).
12-
// - OpenGL ES 3.0, WebGL 2.0.
13-
// - OpenGL ES 2.0, WebGL 1.0, if the extension GL_OES_standard_derivatives is enabled.
14-
#if !defined(GL_ES) || __VERSION__ >= 300 || defined(GL_OES_standard_derivatives)
15-
// Rotated grid UV offsets
16-
const mediump vec2 rgss_uv_offsets = vec2(0.125, 0.375);
17-
18-
mediump vec4 rgss_tex2D(highp vec2 uv)
19-
{
20-
// Per pixel partial derivatives
21-
mediump vec2 dx = dFdx(uv);
22-
mediump vec2 dy = dFdy(uv);
23-
24-
// Supersampled using 2x2 rotated grid
25-
mediump vec4 col = texture2D(texture_sampler, vec2(uv + rgss_uv_offsets.x * dx + rgss_uv_offsets.y * dy));
26-
col += texture2D(texture_sampler, vec2(uv - rgss_uv_offsets.x * dx - rgss_uv_offsets.y * dy));
27-
col += texture2D(texture_sampler, vec2(uv + rgss_uv_offsets.y * dx - rgss_uv_offsets.x * dy));
28-
col += texture2D(texture_sampler, vec2(uv - rgss_uv_offsets.y * dx + rgss_uv_offsets.x * dy));
5+
in highp vec2 var_texcoord0;
6+
in mediump vec4 var_face_color;
297

30-
col *= 0.25;
8+
out vec4 out_fragColor;
319

32-
return col;
33-
}
34-
#else
35-
// A fallback in the case of derivatives lack
36-
mediump vec4 rgss_tex2D(highp vec2 uv)
37-
{
38-
return texture2D(texture_sampler, uv);
39-
}
40-
#endif
10+
uniform mediump sampler2D texture_sampler;
4111

4212
void main()
4313
{
44-
gl_FragColor = rgss_tex2D(var_texcoord0.xy) * var_face_color * var_face_color.a;
14+
out_fragColor = rgss_tex2D(texture_sampler, var_texcoord0.xy, 0.0) * var_face_color * var_face_color.a;
4515
}

sharp_sprite/rgss/fonts/font-fnt.material

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ name: "font"
22
tags: "gui"
33
vertex_program: "/builtins/fonts/font-fnt.vp"
44
fragment_program: "/sharp_sprite/rgss/fonts/font-fnt.fp"
5-
vertex_space: VERTEX_SPACE_WORLD
65
vertex_constants {
76
name: "view_proj"
87
type: CONSTANT_TYPE_VIEWPROJ
9-
value {
10-
x: 0.0
11-
y: 0.0
12-
z: 0.0
13-
w: 0.0
14-
}
158
}
169
samplers {
1710
name: "texture_sampler"
Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,17 @@
1-
#ifdef GL_OES_standard_derivatives
2-
#extension GL_OES_standard_derivatives : enable
3-
#endif
1+
#version 140
42

5-
varying highp vec2 var_texcoord0;
6-
varying lowp vec4 var_face_color;
7-
varying lowp vec4 var_outline_color;
3+
#include "/sharp_sprite/rgss/rgss.glsl"
84

9-
uniform mediump sampler2D texture_sampler;
10-
11-
// Derivative functions are available on:
12-
// - OpenGL (desktop).
13-
// - OpenGL ES 3.0, WebGL 2.0.
14-
// - OpenGL ES 2.0, WebGL 1.0, if the extension GL_OES_standard_derivatives is enabled.
15-
#if !defined(GL_ES) || __VERSION__ >= 300 || defined(GL_OES_standard_derivatives)
16-
// Rotated grid UV offsets
17-
const mediump vec2 rgss_uv_offsets = vec2(0.125, 0.375);
18-
19-
mediump vec4 rgss_tex2D(highp vec2 uv)
20-
{
21-
// Per pixel partial derivatives
22-
mediump vec2 dx = dFdx(uv);
23-
mediump vec2 dy = dFdy(uv);
24-
25-
// Supersampled using 2x2 rotated grid
26-
mediump vec4 col = texture2D(texture_sampler, vec2(uv + rgss_uv_offsets.x * dx + rgss_uv_offsets.y * dy));
27-
col += texture2D(texture_sampler, vec2(uv - rgss_uv_offsets.x * dx - rgss_uv_offsets.y * dy));
28-
col += texture2D(texture_sampler, vec2(uv + rgss_uv_offsets.y * dx - rgss_uv_offsets.x * dy));
29-
col += texture2D(texture_sampler, vec2(uv - rgss_uv_offsets.y * dx + rgss_uv_offsets.x * dy));
5+
in highp vec2 var_texcoord0;
6+
in mediump vec4 var_face_color;
7+
in mediump vec4 var_outline_color;
308

31-
col *= 0.25;
9+
out vec4 out_fragColor;
3210

33-
return col;
34-
}
35-
#else
36-
// A fallback in the case of derivatives lack
37-
mediump vec4 rgss_tex2D(highp vec2 uv)
38-
{
39-
return texture2D(texture_sampler, uv);
40-
}
41-
#endif
11+
uniform mediump sampler2D texture_sampler;
4212

4313
void main()
4414
{
45-
lowp vec2 t = rgss_tex2D(var_texcoord0.xy).xy;
46-
gl_FragColor = vec4(var_face_color.xyz, 1.0) * t.x * var_face_color.w + vec4(var_outline_color.xyz * t.y * var_outline_color.w, t.y * var_outline_color.w) * (1.0 - t.x);
15+
mediump vec2 t = rgss_tex2D(texture_sampler, var_texcoord0.xy, 0.0).xy;
16+
out_fragColor = vec4(var_face_color.xyz, 1.0) * t.x * var_face_color.w + vec4(var_outline_color.xyz * t.y * var_outline_color.w, t.y * var_outline_color.w) * (1.0 - t.x);
4717
}

sharp_sprite/rgss/fonts/font-singlelayer.material

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ name: "font"
22
tags: "gui"
33
vertex_program: "/builtins/fonts/font.vp"
44
fragment_program: "/sharp_sprite/rgss/fonts/font-singlelayer.fp"
5-
vertex_space: VERTEX_SPACE_WORLD
65
vertex_constants {
76
name: "view_proj"
87
type: CONSTANT_TYPE_VIEWPROJ
9-
value {
10-
x: 0.0
11-
y: 0.0
12-
z: 0.0
13-
w: 0.0
14-
}
158
}
169
samplers {
1710
name: "texture_sampler"

0 commit comments

Comments
 (0)