Clamp lighting value on export to fix flat colors

Also, this fixes the Printf format for the ambient lighting entry on the
configuration screen.  This was causing string behavior when attempting
to edit the ambient lighting value on Windows.  Oddly this didn't seem
to affect Linux.
pull/991/head
robnee 2021-04-01 20:52:03 -04:00 committed by phkahler
parent 2df786e741
commit 2e88c5e0da
2 changed files with 3 additions and 5 deletions

View File

@ -236,9 +236,7 @@ void TextWindow::ShowConfiguration() {
CO(SS.lightDir[i]), i, &ScreenChangeLightDirection, CO(SS.lightDir[i]), i, &ScreenChangeLightDirection,
SS.lightIntensity[i], i, &ScreenChangeLightIntensity); SS.lightIntensity[i], i, &ScreenChangeLightIntensity);
} }
Printf(false, "%Bp ambient lighting " Printf(false, "%Ba ambient lighting %2 %Fl%f%Ll[c]%E",
"%2 %Fl%D%f%Ll[c]%E",
(i & 1) ? 'd' : 'a', i,
SS.ambientIntensity, &ScreenChangeLightAmbient); SS.ambientIntensity, &ScreenChangeLightAmbient);
Printf(false, ""); Printf(false, "");

View File

@ -366,9 +366,9 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s
// And calculate lighting for the triangle // And calculate lighting for the triangle
Vector n = tt.Normal().WithMagnitude(1); Vector n = tt.Normal().WithMagnitude(1);
double lighting = SS.ambientIntensity + double lighting = min(1.0, SS.ambientIntensity +
max(0.0, (SS.lightIntensity[0])*(n.Dot(l0))) + max(0.0, (SS.lightIntensity[0])*(n.Dot(l0))) +
max(0.0, (SS.lightIntensity[1])*(n.Dot(l1))); max(0.0, (SS.lightIntensity[1])*(n.Dot(l1))));
double r = min(1.0, tt.meta.color.redF() * lighting), double r = min(1.0, tt.meta.color.redF() * lighting),
g = min(1.0, tt.meta.color.greenF() * lighting), g = min(1.0, tt.meta.color.greenF() * lighting),
b = min(1.0, tt.meta.color.blueF() * lighting); b = min(1.0, tt.meta.color.blueF() * lighting);