Fix minimap arrow orientation and ground-detail foliage transparency

This commit is contained in:
Kelsi 2026-02-22 08:44:16 -08:00
parent 0631b9f5dc
commit 8efc1548dc
5 changed files with 45 additions and 91 deletions

View file

@ -2301,7 +2301,8 @@ void M2Renderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const
effectiveBlendMode = 3;
}
if (model.isGroundDetail) {
effectiveBlendMode = 2;
// Treat foliage cards as cutout so they depth-sort correctly.
effectiveBlendMode = 1;
}
VkPipeline desiredPipeline;
@ -2329,9 +2330,9 @@ void M2Renderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const
if (batch.colorKeyBlack) {
mat->colorKeyThreshold = (effectiveBlendMode == 4 || effectiveBlendMode == 5) ? 0.7f : 0.08f;
}
// Ground detail: override alphaTest and unlit
// Ground detail: force cutout shading for stable two-sided foliage.
if (model.isGroundDetail) {
mat->alphaTest = 0;
mat->alphaTest = 1;
mat->unlit = 0;
}
}

View file

@ -472,7 +472,8 @@ void Minimap::compositePass(VkCommandBuffer cmd, const glm::vec3& centerWorldPos
void Minimap::render(VkCommandBuffer cmd, const Camera& playerCamera,
const glm::vec3& centerWorldPos,
int screenWidth, int screenHeight) {
int screenWidth, int screenHeight,
float playerOrientation, bool hasPlayerOrientation) {
if (!enabled || !hasCachedFrame || !displayPipeline) return;
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, displayPipeline);
@ -511,8 +512,15 @@ void Minimap::render(VkCommandBuffer cmd, const Camera& playerCamera,
float arrowRotation = 0.0f;
if (!rotateWithCamera) {
glm::vec3 fwd = playerCamera.getForward();
arrowRotation = std::atan2(-fwd.x, fwd.y);
// Prefer authoritative player orientation for north-up minimap arrow.
// Canonical yaw already matches minimap rotation convention:
// 0=north, +pi/2=east.
if (hasPlayerOrientation) {
arrowRotation = playerOrientation;
} else {
glm::vec3 fwd = playerCamera.getForward();
arrowRotation = std::atan2(-fwd.x, fwd.y);
}
}
MinimapDisplayPush push{};

View file

@ -3183,8 +3183,15 @@ void Renderer::renderWorld(game::World* world, game::GameHandler* gameHandler) {
glm::vec3 minimapCenter = camera->getPosition();
if (cameraController && cameraController->isThirdPerson())
minimapCenter = characterPosition;
float minimapPlayerOrientation = 0.0f;
bool hasMinimapPlayerOrientation = false;
if (gameHandler) {
minimapPlayerOrientation = gameHandler->getMovementInfo().orientation;
hasMinimapPlayerOrientation = true;
}
minimap->render(currentCmd, *camera, minimapCenter,
window->getWidth(), window->getHeight());
window->getWidth(), window->getHeight(),
minimapPlayerOrientation, hasMinimapPlayerOrientation);
}
auto renderEnd = std::chrono::steady_clock::now();