Created
May 18, 2020 21:54
-
-
Save tyler6699/9d87a71e394f0c5b451872d7b818f1b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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