Created
April 22, 2015 05:19
-
-
Save prespondek/5305bca63de43599c10a to your computer and use it in GitHub Desktop.
Cocos2DX Vertex Blend and Light Map Shader
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
attribute vec4 a_position; | |
attribute vec2 a_texCoord; | |
attribute vec2 a_texCoord1; | |
attribute vec2 a_texCoord2; | |
attribute vec4 a_color; | |
varying vec4 v_color; | |
varying vec2 v_texture_coord; | |
varying vec2 v_texture_coord1; | |
varying vec2 v_texture_coord2; | |
void main(void) | |
{ | |
gl_Position = CC_MVPMatrix * a_position; | |
v_texture_coord = a_texCoord; | |
v_texture_coord.y = (1.0 - v_texture_coord.y); | |
v_texture_coord1 = a_texCoord1; | |
v_texture_coord1.y = (1.0 - v_texture_coord1.y); | |
v_texture_coord2 = a_texCoord2; | |
v_texture_coord2.y = (1.0 - v_texture_coord2.y); | |
v_color = a_color; | |
} |
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 | |
varying mediump vec2 v_texture_coord; | |
varying mediump vec2 v_texture_coord1; | |
varying mediump vec2 v_texture_coord2; | |
varying mediump vec4 v_color; | |
#else | |
varying vec4 v_color; | |
varying vec2 v_texture_coord; | |
varying vec2 v_texture_coord1; | |
varying vec2 v_texture_coord2; | |
#endif | |
uniform sampler2D lightmap; | |
uniform sampler2D blend; | |
void main(void) | |
{ | |
gl_FragColor = mix(texture2D(CC_Texture0, v_texture_coord),texture2D(blend, v_texture_coord1), v_color.r) * (texture2D(lightmap, v_texture_coord2) * 2.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment