Created
February 10, 2018 17:37
-
-
Save JettMonstersGoBoom/89901f6cfdbf3ea215609eefb08e5da0 to your computer and use it in GitHub Desktop.
4 bit source texture shader . for OpenGL
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
#version 130 | |
in vec2 out_uv; | |
out vec4 out_0; | |
uniform sampler2D vramimage; | |
uniform sampler1D vrampalette; | |
void main(void) | |
{ | |
vec2 uv = out_uv; | |
uv.x *=0.5; // force read twice. | |
vec4 tex = texture(vramimage, uv); // grab texel | |
int index = int(tex.r*255.0); // convert the index to 0x00-0xff range | |
int U = int(uv.x * 1024.0); // our texture is 512 so we need to double it | |
if ((U&1)==1) // ODD pixel | |
index = index & 0xf; | |
else // EVEN pixel | |
index = index>>4 & 0xf; | |
out_0 = texture(vrampalette,index/255.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment