Add simple DMG shader
This commit is contained in:
parent
d95ad1ca54
commit
de43ac4cfb
@ -29,6 +29,7 @@
|
|||||||
@"Bilinear",
|
@"Bilinear",
|
||||||
@"SmoothBilinear",
|
@"SmoothBilinear",
|
||||||
@"LCD",
|
@"LCD",
|
||||||
|
@"DMG",
|
||||||
@"Scale2x",
|
@"Scale2x",
|
||||||
@"Scale4x",
|
@"Scale4x",
|
||||||
@"AAScale2x",
|
@"AAScale2x",
|
||||||
|
@ -357,6 +357,7 @@ struct shader_name {
|
|||||||
{"Bilinear", "Bilinear"},
|
{"Bilinear", "Bilinear"},
|
||||||
{"SmoothBilinear", "Smooth Bilinear"},
|
{"SmoothBilinear", "Smooth Bilinear"},
|
||||||
{"LCD", "LCD Display"},
|
{"LCD", "LCD Display"},
|
||||||
|
{"DMG", "DMG Display"},
|
||||||
{"Scale2x", "Scale2x"},
|
{"Scale2x", "Scale2x"},
|
||||||
{"Scale4x", "Scale4x"},
|
{"Scale4x", "Scale4x"},
|
||||||
{"AAScale2x", "Anti-aliased Scale2x"},
|
{"AAScale2x", "Anti-aliased Scale2x"},
|
||||||
|
38
Shaders/DMG.fsh
Normal file
38
Shaders/DMG.fsh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
vec4 pixelize(vec4 image, vec2 scaleVec, vec2 texCoord) {
|
||||||
|
float scale = max(scaleVec.x, scaleVec.y);
|
||||||
|
float x = fract(texCoord.x * 160.0) * scale;
|
||||||
|
float y = fract(texCoord.y * 144.0) * scale;
|
||||||
|
|
||||||
|
float border = 1.0;
|
||||||
|
|
||||||
|
if (scale > 5.0) {
|
||||||
|
border = 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < border || x > scale - border || y < border || y > scale - border) {
|
||||||
|
return vec4(.95, .95, .95, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 scale(sampler2D image) {
|
||||||
|
vec2 displayScale = uResolution / vec2(160.0, 144.0);
|
||||||
|
vec2 texCoord = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y) / uResolution;
|
||||||
|
vec4 sampled = texture(image, texCoord);
|
||||||
|
|
||||||
|
if (displayScale.x < 3.0 || displayScale.y < 3.0) {
|
||||||
|
return sampled;
|
||||||
|
}
|
||||||
|
|
||||||
|
float mixValue = 1.0;
|
||||||
|
|
||||||
|
if (displayScale.x >= 5.0 && displayScale.y >= 5.0) {
|
||||||
|
mixValue = 0.5;
|
||||||
|
}
|
||||||
|
else if (displayScale.x >= 3.0 && displayScale.y >= 3.0) {
|
||||||
|
mixValue = 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mix(pixelize(sampled, displayScale, texCoord), sampled, mixValue);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user