0% found this document useful (0 votes)
6 views

bad_shader_5

Uploaded by

João Pedro
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

bad_shader_5

Uploaded by

João Pedro
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

#version 450 core

#define API_OPENGL 0
#define API_OPENGL_ES 0
#define API_D3D11 0
#define API_VULKAN 1
#define GLSL 1
#define float2 vec2
#define float3 vec3
#define float4 vec4
#define int2 ivec2
#define int3 ivec3
#define int4 ivec4
#define uint2 uvec2
#define uint3 uvec3
#define uint4 uvec4
#define float2x2 mat2
#define float3x3 mat3
#define float4x4 mat4
#define mul(x, y) ((x) * (y))
#define nointerpolation flat
#define frac fract
#define lerp mix
#define CONSTANT const
#define GLOBAL
#define VECTOR_EQ(a, b) ((a) == (b))
#define VECTOR_NEQ(a, b) ((a) != (b))
#define VECTOR_COMP_EQ(a, b) equal((a), (b))
#define VECTOR_COMP_NEQ(a, b) notEqual((a), (b))
#define SAMPLE_TEXTURE(name, coords) texture(name, coords)
#define LOAD_TEXTURE(name, coords, mip) texelFetch(name, coords, mip)
#define LOAD_TEXTURE_MS(name, coords, sample) texelFetch(name, coords, int(sample))
#define LOAD_TEXTURE_OFFSET(name, coords, mip, offset) texelFetchOffset(name,
coords, mip, offset)
#define LOAD_TEXTURE_BUFFER(name, index) texelFetch(name, index)
#define BEGIN_ARRAY(type, size) type[size](
#define END_ARRAY )
float saturate(float value) { return clamp(value, 0.0, 1.0); }
float2 saturate(float2 value) { return clamp(value, float2(0.0, 0.0), float2(1.0,
1.0)); }
float3 saturate(float3 value) { return clamp(value, float3(0.0, 0.0, 0.0),
float3(1.0, 1.0, 1.0)); }
float4 saturate(float4 value) { return clamp(value, float4(0.0, 0.0, 0.0, 0.0),
float4(1.0, 1.0, 1.0, 1.0)); }

layout(set = 0, binding = 1) uniform sampler2D samp0;


layout(std140, set = 0, binding = 0) uniform UBOBlock
{
float4 src_rect;
float2 src_size;
float2 resolution;
float2 rcp_resolution;
float2 window_resolution;
float2 rcp_window_resolution;
float time;
float ubo_pad0;

float LUMINANCE;
float ubo_pad1;
float ubo_pad2;
float ubo_pad3;
float ORANGECYAN;
float ubo_pad4;
float ubo_pad5;
float ubo_pad6;
float MAGENTAGREEN;
float ubo_pad7;
float ubo_pad8;
float ubo_pad9;
float BLACK;
float ubo_pad10;
float ubo_pad11;
float ubo_pad12;
float WHITE;
float ubo_pad13;
float ubo_pad14;
float ubo_pad15;
float NOISE;
float ubo_pad16;
float ubo_pad17;
float ubo_pad18;
float SATURATION;
float ubo_pad19;
float ubo_pad20;
float ubo_pad21;
};

layout(location = 0) in VertexData {
float2 v_tex0;
};
layout(location = 0) out float4 o_col0;

float4 Sample() { return texture(samp0, v_tex0); }


