Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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