Снятие колес работает, покраска тоже более менее. Физика просто говно щяс
This commit is contained in:
1 parent
d4c84b10df
commit
2ce853999d
67 files changed
+155919
-1996
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user