Added space background sphere using a secondary command buffer
This commit is contained in:
parent
e1d45bb90e
commit
6f61d0fd63
8 changed files with 164 additions and 22 deletions
|
|
@ -1,2 +1,4 @@
|
|||
glslangvalidator -V phong.vert -o phong.vert.spv
|
||||
glslangvalidator -V phong.frag -o phong.frag.spv
|
||||
glslangvalidator -V phong.frag -o phong.frag.spv
|
||||
glslangvalidator -V starsphere.vert -o starsphere.vert.spv
|
||||
glslangvalidator -V starsphere.frag -o starsphere.frag.spv
|
||||
|
|
@ -21,7 +21,15 @@ layout (location = 4) out vec3 outLightVec;
|
|||
void main()
|
||||
{
|
||||
outNormal = inNormal;
|
||||
outColor = inColor;// * pushConsts.color;
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
|||
Binary file not shown.
42
data/shaders/multithreading/starsphere.frag
Normal file
42
data/shaders/multithreading/starsphere.frag
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#version 450
|
||||
|
||||
#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+19.19);
|
||||
return fract(vec3((p3.x + p3.y)*p3.z + (p3.x+p3.z)*p3.y + (p3.y+p3.z)*p3.x));
|
||||
}
|
||||
|
||||
float 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);
|
||||
}
|
||||
BIN
data/shaders/multithreading/starsphere.frag.spv
Normal file
BIN
data/shaders/multithreading/starsphere.frag.spv
Normal file
Binary file not shown.
19
data/shaders/multithreading/starsphere.vert
Normal file
19
data/shaders/multithreading/starsphere.vert
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#version 450
|
||||
|
||||
#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);
|
||||
}
|
||||
BIN
data/shaders/multithreading/starsphere.vert.spv
Normal file
BIN
data/shaders/multithreading/starsphere.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue