Browse Source

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.
pull/3552/head
Jussi Viitala 1 year ago
committed by GitHub
parent
commit
25c6c12150
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 108 additions and 5 deletions
  1. +4
    -4
      examples/Makefile.Web
  2. +22
    -0
      examples/shaders/resources/shaders/glsl100/lightmap.fs
  3. +31
    -0
      examples/shaders/resources/shaders/glsl100/lightmap.vs
  4. +20
    -0
      examples/shaders/resources/shaders/glsl120/lightmap.fs
  5. +31
    -0
      examples/shaders/resources/shaders/glsl120/lightmap.vs
  6. +0
    -1
      examples/shaders/shaders_lightmap.c

+ 4
- 4
examples/Makefile.Web View File

@ -968,10 +968,10 @@ shaders/shaders_julia_set: shaders/shaders_julia_set.c
shaders/shaders_lightmap: shaders/shaders_lightmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s FORCE_FILESYSTEM=1 \
--preload-file shaders/resources/shaders/glsl330/lightmap.vs \
--preload-file shaders/resources/shaders/glsl330/lightmap.fs \
--preload-file shaders/resources/cubicmap_atlas.png \
--preload-file shaders/resources/spark_flame.png
--preload-file shaders/resources/shaders/glsl100/lightmap.vs@resources/shaders/glsl100/lightmap.vs \
--preload-file shaders/resources/shaders/glsl100/lightmap.fs@resources/shaders/glsl100/lightmap.fs \
--preload-file shaders/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png \
--preload-file shaders/resources/spark_flame.png@resources/spark_flame.png
shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \

+ 22
- 0
examples/shaders/resources/shaders/glsl100/lightmap.fs View File

@ -0,0 +1,22 @@
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec2 fragTexCoord2;
varying vec3 fragPosition;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform sampler2D texture1;
void main()
{
// Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord);
vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
gl_FragColor = texelColor * texelColor2;
}

+ 31
- 0
examples/shaders/resources/shaders/glsl100/lightmap.vs View File

@ -0,0 +1,31 @@
#version 100
// Input vertex attributes
attribute vec3 vertexPosition;
attribute vec2 vertexTexCoord;
attribute vec2 vertexTexCoord2;
attribute vec4 vertexColor;
// Input uniform values
uniform mat4 mvp;
uniform mat4 matModel;
// Output vertex attributes (to fragment shader)
varying vec3 fragPosition;
varying vec2 fragTexCoord;
varying vec2 fragTexCoord2;
varying vec4 fragColor;
// NOTE: Add here your custom variables
void main()
{
// Send vertex attributes to fragment shader
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
fragTexCoord = vertexTexCoord;
fragTexCoord2 = vertexTexCoord2;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

+ 20
- 0
examples/shaders/resources/shaders/glsl120/lightmap.fs View File

@ -0,0 +1,20 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec2 fragTexCoord2;
varying vec3 fragPosition;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform sampler2D texture1;
void main()
{
// Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord);
vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
gl_FragColor = texelColor * texelColor2;
}

+ 31
- 0
examples/shaders/resources/shaders/glsl120/lightmap.vs View File

@ -0,0 +1,31 @@
#version 120
// Input vertex attributes
attribute vec3 vertexPosition;
attribute vec2 vertexTexCoord;
attribute vec2 vertexTexCoord2;
attribute vec4 vertexColor;
// Input uniform values
uniform mat4 mvp;
uniform mat4 matModel;
// Output vertex attributes (to fragment shader)
varying vec3 fragPosition;
varying vec2 fragTexCoord;
varying vec2 fragTexCoord2;
varying vec4 fragColor;
// NOTE: Add here your custom variables
void main()
{
// Send vertex attributes to fragment shader
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
fragTexCoord = vertexTexCoord;
fragTexCoord2 = vertexTexCoord2;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

+ 0
- 1
examples/shaders/shaders_lightmap.c View File

@ -170,4 +170,3 @@ int main(void)
return 0;
}

Loading…
Cancel
Save