Skip to content

Commit

Permalink
Merge branch 'dev/ralston/explicit_vectors' into 'main'
Browse files Browse the repository at this point in the history
Explicit Vector Constructors

See merge request lightspeedrtx/dxvk-remix-nv!764
  • Loading branch information
anon-apple committed Mar 27, 2024
2 parents 5594caa + 03df56b commit 7e24a52
Show file tree
Hide file tree
Showing 30 changed files with 287 additions and 191 deletions.
6 changes: 3 additions & 3 deletions src/d3d9/d3d9_rtx_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ namespace dxvk {
pVertex += vertexStride;
}

AxisAlignedBoundingBox boundingBox = {
{ minPos.m128_f32[0], minPos.m128_f32[1], minPos.m128_f32[2] },
{ maxPos.m128_f32[0], maxPos.m128_f32[1], maxPos.m128_f32[2] }
AxisAlignedBoundingBox boundingBox{
Vector3{ minPos.m128_f32[0], minPos.m128_f32[1], minPos.m128_f32[2] },
Vector3{ maxPos.m128_f32[0], maxPos.m128_f32[1], maxPos.m128_f32[2] }
};

vertexBuffer->decRef();
Expand Down
2 changes: 1 addition & 1 deletion src/d3d9/d3d9_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ namespace dxvk {
}
else {
for (UINT i = 0; i < Count; i++)
set.fConsts[StartRegister + i] = replaceNaN(pConstantData + (i * 4));
set.fConsts[StartRegister + i] = replaceNaN(Vector4{ pConstantData + (i * 4) });
}
}
else if constexpr (ConstantType == D3D9ConstantType::Int) {
Expand Down
14 changes: 7 additions & 7 deletions src/dxvk/rtx_render/rtx_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ namespace dxvk
m_context.freeCameraViewRelative = freeCameraViewRelative();
}

freeCamViewToWorld[3] = m_matCache[MatrixType::ViewToWorld][3] + Vector4(freeCameraPosition(), 0.f);
freeCamViewToWorld[3] = m_matCache[MatrixType::ViewToWorld][3] + Vector4d{ Vector3d{ freeCameraPosition() }, 0.0 };
return freeCamViewToWorld;
}

Expand Down Expand Up @@ -561,7 +561,7 @@ namespace dxvk
m_matCache[MatrixType::UncorrectedPreviousTranslatedWorldToView] = m_matCache[MatrixType::TranslatedWorldToView];

auto viewToTranslatedWorld = m_matCache[MatrixType::ViewToWorld];
viewToTranslatedWorld[3] = Vector4(0.0f, 0.0f, 0.0f, viewToTranslatedWorld[3].w);
viewToTranslatedWorld[3] = Vector4d(0.0f, 0.0f, 0.0f, viewToTranslatedWorld[3].w);

m_matCache[MatrixType::ViewToTranslatedWorld] = freeCameraViewRelative() ? viewToTranslatedWorld : Matrix4d();
// Note: Slightly non-ideal to have to inverse an already inverted matrix when we have the original world to view matrix,
Expand Down Expand Up @@ -673,7 +673,7 @@ namespace dxvk
}

auto freeCamViewToTranslatedWorld = freeCamViewToWorld;
freeCamViewToTranslatedWorld[3] = Vector4(0.0f, 0.0f, 0.0f, freeCamViewToTranslatedWorld[3].w);
freeCamViewToTranslatedWorld[3] = Vector4d(0.0f, 0.0f, 0.0f, freeCamViewToTranslatedWorld[3].w);

m_matCache[MatrixType::FreeCamPreviousPreviousWorldToView] = m_matCache[MatrixType::FreeCamPreviousWorldToView];
m_matCache[MatrixType::FreeCamPreviousPreviousViewToWorld] = m_matCache[MatrixType::FreeCamPreviousViewToWorld];
Expand Down Expand Up @@ -767,8 +767,8 @@ namespace dxvk
camera.prevTranslatedWorldToView = prevTranslatedWorldToView;
camera.prevTranslatedWorldToProjection = prevViewToProjection * prevTranslatedWorldToView;

camera.translatedWorldOffset = viewToWorld[3].xyz();
camera.previousTranslatedWorldOffset = prevViewToWorld[3].xyz();
camera.translatedWorldOffset = Vector3{ viewToWorld[3].xyz() };
camera.previousTranslatedWorldOffset = Vector3{ prevViewToWorld[3].xyz() };
camera.nearPlane = m_context.nearPlane;
camera.flags = ((!m_context.isLHS) ? rightHandedFlag : 0);

