OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

PrecipitationEffect artifacts

Open ghost opened this issue 2 years ago • 2 comments

Hello,

I noticed a couple visual problems with PrecipitationEffect.

The first problem is, while the repetition of the same rectangle of sprites, as generated by PrecipitationEffect::createGeometry() within a single precipitation layer is unnoticeable (but one can still start seeing repeated patterns of particles falling over a static scene), the sprites in different layers very often stack up such to form immersion-breaking "tunnels".

Examples (I marked a couple lines of repetition that form the artifact on each screenshot).

  1. Snow in FlightGear, there are many instantly visible occurences when looking around. flightgear_snow
  2. Much more difficult to catch, probably because of smaller distance or lower contrast: $ ${OSG_BUILD}/bin/osgprecipitation ${OSG_SRC}/examples/osgemscripten/box.osgt --snow 1.0 osgprecipitation_snow

Could a unique rectangle be used for each layer? If that could save performance in that case, random 90 and 180-degree rotations (but not flips, which can also cause "tunnels") of the same rectangle would pass as "unique", so that would require 3 times fewer truly unique rectangles.

Alternatively, each layer can be simply shifted by a random offset and use rectangles randomly rotated by 90 and 180 degrees.

I can try implementing this, but unfortunately I can not find the code that places rectangles within a single layer of precipitation and moves them within a layer -- hints would be very appreciated.

The second problem I noticed is that the scaling and change of intensity creates apparent wind in or out of those "tunnels", or "rain falling upside down". It looks like it could go away when the first one is solved.

Kind regards, Mike

ghost avatar Aug 18 '21 11:08 ghost

On the second thought, randomizing orientation of the same texture in 2 steps would give 8 variants and would probably work even better:

  1. Flip by 0 or 90 degrees
  2. Mirror: none, along x, along y, or along both x and y

ghost avatar Jan 09 '22 23:01 ghost

The design of PrecipitationEffect has the cells lined up vertically so the particles from one cell "visually" pass into the cell below, so this must be maintained.

To avoid particles lining up between adjacent cells horizontally you could attempt flipping them but I think it might be more productive to add a time offset to each particle based on a noise texture that covers multiple cells.so that adjacent cells don't repeat. I haven't tried to do this but that's what I'd try.

robertosfield avatar Jan 11 '22 10:01 robertosfield