Skip to content

Commit

Permalink
#11 modified default shader
Browse files Browse the repository at this point in the history
  • Loading branch information
KOTerra committed Jun 30, 2023
1 parent 2a8cd18 commit 4f3e8c0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
21 changes: 11 additions & 10 deletions StrafeOverdead/assets/shaders/default.frag
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);
}
24 changes: 18 additions & 6 deletions StrafeOverdead/assets/shaders/default.vert
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;
}
2 changes: 2 additions & 0 deletions StrafeOverdead/assets/shaders/links.txt
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

0 comments on commit 4f3e8c0

Please sign in to comment.