1
\$\begingroup\$

I'm fairly new to shaders and OpenGL so bare with me please, I just want to make sure I'm doing it correctly! Now I'm using LibGDX in order to create a simple 3d diagram for my company. I have a few models that I need to display as grey until they are active, where they will fade to a brighter blue, probably gain some emission value so that they're brighter.

Now, when I export my models from Blender to .fbx, and then run Fbx-Conv to generate .g3dj files, I get some output like the following:

"materials": [
    {
        "id": "glowy_blue_material",
        "ambient": [ 0.000000,  0.000000,  0.000000], 
        "diffuse": [ 0.000000,  0.753256,  1.000000],
        "emissive": [ 0.000000,  0.753256,  1.000000],
        "opacity":  0.592209,
        "specular": [ 0.000000,  0.759441,  1.000000], 
        "shininess":  9.607843,
        "textures": [
            {
                "id": "Texture",
                "filename": "heat_exchange_uv_edge_highlight.png",
                "type": "DIFFUSE"
            }
        ]
    }
]

Which is all good and displays what I want, but I've been reading about shaders the past few days and see that in a lot of cases LibGDX suggests extending the default shader and making tweaks that way.

From a computational point of view, what is the best way to go about switching colors of models? Extending the default shader with some logic about if x is inactive, change shader to render as greyscale, else render as normal blue material? Or should I create a greyscale version of the material and switch them out? ( I'm not quite sure how to do this, also, because I apply the material in the g3dj file — could I do this in Java instead of the g3dj file? Does it cause a performance hit? If anyone could point me in the direction of some documentation somewhere.. )

Any help would be appreciated. Thanks!

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

If you want to make everything black and white, use a post processing shader. Otherwise, it can be a simple line in you shader. In hlsl (directx) this would be something like:

if (greyscale)
{
  float tint = (color.r+color+g+color.b)/3;
  color.rgb = tint;
}

I assume this would also work in OpenGL.

\$\endgroup\$
0
1
\$\begingroup\$

To preserve performance, you should change the material setting in java rather than a "if" statement of the shader.

You can access the material the objects after the config file has been loaded using the functions described here

Hope it helps

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .