Skip to content

Commit 25c6c12

Browse files
authored
Added glsl 100 and 120 shaders to lightmap example. (#3543)
* Added glsl 100 and 120 shaders to lightmap example. * Fixed lightmap example resource loading on web.
1 parent f607cac commit 25c6c12

File tree

6 files changed

+108
-5
lines changed

6 files changed

+108
-5
lines changed

examples/Makefile.Web

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,10 @@ shaders/shaders_julia_set: shaders/shaders_julia_set.c
968968

969969
shaders/shaders_lightmap: shaders/shaders_lightmap.c
970970
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s FORCE_FILESYSTEM=1 \
971-
--preload-file shaders/resources/shaders/glsl330/lightmap.vs \
972-
--preload-file shaders/resources/shaders/glsl330/lightmap.fs \
973-
--preload-file shaders/resources/cubicmap_atlas.png \
974-
--preload-file shaders/resources/spark_flame.png
971+
--preload-file shaders/resources/shaders/glsl100/lightmap.vs@resources/shaders/glsl100/lightmap.vs \
972+
--preload-file shaders/resources/shaders/glsl100/lightmap.fs@resources/shaders/glsl100/lightmap.fs \
973+
--preload-file shaders/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png \
974+
--preload-file shaders/resources/spark_flame.png@resources/spark_flame.png
975975

976976
shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
977977
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#version 100
2+
3+
precision mediump float;
4+
5+
// Input vertex attributes (from vertex shader)
6+
varying vec2 fragTexCoord;
7+
varying vec2 fragTexCoord2;
8+
varying vec3 fragPosition;
9+
varying vec4 fragColor;
10+
11+
// Input uniform values
12+
uniform sampler2D texture0;
13+
uniform sampler2D texture1;
14+
15+
void main()
16+
{
17+
// Texel color fetching from texture sampler
18+
vec4 texelColor = texture2D(texture0, fragTexCoord);
19+
vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
20+
21+
gl_FragColor = texelColor * texelColor2;
22+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#version 100
2+
3+
// Input vertex attributes
4+
attribute vec3 vertexPosition;
5+
attribute vec2 vertexTexCoord;
6+
attribute vec2 vertexTexCoord2;
7+
attribute vec4 vertexColor;
8+
9+
// Input uniform values
10+
uniform mat4 mvp;
11+
uniform mat4 matModel;
12+
13+
// Output vertex attributes (to fragment shader)
14+
varying vec3 fragPosition;
15+
varying vec2 fragTexCoord;
16+
varying vec2 fragTexCoord2;
17+
varying vec4 fragColor;
18+
19+
// NOTE: Add here your custom variables
20+
21+
void main()
22+
{
23+
// Send vertex attributes to fragment shader
24+
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
25+
fragTexCoord = vertexTexCoord;
26+
fragTexCoord2 = vertexTexCoord2;
27+
fragColor = vertexColor;
28+
29+
// Calculate final vertex position
30+
gl_Position = mvp*vec4(vertexPosition, 1.0);
31+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#version 120
2+
3+
// Input vertex attributes (from vertex shader)
4+
varying vec2 fragTexCoord;
5+
varying vec2 fragTexCoord2;
6+
varying vec3 fragPosition;
7+
varying vec4 fragColor;
8+
9+
// Input uniform values
10+
uniform sampler2D texture0;
11+
uniform sampler2D texture1;
12+
13+
void main()
14+
{
15+
// Texel color fetching from texture sampler
16+
vec4 texelColor = texture2D(texture0, fragTexCoord);
17+
vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
18+
19+
gl_FragColor = texelColor * texelColor2;
20+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#version 120
2+
3+
// Input vertex attributes
4+
attribute vec3 vertexPosition;
5+
attribute vec2 vertexTexCoord;
6+
attribute vec2 vertexTexCoord2;
7+
attribute vec4 vertexColor;
8+
9+
// Input uniform values
10+
uniform mat4 mvp;
11+
uniform mat4 matModel;
12+
13+
// Output vertex attributes (to fragment shader)
14+
varying vec3 fragPosition;
15+
varying vec2 fragTexCoord;
16+
varying vec2 fragTexCoord2;
17+
varying vec4 fragColor;
18+
19+
// NOTE: Add here your custom variables
20+
21+
void main()
22+
{
23+
// Send vertex attributes to fragment shader
24+
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
25+
fragTexCoord = vertexTexCoord;
26+
fragTexCoord2 = vertexTexCoord2;
27+
fragColor = vertexColor;
28+
29+
// Calculate final vertex position
30+
gl_Position = mvp*vec4(vertexPosition, 1.0);
31+
}

examples/shaders/shaders_lightmap.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,3 @@ int main(void)
170170

171171
return 0;
172172
}
173-

0 commit comments

Comments
 (0)