diff options
Diffstat (limited to 'tests/glsl/sascha-willems/multithreading')
4 files changed, 130 insertions, 0 deletions
diff --git a/tests/glsl/sascha-willems/multithreading/phong.frag b/tests/glsl/sascha-willems/multithreading/phong.frag new file mode 100644 index 000000000..663fd81b9 --- /dev/null +++ b/tests/glsl/sascha-willems/multithreading/phong.frag @@ -0,0 +1,24 @@ +#version 450 +//TEST:COMPARE_GLSL: + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable + +layout (location = 0) in vec3 inNormal; +layout (location = 1) in vec3 inColor; +layout (location = 3) in vec3 inViewVec; +layout (location = 4) in vec3 inLightVec; + +layout (location = 0) out vec4 outFragColor; + + +void main() +{ + vec3 N = normalize(inNormal); + vec3 L = normalize(inLightVec); + vec3 V = normalize(inViewVec); + vec3 R = reflect(-L, N); + vec3 diffuse = max(dot(N, L), 0.0) * inColor; + vec3 specular = pow(max(dot(R, V), 0.0), 8.0) * vec3(0.75); + outFragColor = vec4(diffuse + specular, 1.0); +}
\ No newline at end of file diff --git a/tests/glsl/sascha-willems/multithreading/phong.vert b/tests/glsl/sascha-willems/multithreading/phong.vert new file mode 100644 index 000000000..67f803dfd --- /dev/null +++ b/tests/glsl/sascha-willems/multithreading/phong.vert @@ -0,0 +1,43 @@ +#version 450 +//TEST:COMPARE_GLSL: + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable + +layout (location = 0) in vec3 inPos; +layout (location = 1) in vec3 inNormal; +layout (location = 2) in vec3 inColor; + +layout (std140, push_constant) uniform PushConsts +{ + mat4 mvp; + vec3 color; +} pushConsts; + +layout (location = 0) out vec3 outNormal; +layout (location = 1) out vec3 outColor; +layout (location = 3) out vec3 outViewVec; +layout (location = 4) out vec3 outLightVec; + +void main() +{ + outNormal = inNormal; + + if ( (inColor.r == 1.0) && (inColor.g == 0.0) && (inColor.b == 0.0)) + { + outColor = pushConsts.color; + } + else + { + outColor = inColor; + } + + gl_Position = pushConsts.mvp * vec4(inPos.xyz, 1.0); + + vec4 pos = pushConsts.mvp * vec4(inPos, 1.0); + outNormal = mat3(pushConsts.mvp) * inNormal; +// vec3 lPos = ubo.lightPos.xyz; +vec3 lPos = vec3(0.0); + outLightVec = lPos - pos.xyz; + outViewVec = -pos.xyz; +}
\ No newline at end of file diff --git a/tests/glsl/sascha-willems/multithreading/starsphere.frag b/tests/glsl/sascha-willems/multithreading/starsphere.frag new file mode 100644 index 000000000..7136a0499 --- /dev/null +++ b/tests/glsl/sascha-willems/multithreading/starsphere.frag @@ -0,0 +1,43 @@ +#version 450 +//TEST:COMPARE_GLSL: + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable + +layout (location = 0) in vec3 inUVW; + +layout (location = 0) out vec4 outFragColor; + +#define HASHSCALE3 vec3(443.897, 441.423, 437.195) +#define STARFREQUENCY 0.01 + +// Hash function by Dave Hoskins (https://www.shadertoy.com/view/4djSRW) +float hash33(vec3 p3) +{ + p3 = fract(p3 * HASHSCALE3); + p3 += dot(p3, p3.yxz+vec3(19.19)); + return fract((p3.x + p3.y)*p3.z + (p3.x+p3.z)*p3.y + (p3.y+p3.z)*p3.x); +} + +vec3 starField(vec3 pos) +{ + vec3 color = vec3(0.0); + float threshhold = (1.0 - STARFREQUENCY); + float rnd = hash33(pos); + if (rnd >= threshhold) + { + float starCol = pow((rnd - threshhold) / (1.0 - threshhold), 16.0); + color += vec3(starCol); + } + return color; +} + +void main() +{ + // Fake atmosphere at the bottom + vec3 atmosphere = clamp(vec3(0.1, 0.15, 0.4) * (inUVW.t - 5.0), 0.0, 1.0); + + vec3 color = starField(inUVW) + atmosphere; + + outFragColor = vec4(color, 1.0); +}
\ No newline at end of file diff --git a/tests/glsl/sascha-willems/multithreading/starsphere.vert b/tests/glsl/sascha-willems/multithreading/starsphere.vert new file mode 100644 index 000000000..c80106f45 --- /dev/null +++ b/tests/glsl/sascha-willems/multithreading/starsphere.vert @@ -0,0 +1,20 @@ +#version 450 +//TEST:COMPARE_GLSL: + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable + +layout (location = 0) in vec3 inPos; + +layout (std140, push_constant) uniform PushConsts +{ + mat4 mvp; +} pushConsts; + +layout (location = 0) out vec3 outUVW; + +void main() +{ + outUVW = inPos; + gl_Position = pushConsts.mvp * vec4(inPos.xyz, 1.0); +} |
