mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 07:22:42 +01:00
Windscreen snow: compiles with the NVIDIA OpenGL driver, the state of the glasses in the log [skip ci]
- water_snow.comp named a variable "packed", a reserved word of GLSL: the NVIDIA OpenGL compiler refused the program, so the whole simulation of the windscreens was off under OpenGL. Now "packing". - mat_snow_windscreen.frag: a material without its slot takes the first glass whose snow the simulation keeps. - The log says, once it changes, whether each glass is baked, what it was built as and what its material is now, whether its snow is simulated, and whether the layer of the snow is laid: to find why the snow stays off under OpenGL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
This commit is contained in:
@@ -127,6 +127,8 @@ void windscreen_water::release()
|
||||
m_glasses = {};
|
||||
m_glasscount = 0;
|
||||
m_layerslot = -1;
|
||||
m_logged.fill(-1);
|
||||
m_layerlogged = -1;
|
||||
m_kinds.clear();
|
||||
m_vehicle = nullptr;
|
||||
m_cab = nullptr;
|
||||
@@ -460,6 +462,14 @@ void windscreen_water::update(double const Seconds)
|
||||
auto const *material{m_host.material(glass.material)};
|
||||
auto const snowed{glass.baked && glass.snow && is_snow_glass(material)};
|
||||
block.snow_slots[static_cast<glm::length_t>(slot)] = (snowed ? 1.f : 0.f);
|
||||
// the state of the glass in the log once it changes: why a glass stays without its water or snow
|
||||
if (auto const state{(glass.baked ? 1 : 0) | (glass.snow ? 2 : 0) | (glass_kind(material) << 2) | (snowed ? 16 : 0)}; state != m_logged[slot])
|
||||
{
|
||||
m_logged[slot] = state;
|
||||
WriteLog("windscreen water: glass " + std::to_string(slot + 1) + (glass.baked ? " baked" : " not baked yet (the mask of the wipers not loaded)") +
|
||||
(glass.snow ? ", built as a glass of the snow" : ", built as a glass of the water") + ", its material now " +
|
||||
std::to_string(glass_kind(material)) + " (0 none, 1 water, 2 snow)" + (snowed ? ", its snow simulated" : ""));
|
||||
}
|
||||
anysnow = anysnow || snowed;
|
||||
auto const simulated{glass.baked && (false == glass.snow) && is_water_glass(material)};
|
||||
glass.landings += static_cast<double>(perground / fall * coming * glass.densest) * seconds;
|
||||
@@ -573,7 +583,12 @@ void windscreen_water::lay_snow(gl::water_ubs const &Block)
|
||||
auto layer{Block};
|
||||
layer.counts.z = static_cast<std::uint32_t>(slot);
|
||||
layer.counts.w = m_step;
|
||||
gpu_snow_layer(slot, atlas, normal, layer);
|
||||
auto const laid{gpu_snow_layer(slot, atlas, normal, layer)};
|
||||
if (int const state{laid ? 1 : 0}; state != m_layerlogged)
|
||||
{
|
||||
m_layerlogged = state;
|
||||
WriteLog("windscreen water: the layer of the snow of glass " + std::to_string(slot + 1) + (laid ? " laid" : " not laid (the atlas of the snow not loaded)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,8 @@ class windscreen_water
|
||||
std::array<glass, gl::WATER_SLOTS> m_glasses{};
|
||||
std::size_t m_glasscount{0};
|
||||
int m_layerslot{-1}; // the glass with the layer of the snow, -1 none
|
||||
std::array<int, gl::WATER_SLOTS> m_logged{-1, -1, -1, -1}; // what the log last said of each glass (baked, snow, the shader, simulated)
|
||||
int m_layerlogged{-1}; // what the log last said of the layer of the snow
|
||||
glm::vec4 m_bladesbefore{-1.f};
|
||||
double m_time{0.0}; // seconds the simulation runs
|
||||
std::uint32_t m_step{0};
|
||||
|
||||
@@ -95,6 +95,13 @@ void main()
|
||||
float snowTr = 0.0;
|
||||
float wet = 0.0;
|
||||
snSlot = int(param[2].z + 0.5) - 1;
|
||||
// the material without its slot (the opengl renderer may give the glass a fresh copy of the material after the weather
|
||||
// changed, without it): the first glass whose snow the simulation keeps
|
||||
for (int s = 0; (snSlot < 0) && (s < WATER_SLOTS); ++s)
|
||||
{
|
||||
if (water_header[s].z > 0.5)
|
||||
snSlot = s;
|
||||
}
|
||||
if ((snSlot >= 0) && (snSlot < WATER_SLOTS) && water_snow_map(uint(snSlot), snMap))
|
||||
{
|
||||
// the sprites coming within the texel of the layer at the pixel (water_snowlayer.comp) laid at the pixel, sharp from the
|
||||
|
||||
@@ -218,7 +218,7 @@ vec4 snow_move(ivec2 texel, vec4 state, float seconds)
|
||||
vec2 waterout = snow_out(motion.zw, seconds);
|
||||
float snow = state.x * (1.0 - snowout.x - snowout.y);
|
||||
float water = state.y * (1.0 - waterout.x - waterout.y);
|
||||
float packed = state.z * snow;
|
||||
float packing = state.z * snow; // (not "packed": a reserved word of GLSL, the NVIDIA OpenGL compiler refuses it)
|
||||
const ivec2 sides[4] = ivec2[4](ivec2(1, 0), ivec2(-1, 0), ivec2(0, 1), ivec2(0, -1));
|
||||
for (int k = 0; k < 4; ++k)
|
||||
{
|
||||
@@ -244,10 +244,10 @@ vec4 snow_move(ivec2 texel, vec4 state, float seconds)
|
||||
water += (itsmotion.w * float(side.y) < 0.0) ? neighbour.y * itswater.y : 0.0;
|
||||
}
|
||||
snow += coming;
|
||||
packed += coming * neighbour.z;
|
||||
packing += coming * neighbour.z;
|
||||
}
|
||||
snow = max(snow, 0.0);
|
||||
return vec4(snow, max(water, 0.0), (snow > 1e-4) ? clamp(packed / snow, 0.0, 1.0) : 0.0, state.w);
|
||||
return vec4(snow, max(water, 0.0), (snow > 1e-4) ? clamp(packing / snow, 0.0, 1.0) : 0.0, state.w);
|
||||
}
|
||||
|
||||
void main()
|
||||
|
||||
@@ -100,6 +100,13 @@ void main()
|
||||
float snowTr = 0.0;
|
||||
float wet = 0.0;
|
||||
snSlot = int(param[2].z + 0.5) - 1;
|
||||
// the material without its slot (the opengl renderer may give the glass a fresh copy of the material after the weather
|
||||
// changed, without it): the first glass whose snow the simulation keeps
|
||||
for (int s = 0; (snSlot < 0) && (s < WATER_SLOTS); ++s)
|
||||
{
|
||||
if (water_header[s].z > 0.5)
|
||||
snSlot = s;
|
||||
}
|
||||
if ((snSlot >= 0) && (snSlot < WATER_SLOTS) && water_snow_map(uint(snSlot), snMap))
|
||||
{
|
||||
// the sprites coming within the texel of the layer at the pixel (water_snowlayer.comp) laid at the pixel, sharp from the
|
||||
|
||||
@@ -221,7 +221,7 @@ vec4 snow_move(ivec2 texel, vec4 state, float seconds)
|
||||
vec2 waterout = snow_out(motion.zw, seconds);
|
||||
float snow = state.x * (1.0 - snowout.x - snowout.y);
|
||||
float water = state.y * (1.0 - waterout.x - waterout.y);
|
||||
float packed = state.z * snow;
|
||||
float packing = state.z * snow; // (not "packed": a reserved word of GLSL, the NVIDIA OpenGL compiler refuses it)
|
||||
const ivec2 sides[4] = ivec2[4](ivec2(1, 0), ivec2(-1, 0), ivec2(0, 1), ivec2(0, -1));
|
||||
for (int k = 0; k < 4; ++k)
|
||||
{
|
||||
@@ -247,10 +247,10 @@ vec4 snow_move(ivec2 texel, vec4 state, float seconds)
|
||||
water += (itsmotion.w * float(side.y) < 0.0) ? neighbour.y * itswater.y : 0.0;
|
||||
}
|
||||
snow += coming;
|
||||
packed += coming * neighbour.z;
|
||||
packing += coming * neighbour.z;
|
||||
}
|
||||
snow = max(snow, 0.0);
|
||||
return vec4(snow, max(water, 0.0), (snow > 1e-4) ? clamp(packed / snow, 0.0, 1.0) : 0.0, state.w);
|
||||
return vec4(snow, max(water, 0.0), (snow > 1e-4) ? clamp(packing / snow, 0.0, 1.0) : 0.0, state.w);
|
||||
}
|
||||
|
||||
void main()
|
||||
|
||||
Reference in New Issue
Block a user