Skip to content

Commit 37cf9c3

Browse files
authored
Convert noise shader to version 1.4.0 (#80)
1 parent 49bcd60 commit 37cf9c3

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

material/noise/example/noise.fp

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
varying mediump vec2 var_texcoord0;
2-
uniform lowp vec4 time;
1+
#version 140
2+
3+
in mediump vec2 var_texcoord0;
4+
5+
uniform fs_uniforms
6+
{
7+
mediump vec4 time;
8+
};
9+
10+
out mediump vec4 out_fragColor;
311

412
// noise shader from https://www.shadertoy.com/view/XXBcDz
513

@@ -42,6 +50,6 @@ float fbm( vec2 p )
4250
void main()
4351
{
4452
float n = fbm(var_texcoord0.xy);
45-
gl_FragColor = vec4(n, n, n, 1.0);
53+
out_fragColor = vec4(n, n, n, 1.0);
4654
}
4755

material/noise/example/noise.material

-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,10 @@ vertex_constants {
77
name: "mtx_worldview"
88
type: CONSTANT_TYPE_WORLDVIEW
99
}
10-
vertex_constants {
11-
name: "mtx_view"
12-
type: CONSTANT_TYPE_VIEW
13-
}
1410
vertex_constants {
1511
name: "mtx_proj"
1612
type: CONSTANT_TYPE_PROJECTION
1713
}
18-
vertex_constants {
19-
name: "mtx_normal"
20-
type: CONSTANT_TYPE_NORMAL
21-
}
2214
fragment_constants {
2315
name: "time"
2416
type: CONSTANT_TYPE_USER

material/noise/example/noise.vp

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1+
#version 140
12

2-
// Positions can be world or local space, since world and normal
3-
// matrices are identity for world vertex space materials.
4-
// If world vertex space is selected, you can remove the
5-
// normal matrix multiplication for optimal performance.
3+
in highp vec4 position;
4+
in mediump vec2 texcoord0;
5+
in mediump vec3 normal;
66

7-
attribute highp vec4 position;
8-
attribute mediump vec2 texcoord0;
9-
attribute mediump vec3 normal;
10-
11-
uniform mediump mat4 mtx_worldview;
12-
uniform mediump mat4 mtx_view;
13-
uniform mediump mat4 mtx_proj;
14-
uniform mediump mat4 mtx_normal;
7+
uniform vp_uniforms
8+
{
9+
mediump mat4 mtx_worldview;
10+
mediump mat4 mtx_proj;
11+
};
1512

16-
varying highp vec4 var_position;
17-
varying mediump vec3 var_normal;
18-
varying mediump vec2 var_texcoord0;
13+
out highp vec4 var_position;
14+
out mediump vec2 var_texcoord0;
1915

2016
void main()
2117
{
22-
vec4 p = mtx_worldview * vec4(position.xyz, 1.0);
18+
highp vec4 p = mtx_worldview * vec4(position.xyz, 1.0);
2319
var_texcoord0 = texcoord0;
20+
2421
gl_Position = mtx_proj * p;
2522
}
2623

material/noise/game.project

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
title = Defold-examples
2+
title = material_noise
33
version = 0.1
44

55
[bootstrap]

0 commit comments

Comments
 (0)