From bfd1d96f8f5235507b29686207b605398e5089dc Mon Sep 17 00:00:00 2001 From: James Fulop Date: Wed, 28 Sep 2016 01:34:15 -0400 Subject: [PATCH] ignoring w component on VS_In --- renderdoc/data/glsl/mesh.comp | 12 +++++++++++- renderdoc/data/hlsl/mesh.hlsl | 20 ++++++++++++++++---- renderdoc/driver/d3d11/d3d11_analyse.cpp | 4 +++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/renderdoc/data/glsl/mesh.comp b/renderdoc/data/glsl/mesh.comp index c9790c604..61a5409e9 100644 --- a/renderdoc/data/glsl/mesh.comp +++ b/renderdoc/data/glsl/mesh.comp @@ -140,9 +140,19 @@ void trianglePath(uint threadID) #endif vec3 hitPosition; - bool hit = TriangleRayIntersect(pos0.xyz/pos0.w, pos1.xyz/pos1.w, pos2.xyz/pos2.w, + bool hit; + if (meshpick.unproject == 1u) + { + hit = TriangleRayIntersect(pos0.xyz / pos0.w, pos1.xyz / pos1.w, pos2.xyz / pos2.w, meshpick.rayPos, meshpick.rayDir, /*out*/ hitPosition); + } + else + { + hit = TriangleRayIntersect(pos0.xyz, pos1.xyz, pos2.xyz, + meshpick.rayPos, meshpick.rayDir, + /*out*/ hitPosition); + } // ray hit a triangle, so return the vertex that was closest // to the triangle/ray intersection point diff --git a/renderdoc/data/hlsl/mesh.hlsl b/renderdoc/data/hlsl/mesh.hlsl index 577a61d4b..289aaf6f6 100644 --- a/renderdoc/data/hlsl/mesh.hlsl +++ b/renderdoc/data/hlsl/mesh.hlsl @@ -143,7 +143,8 @@ cbuffer MeshPickData : register(b0) float2 PickViewport; uint PickMeshMode; - float3 Padding; + uint PickUnproject; + float2 Padding; row_major float4x4 PickMVP; }; @@ -232,11 +233,22 @@ void trianglePath(uint threadID) float4 pos0 = PickIdx ? vertex[index[vertid0]] : vertex[vertid0]; float4 pos1 = PickIdx ? vertex[index[vertid1]] : vertex[vertid1]; float4 pos2 = PickIdx ? vertex[index[vertid2]] : vertex[vertid2]; + float3 hitPosition; - bool hit = TriangleRayIntersect(pos0.xyz/pos0.w, pos1.xyz/pos1.w, pos2.xyz/pos2.w, - PickRayPos, PickRayDir, - /*out*/ hitPosition); + bool hit; + if (PickUnproject == 1) + { + hit = TriangleRayIntersect(pos0.xyz / pos0.w, pos1.xyz / pos1.w, pos2.xyz / pos2.w, + PickRayPos, PickRayDir, + /*out*/ hitPosition); + } + else + { + hit = TriangleRayIntersect(pos0.xyz, pos1.xyz, pos2.xyz, + PickRayPos, PickRayDir, + /*out*/ hitPosition); + } // ray hit a triangle, so return the vertex that was closest // to the triangle/ray intersection point diff --git a/renderdoc/driver/d3d11/d3d11_analyse.cpp b/renderdoc/driver/d3d11/d3d11_analyse.cpp index 753aed99d..6695fb1df 100644 --- a/renderdoc/driver/d3d11/d3d11_analyse.cpp +++ b/renderdoc/driver/d3d11/d3d11_analyse.cpp @@ -2250,7 +2250,8 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, Vec2f PickViewport; uint32_t MeshMode; - Vec3f Padding; + uint32_t PickUnproject; + float2 Padding; Matrix4f PickMVP; @@ -2260,6 +2261,7 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, cbuf.PickViewport = Vec2f((float)GetWidth(), (float)GetHeight()); cbuf.PickIdx = cfg.position.idxByteWidth ? 1 : 0; cbuf.PickNumVerts = cfg.position.numVerts; + cbuf.PickUnproject = cfg.position.unproject ? 1 : 0; Matrix4f projMat = Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, float(GetWidth()) / float(GetHeight()));