Unshaded material question

Hi monkeys!

I have a question about the unshaded material. What I am trying to achieve, is to place a marker (white circle) on the ground where my character is walking to.

I created a material based on the Unshaded material:

Material White Circle : Common/MatDefs/Misc/Unshaded.j3md {
     MaterialParameters {
        ColorMap : Textures/white_circle.png
     }
    AdditionalRenderState {
      Blend Alpha
      PolyOffset -1.0 -1.0
   }
}

Then I created a Plane geometry, set the material on this geometry, and placed the geometry in the Transparent Queue bucket. Then I place the geometry in the scene like this:

Spatial destinationSpatial = getApplication().getAssetManager().loadModel("Models/gui/movement_destination.j3o");
destinationSpatial.setLocalTranslation(destinationComponent.getDestination());
destinationSpatial.lookAt(destinationComponent.getDestination().mult(destinationComponent.getDestinationNormal()), Vector3f.UNIT_Y);

However, from a distance the quality of this setup is not okay. It’s grayish and not clear. I just want a crispy clear white circle, up close and far away.

white circle (texture)

bad quality from far away, it’s grayish and not clear

better when close, but still not okay. It has a gray border for some reason.

Could you guys enlighten me, or give me some clues to look at for solving this problem? Or am I tackling my problem in a wrong way, maybe using a plane + texture is not the correct way?
Maybe I should put indicators like this in the guiNode? What to do for example with health bar indicators on top of a character? I would think I will have the same issue when I start implementing that component.

It may be because of the min filter and/or mipmaps.

When the color is sampled it is blended with adjacent colors and mipmaps according to the filtering you are using.

Try to set MinFilter.NearestNoMipMaps or MinFilter.BilinearNoMipMaps and see if it works as expected, you can also tweak the alpha discard threshold to get a better result (it removes the fragment below a certain alpha value)

1 Like

Probably the parts outside the circle are black, right? That’s why the color bleeds at far away distances where higher levels of mipmaps are used. Make sure the entire texture is white except for the alpha channel

1 Like

Thanks @RiccardoBlb and @Momoko_Fan, I’ll look into the MipMaps / min filter you guys mentioned. And comeback with the results.

Probably the parts outside the circle are black, right?

I don’t really understand the texture thing you described. The texture only has the white circle in it, nothing else.

What color is the part that is not a circle?

And if you answer “transparent”… then you don’t understand the question. “Transparent” is not a color… that’s the alpha channel.

Oh like this.
The texture is fully white, then I set the alpha channel to zero. For the cut-out circle I raised the alpha channel to 100%. So it’s one color.

I tried to set the MinFilter to NearestNoMipMaps and this works great!

edit: you can set this in the material file like this:

ColorMap : MinNearestNoMipMaps Textures/white_circle.png