Ideefixze / DTerrain

Destructible terrain in Unity
MIT License
417 stars 55 forks source link

[Question] Issue with PaintingMode.ADD_COLOR #3

Open EduardChernikh opened 3 years ago

EduardChernikh commented 3 years ago

Hi. I have an issue with PaintingMode.ADD_COLOR:

If i build over previously untouched area - i have weird texture (random purple artifacts), and if i paing over previously destroyed area of terrain i have black texture here as if i use issue with PaintingMode.REPLACE_COLOR and Color set to Color.black; Is this a bug or im doing something wrong?

Ideefixze commented 3 years ago

I checked it in the preview scene included in this repo and if I get it correctly I think I might know what is happening here. This is an issue, but it is related to two things: the way how ADD_COLOR mode works and how Unity handles textures.

ADD_COLOR just takes color that is on the texture and adds RGB values.

Unity on the other hand handles textures in more complicated way and it is even hard for me to elaborate on this topic further. The best way to see it is to, after you run you game with DTerrain layers in it, go to Scene view. Under tab "Scene" you have dropdown list with many different render modes and if you select "Mipmap" mode you can see how colors are streched out even though there should be transparent color.

ADD_COLOR mode on untouched area looks like it would now take the closest color and expand it.

Currently, I am unable to dig deep into this issue. Try to play with orginal texture import options especially: "alpha is transparency" This made my preview scene on ADD_COLOR to fill untouched terrain with a one color (which was a beige color, weird).