Jump to content

Painting albedo colors on landscapes


photo

Recommended Posts

Hello,

Using Unigine 2.13.0.1 and I want to paint albedo colors (any color of my choosing, so not only one) on top of landscape (using Landscape::asyncTextureDraw) but it seems that during rendering any detail layer will overwrite the albedo (if they have any albedo in it, not just roughness and height). So rendering is acting as albedo layer is the first layer and the rest apply on top. How can I arrange the layers (maybe multiple lmaps? maybe clearing the details layers first?) so I can just overwrite the final landscape surface color with some albedo of my choosing?

Think of the usage like this: I have my nice landscape with satellite images, layers with masks etc, and I want to be able to paint with different colors to mark things on top, overwriting all existing layering.

Regards

Link to comment

Hi Adrian,

Can you just use decals for that? If you need to paint on top of the whole terrain I think it would be the best option.

Alternatively you can create a new lmap with albedo and apply it on top of the everything as an additional detail layer. When needed you can enable this lmap and paint.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi and thank you for the response.

We cannot use decals (unless you do some sort of optimizations for them, like baking them in landscape texture). They were too heavy on performance due to amount of painting we needed.

We also tried to use another lmap but the albedo still does not show, seems that any detail layer, from any lmap, with Albedo in its material will overwrite my albedo, even if albedo is painted on a secondary lmap. For example here I tried to paint with pink in the albedo on second lmap, but black from Base layer in first lmap is still rendered on top (what you see there is only the gizmo of the brush as pink, color remains black):

image.thumb.png.1cd3376cfde8a0670821ceaacfb4552e.png

 

By looking at the rendering shaders, am I correct to assume calc_details.frag is the one doing the final blending? If so how is this applied, per lmap, or on some results from all landscape maps?

 

Another thing that I've tried:

- Paint on another layer on secondary lmap (like RetardantOnGround, having with solid black as color, opacity zero) so with this paint I just make it clear all the other details layers mask on those brush stroke places.

- Then paint with albedo in the same places, again on secondary lmap.

- This seems to work in editor, but doesn't in code.

I am using the following states in code:

    // Prepare first paint

    brushMat->setState("masks_overide", 1);

    brushMat->setParameterFloat("opacity", 1);
    brushMat->setParameterFloat("contrast", 0);
    brushMat->setParameterFloat("color_intensity", 1);
    brushMat->setParameterFloat("angle", 0);
    brushMat->setParameterFloat("height", 1);
    brushMat->setState("height_blend_mode", 1);

    brushMat->setParameterFloat4("color", Unigine::Math::vec4::ONE);

    brushMat->setParameterInt("data_mask", FLAGS FOR RetardantOnGround);
    brushMat->setParameterInt("data_mask_opacity", FLAGS FOR RetardantOnGround);
    brushMat->setState("data_mask", FLAGS FOR RetardantOnGround);
    brushMat->setState("data_mask_opacity", FLAGS FOR RetardantOnGround);

    Unigine::Landscape::asyncTextureDraw(paintGroundOpId, secondLmap->getGUID(), cellPixelPos, cellSizeInPixels, fileFlags);

 

   // Now prepare paint of albedo

   params->brushMat->setParameterFloat4("color", *albedo);

   params->brushMat->setParameterInt("data_mask", Unigine::Landscape::FLAGS_DATA_ALBEDO);
   params->brushMat->setParameterInt("data_mask_opacity", Unigine::Landscape::FLAGS_DATA_ALBEDO);
   params->brushMat->setState("data_mask", Unigine::Landscape::FLAGS_DATA_ALBEDO);
   params->brushMat->setState("data_mask_opacity", 0);

   const int newFileFlags = Unigine::Landscape::FLAGS_FILE_DATA_ALBEDO;

   Unigine::Landscape::asyncTextureDraw(paintGroundOpId, secondLmap->getGUID(), cellPixelPos, cellSizeInPixels, newFileFlags);

Any idea what am I doing wrong? I guess important thing is masks_overide to be put on 1 so all other details layers are removed in this painted parts? But still doesn't work.

 

Kind Regards

Link to comment

Btw, did you have a chance to look a the C++ samples from 2.14.x. There is an example that shows how to paint on different Lmaps:

I guess you can easily port this code into the 2.13.x since the LandscapeTerrain API didn't changed much.

If you would be able to reproduce your issue in built-in samples - it would be even better :)

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hello and thank you again for the support. Will have a look at those samples. I will also see if I can prepare at least some lmap data for you.

Regards

  • Thanks 1
Link to comment
×
×
  • Create New...