Expand Down Expand Up @@ -832,10 +832,10 @@ namespace dxvk
}

Matrix4d viewRot = viewToWorld;
viewRot[3] = Vector4(0.0);
viewRot[3] = Vector4d(0.0);
viewRot *= getMatrixFromEulerAngles(shakePitch, shakeYaw);

Vector4 shakeOffset = static_cast<double>(moveLeftRight) * viewRot.data[0];
Vector4d shakeOffset = static_cast<double>(moveLeftRight) * viewRot.data[0];
shakeOffset += static_cast<double>(moveBackForward) * viewRot.data[2];

viewRot[3] = viewToWorld[3] + shakeOffset;
Expand Down
2 changes: 1 addition & 1 deletion src/dxvk/rtx_render/rtx_camera_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace dxvk {
return std::abs(fovA - cameraB.getFov()) < kFovToleranceRadians;
};

if (abs(shearX) > 0.01f || !isFovValid(fov)) {
if (std::abs(shearX) > 0.01f || !isFovValid(fov)) {
ONCE(Logger::warn("[RTX] CameraManager: rejected an invalid camera"));
return input.getCategoryFlags().test(InstanceCategories::Sky) ? CameraType::Sky : CameraType::Unknown;
}
Expand Down
25 changes: 13 additions & 12 deletions src/dxvk/rtx_render/rtx_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <cstring>
#include <cmath>
#include <cassert>
#include <array>

#include "dxvk_device.h"
#include "dxvk_scoped_annotation.h"
Expand Down Expand Up @@ -941,7 +942,7 @@ namespace dxvk {

if (debugView.gpuPrint.enable() && ImGui::IsKeyDown(ImGuiKey_ModCtrl)) {
if (debugView.gpuPrint.useMousePosition()) {
Vector2 toDownscaledExtentScale = {
Vector2 toDownscaledExtentScale{
downscaledExtent.width / static_cast<float>(targetExtent.width),
downscaledExtent.height / static_cast<float>(targetExtent.height)
};
Expand Down Expand Up @@ -1479,9 +1480,9 @@ namespace dxvk {
}

Vector2i rescale(const float(&scale)[2], const Vector2i& pix) {
return {
static_cast<int>(static_cast<float>(pix.x) * scale[0]),
static_cast<int>(static_cast<float>(pix.y) * scale[1]),
return Vector2i {
static_cast<int>(static_cast<float>(pix.x) * scale[0]),
static_cast<int>(static_cast<float>(pix.y) * scale[1]),
};
}

Expand Down Expand Up @@ -1878,16 +1879,16 @@ namespace dxvk {
}

void RtxContext::rasterizeToSkyProbe(const DrawParameters& params, const DrawCallState& drawCallState) {
static Vector3 targets[6] = {
{+1.0f, 0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f},
{0.0f, +1.0f, 0.0f}, {0.0f, -1.0f, 0.0f},
{0.0f, 0.0f, +1.0f}, {0.0f, 0.0f, -1.0f},
static std::array targets{
Vector3{+1.0f, 0.0f, 0.0f}, Vector3{-1.0f, 0.0f, 0.0f},
Vector3{0.0f, +1.0f, 0.0f}, Vector3{0.0f, -1.0f, 0.0f},
Vector3{0.0f, 0.0f, +1.0f}, Vector3{0.0f, 0.0f, -1.0f},
};

static Vector3 ups[6] = {
{0.0f, 1.0f, 0.0f}, {0.0f, 1.0f, 0.0f},
{0.0f, 0.0f,-1.0f}, {0.0f, 0.0f, 1.0f},
{0.0f, 1.0f, 0.0f}, {0.0f, 1.0f, 0.0f},
static std::array ups{
Vector3{0.0f, 1.0f, 0.0f}, Vector3{0.0f, 1.0f, 0.0f},
Vector3{0.0f, 0.0f,-1.0f}, Vector3{0.0f, 0.0f, 1.0f},
Vector3{0.0f, 1.0f, 0.0f}, Vector3{0.0f, 1.0f, 0.0f},
};

ScopedGpuProfileZone(this, "rasterizeToSkyProbe");
Expand Down
6 changes: 3 additions & 3 deletions src/dxvk/rtx_render/rtx_debug_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ namespace dxvk {
pseudoColorModeCombo.getKey(&pseudoColorModeObject());

ImGui::DragFloat("Scale", &m_scale, 0.01f, 0.0f, FLT_MAX, "%.3f", sliderFlags);
ImGui::InputFloat("Min Value", &minValueObject(), std::max(0.01f, 0.02f * abs(minValue())), std::max(0.1f, 0.1f * abs(minValue())));
ImGui::InputFloat("Max Value", &maxValueObject(), std::max(0.01f, 0.02f * abs(maxValue())), std::max(0.1f, 0.1f * abs(maxValue())));
ImGui::InputFloat("Min Value", &minValueObject(), std::max(0.01f, 0.02f * std::abs(minValue())), std::max(0.1f, 0.1f * std::abs(minValue())));
ImGui::InputFloat("Max Value", &maxValueObject(), std::max(0.01f, 0.02f * std::abs(maxValue())), std::max(0.1f, 0.1f * std::abs(maxValue())));
maxValueRef() = std::max(1.00001f * minValue(), maxValue());

// Color legend
Expand All @@ -500,7 +500,7 @@ namespace dxvk {
} else if (displayType() == DebugViewDisplayType::BGRExclusiveColor) {
ImGui::Text("BGR Exclusive Color:");

ImGui::InputFloat("Max Value", &maxValueObject(), std::max(0.01f, 0.02f * abs(maxValue())), std::max(0.1f, 0.1f * abs(maxValue())));
ImGui::InputFloat("Max Value", &maxValueObject(), std::max(0.01f, 0.02f * std::abs(maxValue())), std::max(0.1f, 0.1f * std::abs(maxValue())));
} else if (displayType() == DebugViewDisplayType::EV100) {
ImGui::Text("Exposure Value (EV100):");

Expand Down
8 changes: 4 additions & 4 deletions src/dxvk/rtx_render/rtx_game_capturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ namespace dxvk {
const auto viewToWorld = sceneCamera.getViewToWorld();
if (capCamera.proj.bInv) {
// Check if the up vector in view matrix is upside down
const Vector3& up = viewToWorld[1].xyz();
if ((!RtxOptions::Get()->isZUp() && dot(up, Vector3(0.0f, 1.0f, 0.0f)) < 0.0f) ||
(RtxOptions::Get()->isZUp() && dot(up, Vector3(0.0f, 0.0f, 1.0f)) < 0.0f)) {
const auto& up = viewToWorld[1].xyz();
if ((!RtxOptions::Get()->isZUp() && dot(up, Vector3d(0.0, 1.0, 0.0)) < 0.0) ||
(RtxOptions::Get()->isZUp() && dot(up, Vector3d(0.0, 0.0, 1.0)) < 0.0)) {
capCamera.view.bInv = true;
}
}
Expand Down Expand Up @@ -878,7 +878,7 @@ namespace dxvk {
// Create comparison function that returns float
static auto weightsDifferentEnough = [](const float& a, const float& b) {
const static float delta = RtxOptions::Get()->getCaptureMeshBlendWeightDelta();
return abs(a - b) > delta;
return std::abs(a - b) > delta;
};
// Cache buffer iff new buffer differs from previous buffer
evalNewBufferAndCache(pMesh, pMesh->lssData.buffers.blendWeightBufs, targetBuffer, currentFrameNum, weightsDifferentEnough);
Expand Down
14 changes: 7 additions & 7 deletions src/dxvk/rtx_render/rtx_instance_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,8 +1443,8 @@ namespace dxvk {
const float planeDistanceX = dot(dirToPortalCentroid, rayPortal.entryPortalInfo.planeBasis[0]);
const float planeDistanceY = dot(dirToPortalCentroid, rayPortal.entryPortalInfo.planeBasis[1]);
const bool cameraVolumeIntersectsPortal = 0.f < planeDistanceNormal && planeDistanceNormal < maximumNormalDistance
&& fabs(planeDistanceX) < rayPortal.entryPortalInfo.planeHalfExtents.x
&& fabs(planeDistanceY) < rayPortal.entryPortalInfo.planeHalfExtents.y;
&& std::abs(planeDistanceX) < rayPortal.entryPortalInfo.planeHalfExtents.x
&& std::abs(planeDistanceY) < rayPortal.entryPortalInfo.planeHalfExtents.y;

if (cameraVolumeIntersectsPortal) {
portalIndexForVirtualInstances = i;
Expand Down Expand Up @@ -1537,9 +1537,9 @@ namespace dxvk {
}

const Matrix4 backwardOffsetMatrix {
{ 1.f, 0.f, 0.f, 0.f },
{ 0.f, 1.f, 0.f, 0.f },
{ 0.f, 0.f, 1.f, 0.f },
Vector4{ 1.f, 0.f, 0.f, 0.f },
Vector4{ 0.f, 1.f, 0.f, 0.f },
Vector4{ 0.f, 0.f, 1.f, 0.f },
Vector4(backwardOffsetVector, 1.f)
};

Expand Down Expand Up @@ -1827,10 +1827,10 @@ namespace dxvk {
// - Must be roughly square
const bool isSquare = xLength <= yLength * 1.5f && yLength <= xLength * 1.5f;
// - The original quad must have perpendicular sides
const bool hasPerpendicularSides = fabs(dotAxes) < 0.01f;
const bool hasPerpendicularSides = std::abs(dotAxes) < 0.01f;
// - Must be in the camera view plane, i.e. only auto-oriented particles, not world-space ones
// (except player model particles, which are oriented towards the camera and not in the view plane)
const bool isInViewPlane = fabs(normalDotCamera) > 0.99f;
const bool isInViewPlane = std::abs(normalDotCamera) > 0.99f;
// Assume that all billboards on the player model are camera facing
const bool isCameraFacing = instance.m_isPlayerModel;
if (!isSquare || !hasPerpendicularSides || !isInViewPlane && !isCameraFacing) {
Expand Down
2 changes: 1 addition & 1 deletion src/dxvk/rtx_render/rtx_instance_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RtInstance {
const XXH64_hash_t calculateAntiCullingHash() const;
Matrix4 getTransform() const { return transpose(dxvk::Matrix4(m_vkInstance.transform)); }
const Matrix4& getPrevTransform() const { return surface.prevObjectToWorld; }
Vector3 getWorldPosition() const { return { m_vkInstance.transform.matrix[0][3], m_vkInstance.transform.matrix[1][3], m_vkInstance.transform.matrix[2][3] }; }
Vector3 getWorldPosition() const { return Vector3{ m_vkInstance.transform.matrix[0][3], m_vkInstance.transform.matrix[1][3], m_vkInstance.transform.matrix[2][3] }; }
const Vector3& getPrevWorldPosition() const { return surface.prevObjectToWorld.data[3].xyz(); }

const Vector3& getSpatialCachePosition() const { return m_spatialCachePos; }
Expand Down
20 changes: 11 additions & 9 deletions src/dxvk/rtx_render/rtx_intersection_test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
#pragma once

#include <array>

#include "MathLib/MathLib.h"
#include "../util/util_matrix.h"

Expand All @@ -32,7 +34,7 @@ static inline bool rayIntersectsPlane(
float* t) {

float denom = dot(n, d);
if (abs(denom) > 1e-6) {
if (std::abs(denom) > 1e-6f) {
*t = dot(p0 - s0, n) / denom;
return (*t >= 0);
}
Expand Down Expand Up @@ -150,12 +152,12 @@ static bool boundingBoxIntersectsFrustumSATInternal(
// Note: When the OBB has same coordinate value on 1 or more dimensions, it will become a plane/line/point.
// In such case, we still need to check the axis of the missing dimension(s).
// So, we just set the unit length axis to represent axis direction (normalized axis), then revert extent back to 0 after transformation.
const dxvk::Vector3 extentScale = {
const dxvk::Vector3 extentScale{
maxPos.x - minPos.x > FLT_EPSILON ? 0.5f : 0.0f,
maxPos.y - minPos.y > FLT_EPSILON ? 0.5f : 0.0f,
maxPos.z - minPos.z > FLT_EPSILON ? 0.5f : 0.0f
};
const dxvk::Vector4 obbAxisView[3] = {
const std::array obbAxisView{
objectToView * (extentScale.x != 0.0f ? dxvk::Vector4(maxPos.x - minPos.x, 0.0f, 0.0f, 0.0f) : dxvk::Vector4(1.0f, 0.0f, 0.0f, 0.0f)),
objectToView * (extentScale.y != 0.0f ? dxvk::Vector4(0.0f, maxPos.y - minPos.y, 0.0f, 0.0f) : dxvk::Vector4(0.0f, 1.0f, 0.0f, 0.0f)),
objectToView * (extentScale.z != 0.0f ? dxvk::Vector4(0.0f, 0.0f, maxPos.z - minPos.z, 0.0f) : dxvk::Vector4(0.0f, 0.0f, 1.0f, 0.0f))
Expand All @@ -164,26 +166,26 @@ static bool boundingBoxIntersectsFrustumSATInternal(

// Calculate the view space OBB extent.
// Note: We scale the extents here to avoid dividing 0.
const dxvk::Vector4 obbAxisNormalized[3] = {
const std::array obbAxisNormalized{
obbAxisView[0] / obbExtents.x * extentScale.x,
obbAxisView[1] / obbExtents.y * extentScale.y,
obbAxisView[2] / obbExtents.z * extentScale.z
};

// Project OBB extent to axis
auto calProjectedObbExtent = [&](const dxvk::Vector4& axis) -> float {
const dxvk::Vector4 projObbAxisToAxis(std::fabs(dxvk::dot(obbAxisNormalized[0], axis)),
std::fabs(dxvk::dot(obbAxisNormalized[1], axis)),
std::fabs(dxvk::dot(obbAxisNormalized[2], axis)),
const dxvk::Vector4 projObbAxisToAxis(std::abs(dxvk::dot(obbAxisNormalized[0], axis)),
std::abs(dxvk::dot(obbAxisNormalized[1], axis)),
std::abs(dxvk::dot(obbAxisNormalized[2], axis)),
0.0f);
return dxvk::dot(projObbAxisToAxis, obbExtents);
};

// Fast Frustum Projection Algorithm:
// https://www.geometrictools.com/Documentation/IntersectionBox3Frustum3.pdf
auto calProjectedFrustumExtent = [&](const dxvk::Vector4& axis, float& p0, float& p1) -> void {
const float MoX = std::fabs(axis.x);
const float MoY = std::fabs(axis.y);
const float MoX = std::abs(axis.x);
const float MoY = std::abs(axis.y);
const float MoZ = isLHS ? axis.z : -axis.z;

const float p = nearPlaneRightExtent * MoX + nearPlaneUpExtent * MoY;
Expand Down
2 changes: 1 addition & 1 deletion src/dxvk/rtx_render/rtx_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace dxvk {
}

const auto category = DxvkMemoryStats::Category::RTXBuffer;
const int64_t size = abs(memAdjustmentMB * 1024 * 1024) / 2;
const int64_t size = std::abs(memAdjustmentMB * 1024 * 1024) / 2;

auto& heaps = m_device->getCommon()->memoryManager().getMemoryHeaps();

Expand Down
2 changes: 1 addition & 1 deletion src/dxvk/rtx_render/rtx_light_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ namespace dxvk {
if (coneAngleDelta > 0.01f) {
return kNotSimilar;
}
float coneSoftnessDelta = abs(aShaping.getConeSoftness() - bShaping.getConeSoftness());
float coneSoftnessDelta = std::abs(aShaping.getConeSoftness() - bShaping.getConeSoftness());
if (coneSoftnessDelta > 0.01f) {
return kNotSimilar;
}
Expand Down
14 changes: 7 additions & 7 deletions src/dxvk/rtx_render/rtx_light_manager_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace dxvk {

bool transformToScreen(const Matrix4& worldToProj, const Vector2 screen, const Vector3 worldPos, ImVec2& outScreenPos) {
Vector4 positionPS = worldToProj * Vector4(worldPos.x, worldPos.y, worldPos.z, 1.f);
positionPS.xyz() /= abs(positionPS.w);
positionPS.xyz() /= std::abs(positionPS.w);

// Projection -> screen transform
outScreenPos = { (positionPS.x * 0.5f + 0.5f) * screen.x, (-positionPS.y * 0.5f + 0.5f) * screen.y };
Expand All @@ -204,7 +204,7 @@ namespace dxvk {
ImVec2 screenPos;
{
const ImGuiViewport* viewport = ImGui::GetMainViewport();
transformToScreen(worldToProj, { viewport->Size.x, viewport->Size.y }, position, screenPos);
transformToScreen(worldToProj, Vector2{ viewport->Size.x, viewport->Size.y }, position, screenPos);
}
std::string str = hashToString(h);
ImU32 backColor = IM_COL32(0, 0, 0, 200);
Expand Down Expand Up @@ -322,8 +322,8 @@ namespace dxvk {
}
ImVec2 screenPos[2];
const ImGuiViewport* viewport = ImGui::GetMainViewport();
transformToScreen(worldToProj, { viewport->Size.x, viewport->Size.y }, sphereLight.getPosition(), screenPos[0]);
transformToScreen(worldToProj, { viewport->Size.x, viewport->Size.y }, sphereLight.getPosition() + cameraRight * sphereLight.getRadius(), screenPos[1]);
transformToScreen(worldToProj, Vector2{ viewport->Size.x, viewport->Size.y }, sphereLight.getPosition(), screenPos[0]);
transformToScreen(worldToProj, Vector2{ viewport->Size.x, viewport->Size.y }, sphereLight.getPosition() + cameraRight * sphereLight.getRadius(), screenPos[1]);
const float radius = std::max(1.f, sqrtf(ImLengthSqr(ImVec2(screenPos[0].x - screenPos[1].x, screenPos[0].y - screenPos[1].y))));
drawList->AddCircleFilled(screenPos[0], radius, colHex);

Expand All @@ -345,7 +345,7 @@ namespace dxvk {
rectBounds[3] = position + dimensions.x * 0.5f * xAxis - dimensions.y * yAxis * 0.5f;
ImVec2 screenPos[4];
for (uint32_t i = 0; i < 4; i++) {
transformToScreen(worldToProj, { viewport->Size.x, viewport->Size.y }, rectBounds[i], screenPos[i]);
transformToScreen(worldToProj, Vector2{ viewport->Size.x, viewport->Size.y }, rectBounds[i], screenPos[i]);
}
drawList->AddQuadFilled(screenPos[0], screenPos[1], screenPos[2], screenPos[3], colHex);
return DrawResult {
Expand All @@ -364,7 +364,7 @@ namespace dxvk {
for (uint32_t i = 0; i < numPoints; i++) {
float theta = (float) i * kPi * 2 / numPoints;
Vector3 worldPos = position + radius.x * cos(theta) * xAxis + radius.y * yAxis * sin(theta);
transformToScreen(worldToProj, { viewport->Size.x, viewport->Size.y }, worldPos, screenPos[i]);
transformToScreen(worldToProj, Vector2{ viewport->Size.x, viewport->Size.y }, worldPos, screenPos[i]);
}
drawList->AddConvexPolyFilled(&screenPos[0], numPoints, colHex);

Expand Down Expand Up @@ -434,7 +434,7 @@ namespace dxvk {
switch (light->getType()) {
case RtLightType::Sphere:
{
result = drawSphereLightDebug(light->getSphereLight(), worldToProj, camera.getViewToWorld(true)[0].xyz(), colHex, frustum, drawList);
result = drawSphereLightDebug(light->getSphereLight(), worldToProj, Vector3{ camera.getViewToWorld(true)[0].xyz() }, colHex, frustum, drawList);
break;
}
case RtLightType::Rect:
Expand Down
8 changes: 4 additions & 4 deletions src/dxvk/rtx_render/rtx_light_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,17 @@ Matrix4 LightUtils::getLightTransform(const D3DLIGHT9& light) {
switch (light.Type) {
case D3DLIGHT_SPOT:
{
const Vector3 zAxis = safeNormalize({ light.Direction.x, light.Direction.y, light.Direction.z }, Vector3(0.0f, 0.0f, 1.0f));
return Matrix4(getOrientation(Vector3(0.f, 0.f, -1.f), zAxis), { light.Position.x, light.Position.y, light.Position.z });
const Vector3 zAxis = safeNormalize(Vector3{ light.Direction.x, light.Direction.y, light.Direction.z }, Vector3(0.0f, 0.0f, 1.0f));
return Matrix4(getOrientation(Vector3(0.f, 0.f, -1.f), zAxis), Vector3{ light.Position.x, light.Position.y, light.Position.z });
}
case D3DLIGHT_POINT:
{
return Matrix4(Vector3(light.Position.x, light.Position.y, light.Position.z));
}
case D3DLIGHT_DIRECTIONAL:
{
const Vector3 zAxis = safeNormalize({ light.Direction.x, light.Direction.y, light.Direction.z }, Vector3(0.0f, 0.0f, 1.0f));
return Matrix4(getOrientation(Vector3(0.f, 0.f, -1.f), zAxis), Vector3(0.f));
const Vector3 zAxis = safeNormalize(Vector3{ light.Direction.x, light.Direction.y, light.Direction.z }, Vector3(0.0f, 0.0f, 1.0f));
return Matrix4(getOrientation(Vector3(0.f, 0.f, -1.f), zAxis), Vector3{ 0.0f });
}
default:
return Matrix4();
Expand Down

0 comments on commit 7e24a52

Please sign in to comment.