MaNGusT wrote: ↑06 Jul 2020, 15:31
Cyp wrote: ↑06 Jul 2020, 08:36The blend factors for all terrain types should probably sum to 1, so it doesn't give light/dark bands.
Just wanted to outline textures transitions or make it sharper.
UPD: now it only darkens transitions.
ezgif.com-crop.gif
This is more about coding, but for above post.
I'm not sure if correctly understood point of this post. It seems for me that it's about blending problem. I had some experience, while playing with cairo graphics, trying to solve some common artifacts, affecting any composited graphics, be it 2d or 3d. Some notes may be useless if those issues are already handled properly (I'm totally out of dev context here).
1. Unexpected transparency border between two stiched surfaces. Originaly I remember very sharp artifacts, appearing if antialiasing is not applied to some edjes (afaik, bilinear..anisotropic options are about texture filtering, which is not same as antialiasing).
But even if shaping AA is applied, uncareful compositing also leads to artifacts, though less visible. It is certain to happen in such naive rendering way, when objects are rendered one by one, with full antialiasing (including shape AA), then composited in mix blending mode. Reason - shaping AA is not translucency. If two surfaces share same pixel, their colors don't mix as with translucency. They sum. And that's not alpha-based additive blending mode. Alpha channel here is just another channel, like R,G,B, which must be summed - simply, without any multipliers (well - assuming, at least for premultiplied RGBA format). Exact shaping alpha values represent coverage for proper object.
In naive mode, when stiching in mixing mode, each color part is mixed with background, with final result getting unexpected transparency where it should not be.
I could propose following rendering sequence for solution, with not so deep required modifications:
- render shape into separate texture. Shaping AA must be disabled, but what is important - binary shape mask should include all pixels with any non-zero fulling, not just those with coverage >=0.5.
- draw shape surface to stiching surface in additive blending (as described above). If done correctly, overlapping pixels at edges will sum, forming what you need. Even for transparent materials, even if they have different translucency.
NOTE: any compositing, required by material properties (including translucency) must be done _before_ stiching. If stiched surfaces have dufferent transparency - breaking this rule will break some proportions.
I would also propose this way:
- detect all pixels, covered by any visible edges (not behind opaque objects). Add then to mask.
- render everything out of mask in whatever you like (naive) mode
- render pixels in mask in special mode, with shaping AA as finishing step, just before to _add_ to common result.
There could be cheaper solution for specific case when one of two stiched surfaces is opaque. Stack opaque surf above transparent and extend transparent one to at least one pixel at output device scale.
1.1. Not sure that uncovered, but still worthy to mention - if some point or line has width <1px, it should be cast to =1px, but with alpha correction, very similar to shaping (and of course with subpixel positioning with proper shaping AA). Well... I'm not sure, if such careful rendering is mandatory for games - at least some antialiasing filters easily negate such problem, though they also make picture somewhat blurry.
2. To above post. If textures fade one to other, they are better be opaque (without effects like shadows, light). For mixing mode bottom texture must be opaque everywhere, with above one fading via alpha. Probably additive stiching approach could be used too, but not sure whether such resource waste is worthy.
Edit: Ohh, I really did not get point of that post. If sharpened contours are intentional - more like art effect. I'm sure, that both sharp and soft transitions would be ok (sharpness also could be non-boolean ranged parameter). Or may be just transition distance.