Skip to content
Snippets Groups Projects
Commit e2552851 authored by sdegrande's avatar sdegrande
Browse files

OpenVR distrotion program: use raw string litterals for prettier code.

parent 81a98675
No related branches found
Tags v0.1
No related merge requests found
......@@ -11,48 +11,55 @@ DistortionProgram::DistortionProgram()
: Program("OpenVRDistortion")
{
setShadersFromString(
"OpenVR distortion vertex shader",
"#version 330 core "
" "
"layout(location = 0) in vec4 position; "
"layout(location = 1) in vec2 v2UVredIn; "
"layout(location = 2) in vec2 v2UVGreenIn; "
"layout(location = 3) in vec2 v2UVblueIn; "
"noperspective out vec2 v2UVred; "
"noperspective out vec2 v2UVgreen; "
"noperspective out vec2 v2UVblue; "
" "
"void main() "
"{ "
" v2UVred = v2UVredIn; "
" v2UVgreen = v2UVGreenIn; "
" v2UVblue = v2UVblueIn; "
" gl_Position = position; "
"} ",
{}, {},
"OpenVR distrotion fragment shader",
"#version 330 core "
" "
"uniform sampler2D mytexture; "
" "
"noperspective in vec2 v2UVred; "
"noperspective in vec2 v2UVgreen; "
"noperspective in vec2 v2UVblue; "
" "
"out vec4 outputColor; "
" "
"void main() "
"{ "
" float fBoundsCheck = dot(vec2(lessThan(v2UVgreen.xy, vec2(0.05, 0.05))), vec2(1.0, 1.0)) + "
" dot(vec2(greaterThan(v2UVgreen.xy, vec2(0.95, 0.95))), vec2(1.0, 1.0)); "
" if (fBoundsCheck > 1.0) { "
" outputColor = vec4(0, 0, 0, 1.0); "
" } else { "
" float red = texture(mytexture, v2UVred).x; "
" float green = texture(mytexture, v2UVgreen).y; "
" float blue = texture(mytexture, v2UVblue).z; "
" outputColor = vec4(red, green, blue, 1.0); "
" } "
"} "
);
"OpenVR distortion vertex shader",
R"VS(
#version 330 core
layout(location = 0) in vec4 position;
layout(location = 1) in vec2 v2UVredIn;
layout(location = 2) in vec2 v2UVGreenIn;
layout(location = 3) in vec2 v2UVblueIn;
noperspective out vec2 v2UVred;
noperspective out vec2 v2UVgreen;
noperspective out vec2 v2UVblue;
void main()
{
v2UVred = v2UVredIn;
v2UVgreen = v2UVGreenIn;
v2UVblue = v2UVblueIn;
gl_Position = position;
}
)VS",
{}, {},
"OpenVR distortion fragment shader",
R"FS(
#version 330 core
uniform sampler2D mytexture;
noperspective in vec2 v2UVred;
noperspective in vec2 v2UVgreen;
noperspective in vec2 v2UVblue;
out vec4 outputColor;
void main()
{
float fBoundsCheck = dot(vec2(lessThan(v2UVgreen.xy, vec2(0.05, 0.05))), vec2(1.0, 1.0)) +
dot(vec2(greaterThan(v2UVgreen.xy, vec2(0.95, 0.95))), vec2(1.0, 1.0));
if (fBoundsCheck > 1.0) {
outputColor = vec4(0, 0, 0, 1.0);
} else {
float red = texture(mytexture, v2UVred).x;
float green = texture(mytexture, v2UVgreen).y;
float blue = texture(mytexture, v2UVblue).z;
outputColor = vec4(red, green, blue, 1.0);
}
} "
)FS"
);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment