How do I only change the opaque color of a translucent texture?

Hi and thanks for helping.
Basically I want to create a kind of aura at a sun.
I already have made a radial gradient in greyscale.

But I want to change the color of the white/grey pixels.
Here’s my code:
[java]Quad quad = new Quad(800, 800);
Geometry geo = new Geometry(“quad”, quad);
Material mat1 = new Material(assetManager, “Common/MatDefs/Misc/ColoredTextured.j3md”);
mat1.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/radial.png”));
mat1.setColor(“Color”, ColorRGBA.Blue);
mat1.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
geo.setQueueBucket(RenderQueue.Bucket.Sky);
geo.setMaterial(mat1);
geo.center();
rootNode.attachChild(geo);[/java]
But when I do this the whole quad turns blue and the white pixels even stay.

I really searched the whole forum and tried everything but nothing worked.

This shader:
Common/MatDefs/Misc/ColoredTextured.j3md

Is deprecated. Use Unshaded.j3md instead and it will work like you want.

2 Likes
@pspeed said: This shader: Common/MatDefs/Misc/ColoredTextured.j3md

Is deprecated. Use Unshaded.j3md instead and it will work like you want.


Thanks it works fine now =D

Ok the unshaded.j3md works fine in most cases. But is there a way to use lighting.j3md with translucency and custom color?
Basically that the texture receives shadows.

@Fissll said: Ok the unshaded.j3md works fine in most cases. But is there a way to use lighting.j3md with translucency and custom color? Basically that the texture receives shadows.

Yes. Have you been through any of the related tutorials?

1 Like
@pspeed said: Yes. Have you been through any of the related tutorials?
I thought I did ^^. Could you please send me the link to the wiki page?

It’s right there in the upper left under “Docs”:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3

1 Like
@pspeed said: It's right there in the upper left under "Docs": https://wiki.jmonkeyengine.org/legacy/doku.php/jme3
No I meant the page where it tells me how to make a material which is transparent, can change color and can receive shadows.

It’s the one called “Hello Material”. Sorry, I thought it was obvious.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material

1 Like
@pspeed said: It's the one called "Hello Material". Sorry, I thought it was obvious. https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material
Well it didn't help me. It only tells you how to make an unshaded material translucent wich I already know how to do. I want it to be shaded if you misunderstood my question. For example if you don't add a light source in the sample code [java]/** Must add a light to make the lit object visible! */ DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(1,0,-2).normalizeLocal()); sun.setColor(ColorRGBA.White); //rootNode.addLight(sun);[/java] The two monkeys are still visible. But what I want is, I want the monkeys to be also only visible with a lightsource and therefore I would have to use the lighting.j3md ... but this material also doesn't work because it can't render translucency as far as I know. I don't really want to get into making my own material because it seems to be quite complicated and therefore I want to know if there already exists a material which can render translucency can be coloured and has to be lit (can receive shadows).

Sorry if my question wasn’t precise enough … I hope it is now. And thanks for your time and help :smiley: .

@Fissll said: Well it didn't help me. It only tells you how to make an unshaded material translucent wich I already know how to do. I want it to be shaded if you misunderstood my question. For example if you don't add a light source in the sample code [java]/** Must add a light to make the lit object visible! */ DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(1,0,-2).normalizeLocal()); sun.setColor(ColorRGBA.White); //rootNode.addLight(sun);[/java] The two monkeys are still visible. But what I want is, I want the monkeys to be also only visible with a lightsource and therefore I would have to use the lighting.j3md ... but this material also doesn't work because it can't render translucency as far as I know. I don't really want to get into making my own material because it seems to be quite complicated and therefore I want to know if there already exists a material which can render translucency can be coloured and has to be lit (can receive shadows).

Sorry if my question wasn’t precise enough … I hope it is now. And thanks for your time and help :smiley: .

Your question was plenty precise but I’m not sure you actually did the whole tutorial or understood what was happening. Aside from writing the code for you I’m not sure what else to do:

Then just below that:

1 Like

Oh man I’m so dumb.
I wanted to have a quad with these properties. A radial like in the first pic.
And what I didn’t realized was that the lightsource was directly inside the quad and therefore it doesn’t receive the light.
I guess that’s the problem if you want to make a 2D game in 3 dimensions >.< .
Anyway thanks for all your help.