float4 SampleLocation(float2 location) { return texture(samp0, location); }
#define SampleOffset(offset) textureOffset(samp0, v_tex0, offset)
float2 GetFragCoord()
{
return gl_FragCoord.xy;
}
float2 GetWindowResolution()
{
return window_resolution;
}
float2 GetResolution()
{
return resolution;
}
float2 GetInvResolution()
{
return rcp_resolution;
}
float2 GetCoordinates()
{
return v_tex0;
}
float GetTime()
{
return time;
}
void SetOutput(float4 color)
{
o_col0 = color;
}
#define GetOption(x) (x)
#define OptionEnabled(x) ((x) != 0)
/*==========================================*\
/*=======Calibrator by PavelDurov1488=======*\
/*==========It's not ready yet...===========*\
/*===I need to add blur, dynamic noise...===*\
[configuration]

[OptionRangeFloat]
GUIName = Luminance(Y)
OptionName = LUMINANCE
MinValue = 0.000
MaxValue = 3.000
StepAmount = 0.050
DefaultValue = 1.200

[OptionRangeFloat]
GUIName = Orange-Cyan(I)
OptionName = ORANGECYAN
MinValue = 0.000
MaxValue = 3.000
StepAmount = 0.050
DefaultValue = 1.200

[OptionRangeFloat]
GUIName = Magenta-Green(Q)
OptionName = MAGENTAGREEN
MinValue = 0.000
MaxValue = 3.000
StepAmount = 0.050
DefaultValue = 1.200

[OptionRangeFloat]
GUIName = Black
OptionName = BLACK
MinValue = 0.000
MaxValue = 255.000
StepAmount = 1.000
DefaultValue = 10.000

[OptionRangeFloat]
GUIName = White
OptionName = WHITE
MinValue = 0.000
MaxValue = 255.000
StepAmount = 1.000
DefaultValue = 240.000

[OptionRangeFloat]
GUIName = Noise
OptionName = NOISE
MinValue = 0.000
MaxValue = 50.000
StepAmount = 1.000
DefaultValue = 10.000

[OptionRangeFloat]
GUIName = Saturation
OptionName = SATURATION
MinValue = 0.000
MaxValue = 100.000
StepAmount = 1.000
DefaultValue = 50.000

[/configuration]
*/

float pseudoNoise(vec2 co)


{
return fract(sin(dot(vec2(co.x+0.513,co.y+0.4124) ,vec2(12.9898,78.233))) *
43758.5453);//
*fract(sin(dot(vec2(co.x+4.231,co.y+3.143) ,vec2(12.9898,78.233)*2.0)) *
43758.5453); //pseudo random number generator
}

const vec3 RGBtoY = vec3(0.299, 0.587, 0.114);


const vec3 RGBtoI = vec3(0.596,-0.275,-0.321);
const vec3 RGBtoQ = vec3(0.212,-0.523, 0.311);
const vec3 YIQtoR = vec3(1.0, 0.95568806036115671171, 0.61985809445637075388);
const vec3 YIQtoG = vec3(1.0,-0.27158179694405859326,-0.64687381613840131330);
const vec3 YIQtoB = vec3(1.0,-1.10817732668266195230, 1.70506455991918171490);

void main()
{

float2 texcoord = GetCoordinates();


float2 time = float2(GetTime());
// int FrameCount = GetFrameCount();
float4 color = Sample();
// float brightness_scale = GetOption(BRIGHTNESS_SCALE);

//vec3 czm_saturation(vec3 rgb, float adjustment)


//{
// // Algorithm from Chapter 16 of OpenGL Shading Language
// const vec3 W = vec3(0.2125, 0.7154, 0.0721);
// vec3 intensity = vec3(dot(rgb, W));
// return mix(intensity, rgb, adjustment);
//}

// rgb->yiq
float3 yuv;
yuv.r = pow(dot(color.rgb, float3(0.299, 0.587, 0.114)),LUMINANCE);
yuv.g = dot(color.rgb, float3(0.595716,-0.274453,-0.321263))*ORANGECYAN;
yuv.b = dot(color.rgb, float3(0.211456,-0.522591, 0.311135))*MAGENTAGREEN;

// apply brightness to y
// yuv.r = saturate(yuv.r * brightness_scale);

// yuv->rgb
color.r = dot(yuv, float3(1.0, 0.95629572, 0.62102442));
color.g = dot(yuv, float3(1.0,-0.27212210,-0.64738060));
color.b = dot(yuv, float3(1.0,-1.10698902, 1.70461500));
color.rgb = saturate(color.rgb*WHITE/255.0+BLACK/255.0-color.rgb*BLACK/255.0+
(pseudoNoise(texcoord))*1.0/255.0);

color.rgb = saturate(color.rgb+
(pseudoNoise(vec2(color.r+color.b,color.g+color.b))-0.5)*NOISE/255.0);
SetOutput(saturate(color));
}

Failed to parse shader


Shader Info Log:
ERROR: 0:123: '' : syntax error, unexpected MUL_ASSIGN
ERROR: 1 compilation errors. No code generated.

You might also like