I’m trying to figure out how to create a shiny glass shader. I want this shader to have an Albedo that is completely transparent, but a very visible specular component. Unfortunately when I try this with a StandardMaterial3D, the specular becomes completely invisible when I set the alpha of the Albedo to 0. If I raise the alpha, the specular comes back, but then the glass gets cloudy.
How can I create a transparent material that only renders the specular highlight?
You need refraction. An ideally transparent glass is invisible against a solid background. The complexities of refraction are usually too expensive for games, but if you only have one object at a time it can be done. I recommend looking at how other shaders do it or finding a shader that already does it, because the math of refraction is hard to explain.
However, if what you want is just a fakeish reflection on a very transparent object, just make the alpha higher on the light function of the shader when the light is affecting the color. You can do this easily from a regular shader if you know how to modify it.
I don’t need realistic refraction - I just need a specular highlight to indicate the light source and maybe reflection of the world map. I would prefer perfectly transparent so that it does not obscure what the glass bottle contains, but I could put up with a little opaqueness if necessary.
I had a look at this (PBR Glass - Godot Shaders), but the specular also vanishes when the Albedo has alpha == 0. Please let me know if you know how to set up the StandardMaterial3D to produce this effect, or do it through a custom shader.
I came up with this. It’s not great, but it does keep the material clear except for the specular highlights. I don’t think realistic glass is possible with the current Godot pipeline.