-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
31 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
#ifdef GL_ES | ||
precision mediump float; | ||
#endif | ||
precision mediump float; | ||
#endif | ||
|
||
// varying input variables from our vertex shader | ||
varying vec4 v_color; | ||
varying vec2 v_texCoords; | ||
uniform sampler2D u_texture; | ||
|
||
void main() { | ||
vec2 pixelSize = vec2(1.0 / textureSize(u_texture, 0)); | ||
vec2 uv = v_texCoords - mod(v_texCoords, pixelSize) + 0.5 * pixelSize; | ||
|
||
gl_FragColor = texture2D(u_texture, uv); | ||
} | ||
|
||
// a special uniform for textures | ||
uniform sampler2D u_texture; | ||
|
||
void main() | ||
{ | ||
// set the colour for this fragment|pixel | ||
gl_FragColor = v_color * texture2D(u_texture, v_texCoords); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
attribute vec4 a_position; | ||
// Data sent from libgdx SpriteBatch | ||
// (Read Only and specific to this vertex|pixel) | ||
attribute vec4 a_position; | ||
attribute vec4 a_color; | ||
attribute vec2 a_texCoord0; | ||
|
||
uniform mat4 u_projTrans; | ||
// Data sent from libgdx SpriteBatch | ||
//(Read Only and the same for all vertex|pixel) | ||
uniform mat4 u_projTrans; | ||
|
||
// Variable Data for storing data to pass to fragment Shader | ||
varying vec4 v_color; | ||
varying vec2 v_texCoords; | ||
|
||
void main() { | ||
gl_Position = u_projTrans * a_position; | ||
v_texCoords = a_texCoord0; | ||
} | ||
void main() | ||
{ | ||
// set our varying variables for use in frag shader | ||
v_color = vec4(1, 1, 1, 1); | ||
v_texCoords = a_texCoord0; | ||
|
||
// sgl_Position is a special output variable from | ||
// openGL that must be set in the vertex shader | ||
gl_Position = u_projTrans * a_position; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
https://glslsandbox.com/e#104141.3 | ||
https://glslsandbox.com/e#104142.3 |