Skip to content

Commit

Permalink
move fsaa keyword next to ssao and away from dump_modify
Browse files Browse the repository at this point in the history
we don't need to reallocate the buffers this way
  • Loading branch information
akohlmey committed Aug 17, 2023
1 parent 988b121 commit 5528cef
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 59 deletions.
51 changes: 25 additions & 26 deletions doc/src/dump_image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down Expand Up @@ -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)
Expand All @@ -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 <dump_modify>` doc page for more general keywords

.. parsed-literal::
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <Build_settings>` page for
details.
Expand Down Expand Up @@ -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.

----------

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

----------
Expand Down
1 change: 1 addition & 0 deletions doc/utils/sphinx-config/false_positives.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@ Freitas
Frenkel
Friedrichs
fs
fsaa
fsh
fstyle
fsw
Expand Down
58 changes: 25 additions & 33 deletions src/dump_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5528cef

Please sign in to comment.