Skip to content

Instantly share code, notes, and snippets.

@tyler6699
Created May 18, 2020 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyler6699/9d87a71e394f0c5b451872d7b818f1b9 to your computer and use it in GitHub Desktop.
Save tyler6699/9d87a71e394f0c5b451872d7b818f1b9 to your computer and use it in GitHub Desktop.
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
//texture samplers
uniform sampler2D u_texture; //diffuse map
//additional parameters for the shader
uniform LOWP vec4 ambientColor;
void main() {
vec4 diffuseColor = texture2D(u_texture, vTexCoord);
vec3 ambient = ambientColor.rgb * ambientColor.a;
vec3 final = vColor * diffuseColor.rgb * ambient;
gl_FragColor = vec4(final, diffuseColor.a);
}
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
//our texture samplers
uniform sampler2D u_texture; //diffuse map
uniform sampler2D u_lightmap; //light map
//resolution of screen
uniform vec2 resolution;
void main() {
vec2 lighCoord = (gl_FragCoord.xy / resolution.xy);
vec4 Light = texture2D(u_lightmap, lighCoord);
gl_FragColor = vColor * Light;
}
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
//texture samplers
uniform sampler2D u_texture; //diffuse map
uniform sampler2D u_lightmap; //light map
//additional parameters for the shader
uniform vec2 resolution; //resolution of screen
uniform LOWP vec4 ambientColor; //ambient RGB, alpha channel is intensity
void main() {
vec4 diffuseColor = texture2D(u_texture, vTexCoord);
vec2 lighCoord = (gl_FragCoord.xy / resolution.xy);
vec4 light = texture2D(u_lightmap, lighCoord);
vec3 ambient = ambientColor.rgb * ambientColor.a;
vec3 intensity = ambient + light.rgb;
vec3 finalColor = diffuseColor.rgb * intensity;
gl_FragColor = vColor * vec4(finalColor, diffuseColor.a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment