Decal screen space is now projection based.

This commit is contained in:
Justin Marshall
2026-05-22 09:26:03 -07:00
parent aefe08a1fc
commit 373b0cb253
5 changed files with 40 additions and 23 deletions
+11 -7
View File
@@ -1980,18 +1980,22 @@ static bool CamWnd_BuildDecalAtPoint(CCamWnd* cam, const CPoint& point, renderWo
}
CamWnd_DecalColorFromSelectedMaterial(decal.material, decal.color);
decal.origin = hitPoint;
decal.normal = hitNormal;
if ((decal.normal * dir) > 0.0f) {
decal.normal = -decal.normal;
}
decal.axisU = decal.normal.Cross(cam->Camera().vup);
decal.normal = -dir;
decal.normal.Normalize();
decal.axisU = cam->Camera().vright - decal.normal * (cam->Camera().vright * decal.normal);
if (decal.axisU.LengthSqr() < 0.0001f) {
decal.axisU = decal.normal.Cross(cam->Camera().vright);
decal.axisU = decal.normal.Cross(cam->Camera().vup);
}
decal.axisU.Normalize();
decal.axisV = decal.normal.Cross(decal.axisU);
CamWnd_RotateDecalBasis(decal, s_camWndDecalPreviewRotation);
decal.size = CamWnd_DecalFloat("size", "64");
decal.depth = CamWnd_DecalFloat("depth", "8");
decal.depth = CamWnd_DecalFloat("depth", "0");
const float minProjectorDepth = decal.size * 2.0f;
if (decal.depth < minProjectorDepth) {
decal.depth = minProjectorDepth;
}
decal.opacity = CamWnd_DecalFloat("opacity", "1");
if (hitSource) {
*hitSource = localHitSource;
+7 -1
View File
@@ -109,8 +109,12 @@ static void Map_NormalizeDecal(renderWorldDecal_t& decal) {
if (decal.size <= 0.0f) {
decal.size = 64.0f;
}
const float minProjectorDepth = decal.size * 2.0f;
if (decal.depth <= 0.0f) {
decal.depth = 8.0f;
decal.depth = minProjectorDepth;
}
else if (decal.depth < minProjectorDepth) {
decal.depth = minProjectorDepth;
}
if (decal.opacity <= 0.0f) {
decal.opacity = 1.0f;
@@ -346,6 +350,7 @@ void Map_LoadDecals(const char* filename) {
if (!token.Icmp("material")) {
src.ExpectAnyToken(&token);
decal.material = token;
Texture_ForName(decal.material.c_str());
} else if (!token.Icmp("origin")) {
src.Parse1DMatrix(3, decal.origin.ToFloatPtr());
} else if (!token.Icmp("normal")) {
@@ -364,6 +369,7 @@ void Map_LoadDecals(const char* filename) {
src.Parse1DMatrix(4, decal.color.ToFloatPtr());
}
}
Texture_ForName(decal.material.c_str());
Map_AddDecal(decal);
}
s_selectedWorldDecal = -1;
+9
View File
@@ -757,6 +757,15 @@ void Texture_ShowInuse(void) {
}
}
if (g_qeglobals.rw) {
for (int i = 0; i < g_qeglobals.rw->NumWorldDecals(); ++i) {
const renderWorldDecal_t* decal = g_qeglobals.rw->GetWorldDecal(i);
if (decal) {
Texture_ForName(decal->material.c_str());
}
}
}
Sys_UpdateWindows(W_TEXTURE);
g_Inspectors->SetWindowText("Textures (in use)");