diff options
| author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-09-08 23:25:51 +0900 | 
|---|---|---|
| committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-09-08 23:25:51 +0900 | 
| commit | 50c75c12597b230cec4d7a29559cde263025eeb2 (patch) | |
| tree | 9fa8afe8bcf6e1219186e5c567930831a3b5eab5 /pacc/glsl | |
| parent | 4cfeddd04dcbbf658195bd837d7daff7f08b37bc (diff) | |
pacc: initial
Diffstat (limited to 'pacc/glsl')
| -rw-r--r-- | pacc/glsl/Makefile | 40 | ||||
| -rw-r--r-- | pacc/glsl/blit.vert | 7 | ||||
| -rw-r--r-- | pacc/glsl/blit.vert.inc | 14 | ||||
| -rw-r--r-- | pacc/glsl/color.frag | 13 | ||||
| -rw-r--r-- | pacc/glsl/color.frag.inc | 30 | ||||
| -rw-r--r-- | pacc/glsl/color_trans.frag | 11 | ||||
| -rw-r--r-- | pacc/glsl/color_trans.frag.inc | 27 | ||||
| -rw-r--r-- | pacc/glsl/copy.frag | 9 | ||||
| -rw-r--r-- | pacc/glsl/copy.frag.inc | 25 | ||||
| -rw-r--r-- | pacc/glsl/dsheader | 5 | ||||
| -rw-r--r-- | pacc/glsl/dsheader.inc | 8 | ||||
| -rw-r--r-- | pacc/glsl/esheader | 2 | ||||
| -rw-r--r-- | pacc/glsl/esheader.inc | 5 | ||||
| -rw-r--r-- | pacc/glsl/fill.frag | 5 | ||||
| -rw-r--r-- | pacc/glsl/fill.frag.inc | 15 | ||||
| -rw-r--r-- | pacc/glsl/font.frag | 15 | ||||
| -rw-r--r-- | pacc/glsl/font.frag.inc | 37 | ||||
| -rw-r--r-- | pacc/glsl/key.frag | 12 | ||||
| -rw-r--r-- | pacc/glsl/key.frag.inc | 32 | 
19 files changed, 312 insertions, 0 deletions
| diff --git a/pacc/glsl/Makefile b/pacc/glsl/Makefile new file mode 100644 index 0000000..36aace4 --- /dev/null +++ b/pacc/glsl/Makefile @@ -0,0 +1,40 @@ +VSHADERS:=blit.vert +FSHADERS:=copy.frag color.frag color_trans.frag key.frag fill.frag font.frag +DSHEADER:=dsheader +ESHEADER:=esheader +INCS:=$(addsuffix .inc,$(VSHADERS) $(FSHADERS) $(DSHEADER) $(ESHEADER)) +SHADERS2:=$(addsuffix .ds.vert,$(basename $(VSHADERS))) +SHADERS2+=$(addsuffix .es.vert,$(basename $(VSHADERS))) +SHADERS2+=$(addsuffix .ds.frag,$(basename $(FSHADERS))) +SHADERS2+=$(addsuffix .es.frag,$(basename $(FSHADERS))) +VALS:=$(addsuffix .vald,$(SHADERS2)) +VALIDATOR:=glslangValidator +VFLAGS:= + +all:	$(INCS) + +val:	$(VALS) + +%.es.vert:	%.vert +	cat $(ESHEADER) $< > $@ + +%.es.frag:	%.frag +	cat $(ESHEADER) $< > $@ + +%.ds.vert:	%.vert +	cat $(DSHEADER) $< > $@ + +%.ds.frag:	%.frag +	cat $(DSHEADER) $< > $@ + +%.vald:	% +	$(VALIDATOR) $(VFLAGS) $< + +%.inc:	%.zt +	xxd -i $< | sed -e '/^unsigned char /c\static const uint8_t $(shell echo $(basename $<) | sed -e 's/\./_/g')[] = {' -e '/^unsigned int /c\\' > $@ + +%.zt:	% +	dd bs=1 count=1 if=/dev/zero | cat $< - > $@ + +clean: +	rm -f $(INCS) diff --git a/pacc/glsl/blit.vert b/pacc/glsl/blit.vert new file mode 100644 index 0000000..4232a8d --- /dev/null +++ b/pacc/glsl/blit.vert @@ -0,0 +1,7 @@ +attribute vec4 coord; +varying vec2 texcoord; +void main(void) { +  gl_Position = vec4(coord.xy, 0.0, 1.0); +  texcoord = coord.zw; +} + diff --git a/pacc/glsl/blit.vert.inc b/pacc/glsl/blit.vert.inc new file mode 100644 index 0000000..34691a9 --- /dev/null +++ b/pacc/glsl/blit.vert.inc @@ -0,0 +1,14 @@ +static const uint8_t blit_vert[] = { +  0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x76, 0x65, +  0x63, 0x34, 0x20, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x76, 0x61, +  0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x76, 0x6f, 0x69, +  0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x76, 0x6f, 0x69, 0x64, 0x29, +  0x20, 0x7b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, +  0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, +  0x63, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x78, 0x79, 0x2c, 0x20, 0x30, 0x2e, +  0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x3d, 0x20, 0x63, 0x6f, +  0x6f, 0x72, 0x64, 0x2e, 0x7a, 0x77, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00 +}; + diff --git a/pacc/glsl/color.frag b/pacc/glsl/color.frag new file mode 100644 index 0000000..d03bee5 --- /dev/null +++ b/pacc/glsl/color.frag @@ -0,0 +1,13 @@ +uniform sampler2D palette; +uniform sampler2D tex; +varying mediump vec2 texcoord; +uniform lowp float color; +void main(void) { +  lowp float index = texture2D(tex, texcoord).x; +  if (index > (0.5/255.0)) { +    index = color; +  } else { +    index = 0.5 / 256.0; +  } +  gl_FragColor = texture2D(palette, vec2(index, 0.0)); +} diff --git a/pacc/glsl/color.frag.inc b/pacc/glsl/color.frag.inc new file mode 100644 index 0000000..8ea77ef --- /dev/null +++ b/pacc/glsl/color.frag.inc @@ -0,0 +1,30 @@ +static const uint8_t color_frag[] = { +  0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, +  0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, +  0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, +  0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x74, 0x65, 0x78, +  0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x65, +  0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x75, 0x6e, 0x69, +  0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, +  0x6f, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, +  0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x76, 0x6f, 0x69, +  0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, +  0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, +  0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, +  0x74, 0x65, 0x78, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, +  0x64, 0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, +  0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3e, 0x20, 0x28, 0x30, 0x2e, 0x35, +  0x2f, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, +  0x20, 0x20, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20, 0x63, +  0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, +  0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x64, +  0x65, 0x78, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x35, 0x20, 0x2f, 0x20, 0x32, +  0x35, 0x36, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, +  0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, +  0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, +  0x28, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x2c, 0x20, 0x76, 0x65, +  0x63, 0x32, 0x28, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x30, 0x2e, +  0x30, 0x29, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x00 +}; + diff --git a/pacc/glsl/color_trans.frag b/pacc/glsl/color_trans.frag new file mode 100644 index 0000000..ef742a4 --- /dev/null +++ b/pacc/glsl/color_trans.frag @@ -0,0 +1,11 @@ +uniform sampler2D palette; +uniform sampler2D tex; +varying mediump vec2 texcoord; +uniform lowp float color; +void main(void) { +  lowp float index = texture2D(tex, texcoord).x; +  if (index < (0.5/255.0)) { +    discard; +  } +  gl_FragColor = texture2D(palette, vec2(color, 0.0)); +} diff --git a/pacc/glsl/color_trans.frag.inc b/pacc/glsl/color_trans.frag.inc new file mode 100644 index 0000000..f49404c --- /dev/null +++ b/pacc/glsl/color_trans.frag.inc @@ -0,0 +1,27 @@ +static const uint8_t color_trans_frag[] = { +  0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, +  0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, +  0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, +  0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x74, 0x65, 0x78, +  0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x65, +  0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x75, 0x6e, 0x69, +  0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, +  0x6f, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, +  0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x76, 0x6f, 0x69, +  0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, +  0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, +  0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, +  0x74, 0x65, 0x78, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, +  0x64, 0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, +  0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3c, 0x20, 0x28, 0x30, 0x2e, 0x35, +  0x2f, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, +  0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, 0x72, 0x64, 0x3b, 0x0a, +  0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, +  0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, +  0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, 0x70, 0x61, 0x6c, 0x65, 0x74, +  0x74, 0x65, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x63, 0x6f, 0x6c, +  0x6f, 0x72, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x7d, +  0x0a, 0x00 +}; + diff --git a/pacc/glsl/copy.frag b/pacc/glsl/copy.frag new file mode 100644 index 0000000..a77ad91 --- /dev/null +++ b/pacc/glsl/copy.frag @@ -0,0 +1,9 @@ +uniform sampler2D palette; +uniform sampler2D tex; +varying mediump vec2 texcoord; +void main(void) { +  lowp float index = texture2D(tex, texcoord).x; +  lowp float color = (index * 255.0 + 0.5) / 256.0; +  gl_FragColor = texture2D(palette, vec2(color, 0.0)); +} + diff --git a/pacc/glsl/copy.frag.inc b/pacc/glsl/copy.frag.inc new file mode 100644 index 0000000..fa3f388 --- /dev/null +++ b/pacc/glsl/copy.frag.inc @@ -0,0 +1,25 @@ +static const uint8_t copy_frag[] = { +  0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, +  0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, +  0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, +  0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x74, 0x65, 0x78, +  0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x65, +  0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x76, 0x6f, 0x69, +  0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x76, 0x6f, 0x69, 0x64, 0x29, +  0x20, 0x7b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, +  0x6f, 0x61, 0x74, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20, +  0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, 0x74, 0x65, +  0x78, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x29, +  0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, +  0x6c, 0x6f, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, +  0x20, 0x28, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x35, +  0x35, 0x2e, 0x30, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2f, +  0x20, 0x32, 0x35, 0x36, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, +  0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, +  0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, 0x70, +  0x61, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, +  0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, +  0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00 +}; + diff --git a/pacc/glsl/dsheader b/pacc/glsl/dsheader new file mode 100644 index 0000000..13e65b7 --- /dev/null +++ b/pacc/glsl/dsheader @@ -0,0 +1,5 @@ +#version 110 +#define lowp +#define mediump +#define highp + diff --git a/pacc/glsl/dsheader.inc b/pacc/glsl/dsheader.inc new file mode 100644 index 0000000..b742cec --- /dev/null +++ b/pacc/glsl/dsheader.inc @@ -0,0 +1,8 @@ +static const uint8_t dsheader[] = { +  0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x31, 0x30, +  0x0a, 0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x6c, 0x6f, 0x77, +  0x70, 0x0a, 0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x6d, 0x65, +  0x64, 0x69, 0x75, 0x6d, 0x70, 0x0a, 0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, +  0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x0a, 0x0a, 0x00 +}; + diff --git a/pacc/glsl/esheader b/pacc/glsl/esheader new file mode 100644 index 0000000..43b26bc --- /dev/null +++ b/pacc/glsl/esheader @@ -0,0 +1,2 @@ +#version 100 + diff --git a/pacc/glsl/esheader.inc b/pacc/glsl/esheader.inc new file mode 100644 index 0000000..3ca61f1 --- /dev/null +++ b/pacc/glsl/esheader.inc @@ -0,0 +1,5 @@ +static const uint8_t esheader[] = { +  0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x30, 0x30, +  0x0a, 0x0a, 0x00 +}; + diff --git a/pacc/glsl/fill.frag b/pacc/glsl/fill.frag new file mode 100644 index 0000000..010b5dc --- /dev/null +++ b/pacc/glsl/fill.frag @@ -0,0 +1,5 @@ +uniform sampler2D palette; +varying mediump vec2 texcoord; +void main(void) { +  gl_FragColor = texture2D(palette, vec2(texcoord.x, 0.0)); +} diff --git a/pacc/glsl/fill.frag.inc b/pacc/glsl/fill.frag.inc new file mode 100644 index 0000000..8065199 --- /dev/null +++ b/pacc/glsl/fill.frag.inc @@ -0,0 +1,15 @@ +static const uint8_t fill_frag[] = { +  0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, +  0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, +  0x65, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x6d, +  0x65, 0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, +  0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x76, 0x6f, +  0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x76, 0x6f, 0x69, 0x64, +  0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, +  0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, +  0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, 0x70, 0x61, 0x6c, 0x65, 0x74, +  0x74, 0x65, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x74, 0x65, 0x78, +  0x63, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x78, 0x2c, 0x20, 0x30, 0x2e, 0x30, +  0x29, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x00 +}; + diff --git a/pacc/glsl/font.frag b/pacc/glsl/font.frag new file mode 100644 index 0000000..8beb0a7 --- /dev/null +++ b/pacc/glsl/font.frag @@ -0,0 +1,15 @@ +uniform sampler2D palette; +uniform sampler2D tex; +varying mediump vec2 texcoord; +uniform lowp float bg; +uniform lowp float color; +void main(void) { +  gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0); +  lowp float pixel = texture2D(tex, texcoord).x; +  lowp float index = color; +  if (pixel < 0.5) { +    if (bg < 0.5) discard; +    index = 0.5 / 256.0; +  } +  gl_FragColor = texture2D(palette, vec2(index, 0.0)); +} diff --git a/pacc/glsl/font.frag.inc b/pacc/glsl/font.frag.inc new file mode 100644 index 0000000..27d143d --- /dev/null +++ b/pacc/glsl/font.frag.inc @@ -0,0 +1,37 @@ +static const uint8_t font_frag[] = { +  0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, +  0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, +  0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, +  0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x74, 0x65, 0x78, +  0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x65, +  0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x75, 0x6e, 0x69, +  0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, +  0x6f, 0x61, 0x74, 0x20, 0x62, 0x67, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, +  0x6f, 0x72, 0x6d, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, 0x6f, +  0x61, 0x74, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, 0x6f, +  0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x76, 0x6f, 0x69, 0x64, +  0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, +  0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, +  0x34, 0x28, 0x31, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, +  0x31, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, +  0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, +  0x70, 0x69, 0x78, 0x65, 0x6c, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, +  0x75, 0x72, 0x65, 0x32, 0x44, 0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x29, 0x2e, 0x78, 0x3b, 0x0a, +  0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, +  0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6c, +  0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x70, 0x69, +  0x78, 0x65, 0x6c, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x7b, +  0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x62, 0x67, 0x20, +  0x3c, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, +  0x72, 0x64, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x64, 0x65, +  0x78, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x35, 0x20, 0x2f, 0x20, 0x32, 0x35, +  0x36, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x67, +  0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, +  0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, +  0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x2c, 0x20, 0x76, 0x65, 0x63, +  0x32, 0x28, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x30, 0x2e, 0x30, +  0x29, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x00 +}; + diff --git a/pacc/glsl/key.frag b/pacc/glsl/key.frag new file mode 100644 index 0000000..d6bf7e1 --- /dev/null +++ b/pacc/glsl/key.frag @@ -0,0 +1,12 @@ +uniform sampler2D palette; +uniform sampler2D tex; +varying mediump vec2 texcoord; +uniform lowp float key; +uniform lowp float color; +void main(void) { +  lowp float index = texture2D(tex, texcoord).x; +  if (index < (key + (0.5/255.0)) || (key + (1.5/255.0)) < index) { +    discard; +  } +  gl_FragColor = texture2D(palette, vec2(color, 0.0)); +} diff --git a/pacc/glsl/key.frag.inc b/pacc/glsl/key.frag.inc new file mode 100644 index 0000000..4a4a6c1 --- /dev/null +++ b/pacc/glsl/key.frag.inc @@ -0,0 +1,32 @@ +static const uint8_t key_frag[] = { +  0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, +  0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x74, +  0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, +  0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x74, 0x65, 0x78, +  0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x65, +  0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, +  0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x75, 0x6e, 0x69, +  0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, +  0x6f, 0x61, 0x74, 0x20, 0x6b, 0x65, 0x79, 0x3b, 0x0a, 0x75, 0x6e, 0x69, +  0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x66, 0x6c, +  0x6f, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, +  0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x76, 0x6f, 0x69, +  0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, +  0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, +  0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, +  0x74, 0x65, 0x78, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, +  0x64, 0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, +  0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3c, 0x20, 0x28, 0x6b, 0x65, 0x79, +  0x20, 0x2b, 0x20, 0x28, 0x30, 0x2e, 0x35, 0x2f, 0x32, 0x35, 0x35, 0x2e, +  0x30, 0x29, 0x29, 0x20, 0x7c, 0x7c, 0x20, 0x28, 0x6b, 0x65, 0x79, 0x20, +  0x2b, 0x20, 0x28, 0x31, 0x2e, 0x35, 0x2f, 0x32, 0x35, 0x35, 0x2e, 0x30, +  0x29, 0x29, 0x20, 0x3c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x29, 0x20, +  0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, 0x72, +  0x64, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, +  0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, +  0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x28, 0x70, 0x61, +  0x6c, 0x65, 0x74, 0x74, 0x65, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, +  0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x29, +  0x3b, 0x0a, 0x7d, 0x0a, 0x00 +}; + | 
