tweak dump image settings for better viz of grid cells

This commit is contained in:
Steve Plimpton
2022-12-14 15:41:01 -07:00
parent 3fea762e30
commit 4efe379b7b
3 changed files with 35 additions and 7 deletions

View File

@ -921,6 +921,14 @@ void DumpImage::create_image()
// for 3d, outward normals on all 6 faces // for 3d, outward normals on all 6 faces
if (gridflag) { if (gridflag) {
// reset lighting for flat surfaces to make them brighter
image->ambientColor[0] = image->ambientColor[1] = image->ambientColor[2] = 0.9;
image->keyLightColor[0] = image->keyLightColor[1] = image->keyLightColor[2] = 0.3;
image->fillLightColor[0] = image->fillLightColor[1] = image->fillLightColor[2] = 0.3;
image->backLightColor[0] = image->backLightColor[1] = image->backLightColor[2] = 0.3;
int n = 0; int n = 0;
if (domain->dimension == 2) { if (domain->dimension == 2) {
for (int iy = nylo_in; iy <= nyhi_in; iy++) for (int iy = nylo_in; iy <= nyhi_in; iy++)
@ -956,6 +964,13 @@ void DumpImage::create_image()
image->draw_triangle(gcorners[4],gcorners[7],gcorners[6],color); image->draw_triangle(gcorners[4],gcorners[7],gcorners[6],color);
} }
} }
// restore lighting for curved objects
image->ambientColor[0] = image->ambientColor[1] = image->ambientColor[2] = 0.0;
image->keyLightColor[0] = image->keyLightColor[1] = image->keyLightColor[2] = 0.9;
image->fillLightColor[0] = image->fillLightColor[1] = image->fillLightColor[2] = 0.45;
image->backLightColor[0] = image->backLightColor[1] = image->backLightColor[2] = 0.9;
} }
// render atoms that are lines // render atoms that are lines

View File

@ -815,26 +815,34 @@ void Image::draw_triangle(double *x, double *y, double *z, double *surfaceColor)
double s1[3], s2[3], s3[3]; double s1[3], s2[3], s3[3];
double c1[3], c2[3]; double c1[3], c2[3];
// for grid cell viz:
// using <= if test can leave single-pixel gaps between 2 tris
// using < if test fixes it
// suggested by Nathan Fabian, Nov 2022
MathExtra::sub3 (zlocal, xlocal, s1); MathExtra::sub3 (zlocal, xlocal, s1);
MathExtra::sub3 (ylocal, xlocal, s2); MathExtra::sub3 (ylocal, xlocal, s2);
MathExtra::sub3 (p, xlocal, s3); MathExtra::sub3 (p, xlocal, s3);
MathExtra::cross3 (s1, s2, c1); MathExtra::cross3 (s1, s2, c1);
MathExtra::cross3 (s1, s3, c2); MathExtra::cross3 (s1, s3, c2);
if (MathExtra::dot3 (c1, c2) <= 0) continue; if (MathExtra::dot3 (c1, c2) < 0) continue;
//if (MathExtra::dot3 (c1, c2) <= 0) continue;
MathExtra::sub3 (xlocal, ylocal, s1); MathExtra::sub3 (xlocal, ylocal, s1);
MathExtra::sub3 (zlocal, ylocal, s2); MathExtra::sub3 (zlocal, ylocal, s2);
MathExtra::sub3 (p, ylocal, s3); MathExtra::sub3 (p, ylocal, s3);
MathExtra::cross3 (s1, s2, c1); MathExtra::cross3 (s1, s2, c1);
MathExtra::cross3 (s1, s3, c2); MathExtra::cross3 (s1, s3, c2);
if (MathExtra::dot3 (c1, c2) <= 0) continue; if (MathExtra::dot3 (c1, c2) < 0) continue;
//if (MathExtra::dot3 (c1, c2) <= 0) continue;
MathExtra::sub3 (ylocal, zlocal, s1); MathExtra::sub3 (ylocal, zlocal, s1);
MathExtra::sub3 (xlocal, zlocal, s2); MathExtra::sub3 (xlocal, zlocal, s2);
MathExtra::sub3 (p, zlocal, s3); MathExtra::sub3 (p, zlocal, s3);
MathExtra::cross3 (s1, s2, c1); MathExtra::cross3 (s1, s2, c1);
MathExtra::cross3 (s1, s3, c2); MathExtra::cross3 (s1, s3, c2);
if (MathExtra::dot3 (c1, c2) <= 0) continue; if (MathExtra::dot3 (c1, c2) < 0) continue;
//if (MathExtra::dot3 (c1, c2) <= 0) continue;
double cNormal[3]; double cNormal[3];
cNormal[0] = MathExtra::dot3(camRight, normal); cNormal[0] = MathExtra::dot3(camRight, normal);

View File

@ -34,6 +34,11 @@ class Image : protected Pointers {
double *boxcolor; // color to draw box outline with double *boxcolor; // color to draw box outline with
int background[3]; // RGB values of background int background[3]; // RGB values of background
double ambientColor[3]; // light color settings (adjustable by caller)
double keyLightColor[3];
double fillLightColor[3];
double backLightColor[3];
Image(class LAMMPS *, int); Image(class LAMMPS *, int);
~Image() override; ~Image() override;
void buffers(); void buffers();
@ -80,19 +85,19 @@ class Image : protected Pointers {
// constant view params // constant view params
double FOV; double FOV;
double ambientColor[3]; //double ambientColor[3];
double keyLightTheta; double keyLightTheta;
double keyLightPhi; double keyLightPhi;
double keyLightColor[3]; //double keyLightColor[3];
double fillLightTheta; double fillLightTheta;
double fillLightPhi; double fillLightPhi;
double fillLightColor[3]; //double fillLightColor[3];
double backLightTheta; double backLightTheta;
double backLightPhi; double backLightPhi;
double backLightColor[3]; //double backLightColor[3];
double specularHardness; double specularHardness;
double specularIntensity; double specularIntensity;