fix: correct matrix order (proj*view) + Z depth range for Vulkan
- VP matrix order: proj*view (GLSL column-vector convention) - Z correction in vertex shader: gl_Position.z = (z+w)*0.5 (OpenGL [-1,1] → Vulkan [0,1]) - Depth test temporarily disabled for debugging
This commit is contained in:
@@ -17,6 +17,7 @@ layout(row_major, push_constant) uniform PC {
|
||||
|
||||
void main() {
|
||||
gl_Position = vp * pc.model * vec4(inPosition, 1.0);
|
||||
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
|
||||
fragColor = inColor;
|
||||
fragNormal = mat3(pc.model) * inNormal;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -118,8 +118,8 @@ internal sealed unsafe class VulkanPipeline : IDisposable
|
||||
var depthStencilState = new VkPipelineDepthStencilStateCreateInfo
|
||||
{
|
||||
sType = VkStructureType.PipelineDepthStencilStateCreateInfo,
|
||||
depthTestEnable = VkBool32.True,
|
||||
depthWriteEnable = VkBool32.True,
|
||||
depthTestEnable = VkBool32.False,
|
||||
depthWriteEnable = VkBool32.False,
|
||||
depthCompareOp = VkCompareOp.Less,
|
||||
depthBoundsTestEnable = VkBool32.False,
|
||||
stencilTestEnable = VkBool32.False,
|
||||
|
||||
@@ -273,8 +273,8 @@ internal sealed unsafe class VulkanRenderer : IRenderer, Engine.Graphics.IScreen
|
||||
{
|
||||
var aspect = (float)_swapchain.Extent.Width / (float)_swapchain.Extent.Height;
|
||||
var proj = Matrix4x4.CreatePerspectiveFieldOfView(MathF.PI / 4f, aspect, 0.1f, 100f);
|
||||
var view = Matrix4x4.CreateLookAt(new Vector3(0, 0, -3), Vector3.Zero, Vector3.UnitY);
|
||||
return view * proj;
|
||||
var view = Matrix4x4.CreateLookAt(new Vector3(0, 0, 3), Vector3.Zero, Vector3.UnitY);
|
||||
return proj * view;
|
||||
}
|
||||
|
||||
private static void TransitionImageLayout(VkCommandBuffer cmd, VkImage image,
|
||||
|
||||
Reference in New Issue
Block a user