Code Monkey home page Code Monkey logo

Comments (7)

MineBill avatar MineBill commented on September 25, 2024 1

For future reference, if anyone else tries to tackle this:
#1739 (comment)

from flaxengine.

Vizepi avatar Vizepi commented on September 25, 2024 1

Hello, I don't know if it's related, but I think the splatmap painting quantization algorithm is iccorect (Source/Editor/Tools/Terrain/Paint/SingleLayerMode.cs -> Apply).
In the deepest of the loop, we can see that we add paintAmount to the current layer (c) and subtract this same amount to all other layers.
I think instead we should decrease each other layers by the paintAmount multiplied by their contribution (minus current layer's contribution).
Something like this:

// Paint on the active splatmap texture
var c1 = (c + 1) % 4;
var c2 = (c + 2) % 4;
var c3 = (c + 3) % 4;

var otherLayersSum = src[c1] + src[c2] + src[c3] + other[0] + other[1] + other[2] + other[3];
var decreaseAmount = paintAmount / otherLayersSum;

src[c] = Mathf.Saturate(src[c] + paintAmount);
src[c1] = Mathf.Saturate(src[c1] - decreaseAmount * src[c1]);
src[c2] = Mathf.Saturate(src[c2] - decreaseAmount * src[c2]);
src[c3] = Mathf.Saturate(src[c3] - decreaseAmount * src[c3]);
p.TempBuffer[z * p.ModifiedSize.X + x] = src;

var other = (Color)p.SourceDataOther[zz * p.HeightmapSize + xx];
//if (other.ValuesSum > 0.0f) // Skip editing the other splatmap if it's empty
{
    // Remove 'paint' from the other splatmap texture
    other[0] = Mathf.Saturate(other[0] - decreaseAmount * other[0]);
    other[1] = Mathf.Saturate(other[1] - decreaseAmount * other[1]);
    other[2] = Mathf.Saturate(other[2] - decreaseAmount * other[2]);
    other[3] = Mathf.Saturate(other[3] - decreaseAmount * other[3]);
    p.TempBufferOther[z * p.ModifiedSize.X + x] = other;
    otherModified = true;
}

from flaxengine.

mafiesto4 avatar mafiesto4 commented on September 25, 2024

@Menotdan could you attach terrain material you use in here? (no need for textures, just material asset would be fine)

from flaxengine.

mafiesto4 avatar mafiesto4 commented on September 25, 2024

Also, usually using more advanced blending logic than simple Lerp yields better results in realistic terrains:

image

from flaxengine.

Menotdan avatar Menotdan commented on September 25, 2024

@Menotdan could you attach terrain material you use in here? (no need for textures, just material asset would be fine)

landscape.zip

from flaxengine.

Menotdan avatar Menotdan commented on September 25, 2024

Also, usually using more advanced blending logic than simple Lerp yields better results in realistic terrains

Is Linear Blend more complicated than Lerp? Anyways that wouldn't affect the splatmap being blocky.

from flaxengine.

mafiesto4 avatar mafiesto4 commented on September 25, 2024

Thanks @Vizepi . I used your code here 0ee5ef8. It did improve blending.

Regarding the blockiness of the paint, it's related to the implementation of this system which stores layer weights per-vertex and uses hardware interpolation of the values in-between:

image

To provide higher resolution or this blend use heightmap-aware blending (like suggested above) or use tessellation (also with displacement/height-based blend) or increase vertex density (eg. by scaling terrain down a little).

image

from flaxengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.