JavaFX: How to make a transparent glowing material?

122 Views Asked by At

I want to create a PhongMaterial with a uniform glow. The effect is, I have a small Earth model and I would like to surround it with a cheap imitation of the aurora. https://i1.wp.com/trendintech.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-09-at-12.06.23.png?fit=1079%2C742. The flares aren't necessary or desired, I just want the pale green sphere surrounding it.

The way I would have thought to make this in white is just

public static Sphere buildGlowingSphere(double radius) {

    String glowingFilename = "white_square_400x400.jpg";
    Image glowingMap = new Image(new File(glowingFilename).toURI().toString());

    PhongMaterial material = new PhongMaterial();
    material.setDiffuseColor(Color.rgb(255, 255, 255, 0.01));
    material.setSpecularColor(Color.rgb(255, 255, 255, 0.01));
    material.setSelfIlluminationMap(glowingMap);

    Sphere sphere = new Sphere(radius);
    sphere.setMaterial(material);

    return sphere;
}

However, this just makes an opaque white sphere. What do I need to make it transparent and quite subtle?

While we're at it, I'd like to not have to source a new image for each color I'd like to make. I'd like to do something like

public static Sphere buildGlowingSphere2(double radius, Color color) {

    Image glowingMap = generateBlankImage(color);

    PhongMaterial material = new PhongMaterial();
    material.setDiffuseColor(Color.rgb(255, 255, 255, 0.01));
    material.setSpecularColor(Color.rgb(255, 255, 255, 0.01));
    material.setSelfIlluminationMap(glowingMap);

    Sphere sphere = new Sphere(radius);
    sphere.setMaterial(material);

    return sphere;
}

How do I do that? Or otherwise make a material that's uniformly self illuminated?

I have also tried to do this just using a non-illuminated transparent sphere, and that looks okay but it doesn't have the bright limb that you get in that image; it just looks like a flat circle covering the Earth. I assumed that this would be because in real life, that material is luminescent. But if there's a different or better way to achieve the same effect, I'm all ears.

0

There are 0 best solutions below