Fixed flipped reflection and skybox on x-axis, enable anisotropy (Fixes #232)

This commit is contained in:
saschawillems 2016-09-17 10:31:04 +02:00
parent 13eed42bfb
commit 9ce827b3f3
7 changed files with 32 additions and 3 deletions

View file

@ -20,6 +20,7 @@ void main()
vec3 cR = reflect (cI, normalize(inNormal));
cR = vec3(inInvModelView * vec4(cR, 0.0));
cR.x *= -1.0;
vec4 color = texture(samplerColor, cR, inLodBias);
@ -31,5 +32,4 @@ void main()
vec3 diffuse = max(dot(N, L), 0.0) * vec3(1.0);
vec3 specular = pow(max(dot(R, V), 0.0), 16.0) * vec3(0.5);
outFragColor = vec4(ambient + diffuse * color.rgb + specular, 1.0);
}

View file

@ -21,5 +21,6 @@ out gl_PerVertex
void main()
{
outUVW = inPos;
outUVW.x *= -1.0;
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
}

Binary file not shown.

View file

@ -80,7 +80,7 @@ public:
{
zoom = -4.0f;
rotationSpeed = 0.25f;
rotation = { -7.25f, 120.0f, 0.0f };
rotation = { -7.25f, -120.0f, 0.0f };
enableTextOverlay = true;
title = "Vulkan Example - Cube map";
}
@ -267,11 +267,16 @@ public:
sampler.addressModeV = sampler.addressModeU;
sampler.addressModeW = sampler.addressModeU;
sampler.mipLodBias = 0.0f;
sampler.maxAnisotropy = 8.0f;
sampler.compareOp = VK_COMPARE_OP_NEVER;
sampler.minLod = 0.0f;
sampler.maxLod = cubeMap.mipLevels;
sampler.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
sampler.maxAnisotropy = 1.0f;
if (vulkanDevice->features.samplerAnisotropy)
{
sampler.maxAnisotropy = vulkanDevice->properties.limits.maxSamplerAnisotropy;
sampler.anisotropyEnable = VK_TRUE;
}
VK_CHECK_RESULT(vkCreateSampler(device, &sampler, nullptr, &cubeMap.sampler));
// Create image view

View file

@ -89,6 +89,12 @@
<ClInclude Include="..\base\vulkanexamplebase.h" />
<ClInclude Include="..\base\vulkantools.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\data\shaders\cubemap\reflect.frag" />
<None Include="..\data\shaders\cubemap\reflect.vert" />
<None Include="..\data\shaders\cubemap\skybox.frag" />
<None Include="..\data\shaders\cubemap\skybox.vert" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View file

@ -13,6 +13,9 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
<Filter Include="Shaders">
<UniqueIdentifier>{3adf072b-32a9-412a-8eb5-5329a601df1a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\base\vulkandebug.cpp">
@ -39,4 +42,18 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\data\shaders\cubemap\reflect.frag">
<Filter>Shaders</Filter>
</None>
<None Include="..\data\shaders\cubemap\reflect.vert">
<Filter>Shaders</Filter>
</None>
<None Include="..\data\shaders\cubemap\skybox.frag">
<Filter>Shaders</Filter>
</None>
<None Include="..\data\shaders\cubemap\skybox.vert">
<Filter>Shaders</Filter>
</None>
</ItemGroup>
</Project>