S
Shadowblitz16
Guest
can someone tell me how to draw a pixel array with a shader?
this is what I have been trying to do.
but it gives me this error
at this point I'm not even sure if it will draw pixels in world space instead of surface space
this is what I have been trying to do.
Code:
/// shd_draw
uniform int tilesize;
uniform int tileset[4];
uniform int palette[2];
uniform int tile;
uniform int dx;
uniform int dy;
int RGBA;
vec4 drawColor;
vec2 drawPos;
void main()
{
// yo and xo stand for y and x offset
for (int yo=0; yo<tilesize; yo++)
for (int xo=0; xo<tilesize; xo++)
{
RGBA = palette[tileset[tile][xo+yo*tilesize]]; //Might want to make consider alpha in front
//Convert RRGGBBAA to vec4 of floats ranging from 0.0 to 1.0
drawColor = vec4(float((RGBA >> 32) & 0xFF) / 255.0, float((RGBA >> 16) & 0xFF) / 255.0, float((RGBA >> 8) & 0xFF) / 255.0, float((RGBA >> 0) & 0xFF) / 255.0);
//Convert pos and loop offset to vec2 of floats ranging from 0.0 to 1.0
drawPos = vec2(float((dx+xo) / tilesize), float((dy+yo) / tilesize)
//Set pos and color
gl_Position = drawPos;
gl_FragColor = drawColor;
}
}
Code:
Fragment Shader: shd_draw at line 23 : 'expression'
Fragment Shader: shd_draw at line 26 : ''