(AANN) Add parameters

This commit is contained in:
Monroe88 2016-08-14 14:12:16 -05:00
parent e410ff0886
commit c9bc79e10a

View file

@ -1,5 +1,12 @@
#version 450
layout(push_constant) uniform Push
{
float NOGAMMA;
float MASKING;
float BILINEAR;
} param;
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
@ -13,14 +20,14 @@ layout(std140, set = 0, binding = 0) uniform UBO
// Licensed MIT
// set to true to interpolate in sRGB instead of a pseudo-perceptual colorspace
#define NOGAMMA false
#pragma parameter NOGAMMA "Interpolate in sRGB" 0.0 0.0 1.0 1.0
// set to true to compensate for 8px overscan masking
// Note: overscan compensation slightly alters (extremifies) the pixel aspect ratio of the game if said pixel aspect ratio is not exactly 1:1
#define MASKING false
#pragma parameter MASKING "8px Overscan Masking" 0.0 0.0 1.0 1.0
// Do bilinear filtering instead of anti-aliased nearest neighbor filtering (used for debugging color)
#define BILINEAR false
#pragma parameter BILINEAR "Force Bilinear Filtering" 0.0 0.0 1.0 1.0
// http://i.imgur.com/kzwZkVf.png
@ -69,7 +76,7 @@ vec3 linear2srgb(vec3 linear) {
#define BS 0.0722
vec3 rgb2vry(vec3 rgb) {
if (NOGAMMA)
if (param.NOGAMMA == 1.0)
return rgb;
// https://en.wikipedia.org/wiki/Opponent_process
@ -87,7 +94,7 @@ vec3 rgb2vry(vec3 rgb) {
return vry;
}
vec3 vry2rgb(vec3 vry) {
if (NOGAMMA)
if (param.NOGAMMA == 1.0)
return vry;
// Magic.
@ -103,7 +110,7 @@ vec3 vry2rgb(vec3 vry) {
}
vec3 vry_interp(vec3 first, vec3 second, float frac) {
if (NOGAMMA)
if (param.NOGAMMA == 1.0)
return first*NOT(frac) + second*YES(frac);
// Because the chroma values were generated on linear light, but the luma must be interpolated in perceptual gamma (3)
@ -124,7 +131,7 @@ vec3 vry_interp(vec3 first, vec3 second, float frac) {
}
vec3 percent(float ssize, float tsize, float coord) {
if (BILINEAR)
if (param.BILINEAR == 1.0)
tsize = ssize;
float minfull = (coord*tsize - 0.5)/tsize*ssize;
@ -146,7 +153,7 @@ vec3 percent(float ssize, float tsize, float coord) {
void main() {
vec2 viewportSize = global.OutputSize.xy;
vec2 gameCoord = vTexCoord;
if (MASKING) {
if (param.MASKING == 1.0) {
float hscale = viewportSize.x/global.SourceSize.x;
float vscale = viewportSize.y/global.SourceSize.y;