Add missing inverseModelView UBO to fix hdr sample
This commit is contained in:
parent
b6f2577174
commit
13c081664e
10 changed files with 40 additions and 35 deletions
|
|
@ -34,7 +34,7 @@ Shaders written to mirror the GLSL versions at `eddd724`. There have been change
|
||||||
| gears | ☑ | ☑ | ☑ | ☑
|
| gears | ☑ | ☑ | ☑ | ☑
|
||||||
| geometryshader | ☑ | ☑ | ☑ | ☑
|
| geometryshader | ☑ | ☑ | ☑ | ☑
|
||||||
| gltfscene | - | - | ☑ | ☑
|
| gltfscene | - | - | ☑ | ☑
|
||||||
| hdr | ☑ | ❌ | ☑ | ❌
|
| hdr | ☑ | ❌ | ☑ | ☑
|
||||||
| imgui | ☑ | ☑ | ☑ | ☑
|
| imgui | ☑ | ☑ | ☑ | ☑
|
||||||
| indirectdraw | ☑ | ☑ | ☑ | ☑
|
| indirectdraw | ☑ | ☑ | ☑ | ☑
|
||||||
| inlineuniformblocks | ☑ | ☑ | ☑ | ☑
|
| inlineuniformblocks | ☑ | ☑ | ☑ | ☑
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -2,12 +2,17 @@
|
||||||
|
|
||||||
layout (binding = 1) uniform samplerCube samplerEnvMap;
|
layout (binding = 1) uniform samplerCube samplerEnvMap;
|
||||||
|
|
||||||
|
layout (binding = 0) uniform UBO {
|
||||||
|
mat4 projection;
|
||||||
|
mat4 modelview;
|
||||||
|
mat4 inverseModelview;
|
||||||
|
} ubo;
|
||||||
|
|
||||||
layout (location = 0) in vec3 inUVW;
|
layout (location = 0) in vec3 inUVW;
|
||||||
layout (location = 1) in vec3 inPos;
|
layout (location = 1) in vec3 inPos;
|
||||||
layout (location = 2) in vec3 inNormal;
|
layout (location = 2) in vec3 inNormal;
|
||||||
layout (location = 3) in vec3 inViewVec;
|
layout (location = 3) in vec3 inViewVec;
|
||||||
layout (location = 4) in vec3 inLightVec;
|
layout (location = 4) in vec3 inLightVec;
|
||||||
layout (location = 5) in mat4 inInvModelView;
|
|
||||||
|
|
||||||
layout (location = 0) out vec4 outColor0;
|
layout (location = 0) out vec4 outColor0;
|
||||||
layout (location = 1) out vec4 outColor1;
|
layout (location = 1) out vec4 outColor1;
|
||||||
|
|
@ -17,9 +22,9 @@ layout (constant_id = 0) const int type = 0;
|
||||||
#define PI 3.1415926
|
#define PI 3.1415926
|
||||||
#define TwoPI (2.0 * PI)
|
#define TwoPI (2.0 * PI)
|
||||||
|
|
||||||
layout (binding = 2) uniform UBO {
|
layout (binding = 2) uniform Exposure {
|
||||||
float exposure;
|
float exposure;
|
||||||
} ubo;
|
} exposure;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
@ -36,9 +41,9 @@ void main()
|
||||||
|
|
||||||
case 1: // Reflect
|
case 1: // Reflect
|
||||||
{
|
{
|
||||||
vec3 wViewVec = mat3(inInvModelView) * normalize(inViewVec);
|
vec3 wViewVec = mat3(ubo.inverseModelview) * normalize(inViewVec);
|
||||||
vec3 normal = normalize(inNormal);
|
vec3 normal = normalize(inNormal);
|
||||||
vec3 wNormal = mat3(inInvModelView) * normal;
|
vec3 wNormal = mat3(ubo.inverseModelview) * normal;
|
||||||
|
|
||||||
float NdotL = max(dot(normal, inLightVec), 0.0);
|
float NdotL = max(dot(normal, inLightVec), 0.0);
|
||||||
|
|
||||||
|
|
@ -72,8 +77,8 @@ void main()
|
||||||
|
|
||||||
case 2: // Refract
|
case 2: // Refract
|
||||||
{
|
{
|
||||||
vec3 wViewVec = mat3(inInvModelView) * normalize(inViewVec);
|
vec3 wViewVec = mat3(ubo.inverseModelview) * normalize(inViewVec);
|
||||||
vec3 wNormal = mat3(inInvModelView) * inNormal;
|
vec3 wNormal = mat3(ubo.inverseModelview) * inNormal;
|
||||||
color = texture(samplerEnvMap, refract(-wViewVec, wNormal, 1.0/1.6));
|
color = texture(samplerEnvMap, refract(-wViewVec, wNormal, 1.0/1.6));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -81,7 +86,7 @@ void main()
|
||||||
|
|
||||||
|
|
||||||
// Color with manual exposure into attachment 0
|
// Color with manual exposure into attachment 0
|
||||||
outColor0.rgb = vec3(1.0) - exp(-color.rgb * ubo.exposure);
|
outColor0.rgb = vec3(1.0) - exp(-color.rgb * exposure.exposure);
|
||||||
|
|
||||||
// Bright parts for bloom into attachment 1
|
// Bright parts for bloom into attachment 1
|
||||||
float l = dot(outColor0.rgb, vec3(0.2126, 0.7152, 0.0722));
|
float l = dot(outColor0.rgb, vec3(0.2126, 0.7152, 0.0722));
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -8,6 +8,7 @@ layout (constant_id = 0) const int type = 0;
|
||||||
layout (binding = 0) uniform UBO {
|
layout (binding = 0) uniform UBO {
|
||||||
mat4 projection;
|
mat4 projection;
|
||||||
mat4 modelview;
|
mat4 modelview;
|
||||||
|
mat4 inverseModelview;
|
||||||
} ubo;
|
} ubo;
|
||||||
|
|
||||||
layout (location = 0) out vec3 outUVW;
|
layout (location = 0) out vec3 outUVW;
|
||||||
|
|
@ -15,7 +16,6 @@ layout (location = 1) out vec3 outPos;
|
||||||
layout (location = 2) out vec3 outNormal;
|
layout (location = 2) out vec3 outNormal;
|
||||||
layout (location = 3) out vec3 outViewVec;
|
layout (location = 3) out vec3 outViewVec;
|
||||||
layout (location = 4) out vec3 outLightVec;
|
layout (location = 4) out vec3 outLightVec;
|
||||||
layout (location = 5) out mat4 outInvModelView;
|
|
||||||
|
|
||||||
out gl_PerVertex
|
out gl_PerVertex
|
||||||
{
|
{
|
||||||
|
|
@ -39,8 +39,6 @@ void main()
|
||||||
outPos = vec3(ubo.modelview * vec4(inPos, 1.0));
|
outPos = vec3(ubo.modelview * vec4(inPos, 1.0));
|
||||||
outNormal = mat3(ubo.modelview) * inNormal;
|
outNormal = mat3(ubo.modelview) * inNormal;
|
||||||
|
|
||||||
outInvModelView = inverse(ubo.modelview);
|
|
||||||
|
|
||||||
vec3 lightPos = vec3(0.0f, -5.0f, 5.0f);
|
vec3 lightPos = vec3(0.0f, -5.0f, 5.0f);
|
||||||
outLightVec = lightPos.xyz - outPos.xyz;
|
outLightVec = lightPos.xyz - outPos.xyz;
|
||||||
outViewVec = -outPos.xyz;
|
outViewVec = -outPos.xyz;
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -58,6 +58,7 @@ public:
|
||||||
struct UBOVS {
|
struct UBOVS {
|
||||||
glm::mat4 projection;
|
glm::mat4 projection;
|
||||||
glm::mat4 modelview;
|
glm::mat4 modelview;
|
||||||
|
glm::mat4 inverseModelview;
|
||||||
} uboVS;
|
} uboVS;
|
||||||
|
|
||||||
struct UBOParams {
|
struct UBOParams {
|
||||||
|
|
@ -621,7 +622,7 @@ public:
|
||||||
void setupDescriptorSetLayout()
|
void setupDescriptorSetLayout()
|
||||||
{
|
{
|
||||||
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings = {
|
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings = {
|
||||||
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT, 0),
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0),
|
||||||
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 1),
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 1),
|
||||||
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_FRAGMENT_BIT, 2),
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_FRAGMENT_BIT, 2),
|
||||||
};
|
};
|
||||||
|
|
@ -922,6 +923,7 @@ public:
|
||||||
{
|
{
|
||||||
uboVS.projection = camera.matrices.perspective;
|
uboVS.projection = camera.matrices.perspective;
|
||||||
uboVS.modelview = camera.matrices.view;
|
uboVS.modelview = camera.matrices.view;
|
||||||
|
uboVS.inverseModelview = glm::inverse(camera.matrices.view);
|
||||||
memcpy(uniformBuffers.matrices.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBuffers.matrices.mapped, &uboVS, sizeof(uboVS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue