How to set material for metal(like silver) in OpenGL?

15,971

Solution 1

How to set material for metal(like silver) in OpenGL? Anyone knows?

If you want your material to sometimes look "kinda" like metal, you need to set corresponding diffuse, ambient, specular and "shininess" parameters. You could investigate existing material libraries for 3d editors like blender and see how they do it. That's cheap, but it will also look cheap. Normally material with low GL_SHININESS value (3..12, I think?) will look "kinda" like metallic surface.

If you want your material to look more like metal, but under certain lighting condition, you'll need to write pixel shader that will use photorealistic texture of silver, additional texture map that controls specular color and strength. A good texture allows you to get away with horrible and easy shader, as long as lighting conditions were carefully selected. That requires programmer with GLSL knowledge and a good artist to make texture, and artist will be more important - even a non-metallic shader like per-pixel phong can be fine-tuned by hand to look like what you want (precess might be boring and tedious). Shader itself only requires per-pixel lighting with specular (any specular), normalmapping support and environmental reflection mapping (with fresnel term support). Using HDR for weakly-reflective polished surfaces will also help.

If you want REAL and PERFECT silver, then you're in trouble and should reconsider. Metallic surfaces have "fuzzy" reflections that can be a pain to implement quickly, depending on your hardware. Another problem is that you'll have to pretty much study the metal itself, check every metallic surface demo that exists out there, read GDC papers, etc. I.e. do the research, which can take a lot of time/effort and won't pay off in the end because it is quite possible that final result will have horrible performance. The important thing is that you don't need to simulate real material to make it look right - you need to fool the viewer into thinking that this is silver.

Solution 2

If you check this site you can find a selection of different material settings designed to mimic various materials, including silver. However, as others have said in comments, remember that Phong shading, which is what OpenGL uses material settings like this to do, has a hard time rendering certain real-world substances in a realistic manner, particularly reflective ones like silver. But the material settings at that site should give you something silver-like, at least to a first approximation. (Make sure you catch the note at the end about multiplying shininess by 128)

Share:
15,971
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    How to set material for metal(like silver) in OpenGL? Anyone knows?