From 5528cefe0f5741893262258ac7d23e137a00ce55 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Aug 2023 19:57:46 -0400 Subject: [PATCH] move fsaa keyword next to ssao and away from dump_modify we don't need to reallocate the buffers this way --- doc/src/dump_image.rst | 51 +++++++++--------- doc/utils/sphinx-config/false_positives.txt | 1 + src/dump_image.cpp | 58 +++++++++------------ 3 files changed, 51 insertions(+), 59 deletions(-) diff --git a/doc/src/dump_image.rst b/doc/src/dump_image.rst index 4eaff739d2..6e0f28af74 100644 --- a/doc/src/dump_image.rst +++ b/doc/src/dump_image.rst @@ -24,7 +24,7 @@ Syntax * color = atom attribute that determines color of each atom * diameter = atom attribute that determines size of each atom * zero or more keyword/value pairs may be appended -* keyword = *atom* or *adiam* or *bond* or *grid* or *line* or *tri* or *body* or *fix* or *size* or *view* or *center* or *up* or *zoom* or *box* or *axes* or *subbox* or *shiny* or *ssao* +* keyword = *atom* or *adiam* or *bond* or *grid* or *line* or *tri* or *body* or *fix* or *size* or *view* or *center* or *up* or *zoom* or *box* or *axes* or *subbox* or *shiny* or *fsaa* or *ssao* .. parsed-literal:: @@ -85,6 +85,8 @@ Syntax diam = diameter of subdomain lines as fraction of shortest box length *shiny* value = sfactor = shinyness of spheres and cylinders sfactor = shinyness of spheres and cylinders from 0.0 to 1.0 + *fsaa* arg = yes/no + yes/no = do or do not apply anti-aliasing *ssao* value = shading seed dfactor = SSAO depth shading shading = *yes* or *no* = turn depth shading on/off seed = random # seed (positive integer) @@ -103,7 +105,7 @@ Syntax dump_modify dump-ID keyword values ... * these keywords apply only to the *image* and *movie* styles and are documented on this page -* keyword = *acolor* or *adiam* or *amap* or *gmap* or *backcolor* or *bcolor* or *bdiam* or *bitrate* or *boxcolor* or *color* or *framerate* or *fsaa* or *gmap* +* keyword = *acolor* or *adiam* or *amap* or *gmap* or *backcolor* or *bcolor* or *bdiam* or *bitrate* or *boxcolor* or *color* or *framerate* or *gmap* * see the :doc:`dump modify ` doc page for more general keywords .. parsed-literal:: @@ -151,8 +153,6 @@ Syntax R,G,B = red/green/blue numeric values from 0.0 to 1.0 *framerate* arg = fps fps = frames per second for movie - *fsaa* arg = yes/no - yes/no = do or do not apply anti-aliasing *gmap* args = identical to *amap* args Examples @@ -229,7 +229,7 @@ details have to be looked up in the `FFmpeg documentation described below. To write out JPEG and PNG format files, you must build LAMMPS with -support for the corresponding JPEG or PNG library. To convert images +support for the corresponding JPEG or PNG library. To convert images into movies, LAMMPS has to be compiled with the -DLAMMPS_FFMPEG flag. See the :doc:`Build settings ` page for details. @@ -599,13 +599,25 @@ image will appear. The *sfactor* value must be a value 0.0 <= *sfactor* <= 1.0, where *sfactor* = 1 is a highly reflective surface and *sfactor* = 0 is a rough non-shiny surface. -The *ssao* keyword turns on/off a screen space ambient occlusion -(SSAO) model for depth shading. If *yes* is set, then atoms further -away from the viewer are darkened via a randomized process, which is -perceived as depth. The calculation of this effect can increase the -cost of computing the image by roughly 2x. The strength of the effect -can be scaled by the *dfactor* parameter. If *no* is set, no depth -shading is performed. +.. versionadded:: TBD + +The *fsaa* keyword can be used with the dump image command to improve +the image quality by enabling full scene anti-aliasing. Internally the +image is rendered at twice the width and height and then scaled down by +computing the average of each 2x2 block of pixels to produce a single +pixel in the final image at the original size. This produces images with +smoother, less ragged edges. The application of this algorithm can +increase the cost of computing the image by about 3x or more. + +The *ssao* keyword turns on/off a screen space ambient occlusion (SSAO) +model for depth shading. If *yes* is set, then atoms further away from +the viewer are darkened via a randomized process, which is perceived as +depth. The strength of the effect can be scaled by the *dfactor* +parameter. If *no* is set, no depth shading is performed. The +calculation of this effect can increase the cost of computing the image +substantially by 5x or more, especially with larger images. When used +in combination with the *fsaa* keyword the computational cost of depth +shading is particularly large. ---------- @@ -959,20 +971,6 @@ frequently. ---------- -.. versionadded:: TBD - -The *fsaa* keyword can be used with the dump image command to improve -the image quality by enabling full scene anti-aliasing. Internally the -image is rendered at twice the width and height and then scaled down by -computing the average of each 2x2 block of pixels to produce a single -pixel in the final image at the original size. This produces images with -smoother, less ragged edges. The calculation of this effect can -increase the cost of computing the image by roughly 4x or more, -especially for large images and with large processor counts due to -increased communication cost. - ----------- - The *gmap* keyword can be used with the dump image command, with its *grid* keyword, to setup a color map. The color map is used to assign a specific RGB (red/green/blue) color value to an individual grid cell @@ -1067,6 +1065,7 @@ The defaults for the dump_modify keywords specific to dump image and dump movie * boxcolor = yellow * color = 140 color names are pre-defined as listed below * framerate = 24 +* fsaa = no * gmap = min max cf 0.0 2 min blue max red ---------- diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 3ed6fb8e42..bcf1e741c4 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1195,6 +1195,7 @@ Freitas Frenkel Friedrichs fs +fsaa fsh fstyle fsw diff --git a/src/dump_image.cpp b/src/dump_image.cpp index 41d4671f95..b1b91c6543 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -248,10 +248,14 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal dump image command"); int width = utils::inumeric(FLERR,arg[iarg+1],false,lmp); int height = utils::inumeric(FLERR,arg[iarg+2],false,lmp); - if (width <= 0 || height <= 0) - error->all(FLERR,"Illegal dump image command"); - image->width = width; - image->height = height; + if (width <= 0 || height <= 0) error->all(FLERR,"Illegal dump image command"); + if (image->fsaa) { + image->width = width*2; + image->height = height*2; + } else { + image->width = width; + image->height = height; + } iarg += 3; } else if (strcmp(arg[iarg],"view") == 0) { @@ -345,6 +349,23 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : image->shiny = shiny; iarg += 2; + } else if (strcmp(arg[iarg],"fsaa") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + int aa = utils::logical(FLERR, arg[iarg+1], false, lmp); + if (aa) { + if (!image->fsaa) { + image->width = image->width*2; + image->height = image->height*2; + } + } else { + if (image->fsaa) { + image->width = image->width/2; + image->height = image->height/2; + } + } + image->fsaa = aa; + iarg += 2; + } else if (strcmp(arg[iarg],"ssao") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal dump image command"); image->ssao = utils::logical(FLERR,arg[iarg+1],false,lmp); @@ -1555,35 +1576,6 @@ int DumpImage::modify_param(int narg, char **arg) return n; } - // if antialias state changes, we need to increase the buffer space - // change the (internal) image dimensions and reset the view parameters - if (strcmp(arg[0],"fsaa") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - int aa = utils::logical(FLERR, arg[1], false, lmp); - if (image->fsaa == NO) { - if (aa == YES) { - image->width = image->width*2; - image->height = image->height*2; - // reallocate buffers to make room - image->buffers(); - } - } else { - if (aa == NO) { - image->width = image->width/2; - image->height = image->height/2; - box_bounds(); - box_center(); - view_params(); - } - } - image->fsaa = aa; - // reset size based parameters - box_bounds(); - box_center(); - view_params(); - return 2; - } - if (strcmp(arg[0],"bcolor") == 0) { if (narg < 3) error->all(FLERR,"Illegal dump_modify command"); if (atom->nbondtypes == 0)