Created
September 1, 2020 05:47
-
-
Save DragoniteSpam/9ab79685b93ddce9e5bc74da7b194a3a to your computer and use it in GitHub Desktop.
GLSL ES; use with matrix_set and any of the draw_sprite functions in GameMaker. Fragment shader is just the passthrough shader.
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
attribute vec3 in_Position; // (x,y,z) | |
//attribute vec3 in_Normal; // (x,y,z) unused in this shader. | |
attribute vec4 in_Colour; // (r,g,b,a) | |
attribute vec2 in_TextureCoord; // (u,v) | |
varying vec2 v_vTexcoord; | |
varying vec4 v_vColour; | |
void main() { | |
vec4 object_space_pos = vec4(in_Position, 1.); | |
mat4 worldView = gm_Matrices[MATRIX_WORLD_VIEW]; | |
worldView[0][0] = 1.; | |
worldView[0][1] = 0.; | |
worldView[0][2] = 0.; | |
worldView[1][0] = 0.; | |
worldView[1][1] = -1.; | |
worldView[1][2] = 0.; | |
// comment out this bit for cylindrical billboarding | |
// (you may wish to have a shader uniform to determine this) | |
/* | |
worldView[1][0] = worldView[2][0]; | |
worldView[1][1] = worldView[2][1]; | |
worldView[1][2] = worldView[2][2]; | |
*/ | |
worldView[2][0] = 0.; | |
worldView[2][1] = 0.; | |
worldView[2][2] = 1.; | |
gl_Position = gm_Matrices[MATRIX_PROJECTION] * (worldView * object_space_pos); | |
v_vColour = in_Colour; | |
v_vTexcoord = in_TextureCoord; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment