Снятие колес работает, покраска тоже более менее. Физика просто говно щяс

This commit is contained in:
bybohka committed 2026-10-20 17:54:31 +03:00
1 parent d4c84b10df
commit 2ce853999d
67 files changed
+155919 -1996

No files matched your search

+8 -8
View File
@@ -421,10 +421,10 @@
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1146.0,
"x": 1146.9998779296875,
"y": 714.9999389648438,
"width": 254.9998779296875,
"height": 286.0
"width": 255.0,
"height": 309.99993896484375
}
},
"m_Slots": [
@@ -476,11 +476,11 @@
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 0,
"m_SourceType": 1,
"m_FunctionName": "RepairSurface",
"m_FunctionSource": "8406d757d93120545ba59c440d9e5031",
"m_FunctionSourceUsePragmas": true,
"m_FunctionBody": "Enter function body here..."
"m_FunctionBody": "float e = 0.04;\nfloat3 bareMetal = float3(0.55, 0.56, 0.58);\nfloat3 puttyRaw = float3(0.62, 0.58, 0.50);\nfloat3 puttySanded = float3(0.74, 0.72, 0.68);\n\nif (RustInitial <= 0.001)\n{\n Albedo = BaseColor;\n Metallic = 0.0;\n Smoothness = PaintSmoothness;\n}\nelse\n{\n float sand = saturate(SandProgress);\n float zone = smoothstep(1.0 - RustInitial, 1.0 - RustInitial + e, N);\n\n float fillEdge = 1.0 - saturate(PuttyProgress) * (RustInitial + e);\n float puttyMask = smoothstep(fillEdge + e, fillEdge, N) * step(0.001, PuttyProgress);\n if (PuttyProgress >= 0.98) puttyMask = 1.0;\n\n float3 underColor = lerp(bareMetal, lerp(puttyRaw, puttySanded, sand), puttyMask);\n float underSmooth = lerp(0.45, lerp(0.05, 0.35, sand), puttyMask);\n float underMetal = lerp(0.8, 0.0, puttyMask);\n\n float paintEdge = (1.0 - RustInitial) + saturate(PaintProgress) * (RustInitial + e);\n float paintMask = (1.0 - smoothstep(paintEdge, paintEdge + e, N)) * step(0.001, PaintProgress);\n if (PaintProgress >= 0.98) paintMask = 1.0;\n\n float damageVisible = zone * (1.0 - paintMask);\n float rust = zone * smoothstep(1.0 - RustAmount, 1.0 - RustAmount + e, N) * step(0.001, RustAmount);\n\n float3 col = lerp(BaseColor, underColor, damageVisible);\n float sm = lerp(PaintSmoothness, underSmooth, damageVisible);\n float met = lerp(0.0, underMetal, damageVisible);\n\n Albedo = lerp(col, RustColor, rust);\n Smoothness = lerp(sm, 0.08, rust);\n Metallic = lerp(met, 0.0, rust);\n}\n"
}
{
@@ -1504,10 +1504,10 @@
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 848.0,
"y": 1137.0,
"x": 655.9999389648438,
"y": 1179.0,
"width": 166.0,
"height": 34.0
"height": 33.9998779296875
}
},
"m_Slots": [
+24 -25
View File
@@ -1,7 +1,6 @@
#ifndef REPAIR_SURFACE_INCLUDED
#define REPAIR_SURFACE_INCLUDED
// Исправленная послойная модель реставрации кузова без артефактов на границах
void RepairSurface_float(
float N,
float3 BaseColor,
@@ -16,46 +15,50 @@ void RepairSurface_float(
out float Metallic,
out float Smoothness)
{
const float e = 0.04; // мягкость перехода
const float e = 0.04;
const float3 bareMetal = float3(0.55, 0.56, 0.58);
const float3 puttyRaw = float3(0.62, 0.58, 0.50);
const float3 puttySanded = float3(0.72, 0.70, 0.66);
const float3 puttySanded = float3(0.74, 0.72, 0.68);
// Если деталь целая (RustInitial = 0) — сразу возвращаем чистый родной цвет авто
if (RustInitial <= 0.001)
{
Albedo = BaseColor;
Metallic = 0.0;
Smoothness = PaintSmoothness;
return;
}
float sand = saturate(SandProgress);
// 1. Исходная зона повреждения детали (0..1)
float zone = smoothstep(1.0 - RustInitial, 1.0 - RustInitial + e, N) * step(0.001, RustInitial);
// 1. Исходная зона повреждения
float zone = smoothstep(1.0 - RustInitial, 1.0 - RustInitial + e, N);
// 2. Маска шпаклёвки (наносится поверх голого металла)
float fillEdge = 1.0 - PuttyProgress * (RustInitial + e);
// 2. Шпаклевка (заполняет зачищенный металл от центра к краям)
float fillEdge = 1.0 - saturate(PuttyProgress) * (RustInitial + e);
float puttyMask = smoothstep(fillEdge + e, fillEdge, N) * step(0.001, PuttyProgress);
if (PuttyProgress >= 0.99) puttyMask = 1.0;
if (PuttyProgress >= 0.98) puttyMask = 1.0;
// Свойства подложки (голый металл или шпаклёвка)
float3 underColor = lerp(bareMetal, lerp(puttyRaw, puttySanded, sand), puttyMask);
float underSmooth = lerp(0.45, lerp(0.05, 0.35, sand), puttyMask);
float underMetal = lerp(0.8, 0.0, puttyMask);
// 3. Маска нанесения новой краски (растёт от краёв зоны внутрь)
float paintEdge = (1.0 - RustInitial) + PaintProgress * (RustInitial + e);
// 3. Новая краска (закрывает зашлифованную шпаклевку без белых контуров)
float paintEdge = (1.0 - RustInitial) + saturate(PaintProgress) * (RustInitial + e);
float paintMask = (1.0 - smoothstep(paintEdge, paintEdge + e, N)) * step(0.001, PaintProgress);
if (PaintProgress >= 0.99) paintMask = 1.0;
if (PaintProgress >= 0.98) paintMask = 1.0;
// ВАЖНО: Доля повреждения, которая ЕЩЁ видна (не перекрыта краской).
// При завершении покраски (paintMask = 1) это значение строго равно 0 даже на полутонах!
float damageVisible = zone * (1.0 - paintMask);
// 4. Очаги ржавчины (лежат поверх всего, пока не счищены)
float rust = smoothstep(1.0 - RustAmount, 1.0 - RustAmount + e, N) * step(0.001, RustAmount);
// 4. Текущий остаток ржавчины
float rust = zone * smoothstep(1.0 - RustAmount, 1.0 - RustAmount + e, N) * step(0.001, RustAmount);
// Смешиваем заводскую краску с повреждением
float3 col = lerp(BaseColor, underColor, damageVisible);
float sm = lerp(PaintSmoothness, underSmooth, damageVisible);
float met = lerp(0.0, underMetal, damageVisible);
// Поверх накладываем оставшуюся ржавчину
col = lerp(col, RustColor, rust);
sm = lerp(sm, 0.1, rust);
sm = lerp(sm, 0.08, rust);
met = lerp(met, 0.0, rust);
Albedo = col;
@@ -77,14 +80,10 @@ void RepairSurface_half(
out half Metallic,
out half Smoothness)
{
float3 a;
float m;
float s;
float3 a; float m; float s;
RepairSurface_float(N, BaseColor, RustColor, RustInitial, RustAmount,
PuttyProgress, SandProgress, PaintProgress, PaintSmoothness, a, m, s);
Albedo = a;
Metallic = m;
Smoothness = s;
Albedo = a; Metallic = m; Smoothness = s;
}
#endif