Updated displacement example
This commit is contained in:
parent
0ecff76c40
commit
2ec1a60535
16 changed files with 77 additions and 177 deletions
|
|
@ -3,7 +3,7 @@
|
|||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 3) uniform sampler2D colorMap;
|
||||
layout (binding = 2) uniform sampler2D colorMap;
|
||||
|
||||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec2 inUV;
|
||||
|
|
@ -25,5 +25,5 @@ void main()
|
|||
vec4 IAmbient = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
vec4 IDiffuse = vec4(1.0) * max(dot(inNormal, inLightVec), 0.0);
|
||||
|
||||
outFragColor = vec4((IAmbient + IDiffuse) * texture(colorMap, inUV));
|
||||
outFragColor = vec4((IAmbient + IDiffuse) * vec4(texture(colorMap, inUV).rgb, 1.0));
|
||||
}
|
||||
Binary file not shown.
|
|
@ -18,15 +18,15 @@ layout (location = 1) out vec2 outUV[3];
|
|||
|
||||
void main()
|
||||
{
|
||||
if (gl_InvocationID == 0)
|
||||
{
|
||||
gl_TessLevelInner[0] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[0] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[1] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[2] = ubo.tessLevel;
|
||||
}
|
||||
if (gl_InvocationID == 0)
|
||||
{
|
||||
gl_TessLevelInner[0] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[0] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[1] = ubo.tessLevel;
|
||||
gl_TessLevelOuter[2] = ubo.tessLevel;
|
||||
}
|
||||
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
outNormal[gl_InvocationID] = inNormal[gl_InvocationID];
|
||||
outUV[gl_InvocationID] = inUV[gl_InvocationID];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,12 +26,11 @@ layout (location = 3) out vec3 outLightVec;
|
|||
|
||||
void main()
|
||||
{
|
||||
|
||||
gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position);
|
||||
outUV = gl_TessCoord.x * inUV[0] + gl_TessCoord.y * inUV[1] + gl_TessCoord.z * inUV[2];
|
||||
outNormal = gl_TessCoord.x * inNormal[0] + gl_TessCoord.y * inNormal[1] + gl_TessCoord.z * inNormal[2];
|
||||
|
||||
gl_Position.xyz += normalize(outNormal) * (max(textureLod(displacementMap, outUV.st, 0.0).r, 0.45) * ubo.tessStrength);
|
||||
gl_Position.xyz += normalize(outNormal) * (max(textureLod(displacementMap, outUV.st, 0.0).a, 0.0) * ubo.tessStrength);
|
||||
|
||||
outEyesPos = (gl_Position).xyz;
|
||||
outLightVec = normalize(ubo.lightPos.xyz - outEyesPos);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,7 +1,5 @@
|
|||
glslangvalidator -V base.vert -o base.vert.spv
|
||||
glslangvalidator -V base.frag -o base.frag.spv
|
||||
glslangvalidator -V passthrough.tesc -o passthrough.tesc.spv
|
||||
glslangvalidator -V passthrough.tese -o passthrough.tese.spv
|
||||
glslangvalidator -V displacement.tesc -o displacement.tesc.spv
|
||||
glslangvalidator -V displacement.tese -o displacement.tese.spv
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (vertices = 3) out;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 1) in vec2 inTexCoord[];
|
||||
layout (location = 0) out vec3 outNormal[3];
|
||||
layout (location = 3) out vec2 oTexCoord[3];
|
||||
|
||||
void main(void)
|
||||
{
|
||||
if (gl_InvocationID == 0)
|
||||
{
|
||||
gl_TessLevelInner[0] = 1.0;
|
||||
gl_TessLevelOuter[0] = 1.0;
|
||||
gl_TessLevelOuter[1] = 1.0;
|
||||
gl_TessLevelOuter[2] = 1.0;
|
||||
}
|
||||
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
outNormal[gl_InvocationID] = inNormal[gl_InvocationID];
|
||||
oTexCoord[gl_InvocationID] = inTexCoord[gl_InvocationID];
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,34 +0,0 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (triangles) in;
|
||||
|
||||
layout (binding = 1) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
vec3 lightPos;
|
||||
float tessAlpha;
|
||||
float tessStrength;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) in vec3 inNormal[];
|
||||
layout (location = 3) in vec2 inTexCoord[];
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec2 outTexCoord;
|
||||
layout (location = 2) out vec3 outEyesPos;
|
||||
layout (location = 3) out vec3 outLightVec;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position);
|
||||
outNormal = gl_TessCoord.x * inNormal[0] + gl_TessCoord.y * inNormal[1] + gl_TessCoord.z * inNormal[2];
|
||||
outTexCoord = gl_TessCoord.x * inTexCoord[0] + gl_TessCoord.y * inTexCoord[1] + gl_TessCoord.z * inTexCoord[2];
|
||||
gl_Position.xyz += normalize(outNormal);
|
||||
outEyesPos = (gl_Position).xyz;
|
||||
outLightVec = normalize(ubo.lightPos - outEyesPos);
|
||||
gl_Position = ubo.projection * ubo.model * gl_Position;
|
||||
|
||||
}
|
||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue