How do I create a transparent glass cup in OpenGL ES / OpenGL?

Is there a way to create a glass cup with OpenGL ES / OpenGl? And if possible, what can I read to start creating? You need to get the most realistic view of the glass, for example -

see glass cup picture

For handle-free simplicity.

Maybe anyone has an example with sources?

Thanks.

+2


a source to share


3 answers


Getting something that looks very close to the associated image will be very tricky (the handle is not the tricky part). If this is a tutorial project, I would suggest starting less. Coarser approximations would be a better starting point.

You can easily render a semi-transparent object in OpenGL ES. The OpenGL feature you want is Alpha Blending. It won't help you get close to your glass. http://www.opengl.org/resources/faq/technical/transparency.htm



The basic level of replication for this object will be to use a hand-drawn gray texture that looks like internal refractions and paint it on a camera-facing sprite with partial transparency. Then make a regular high opacity bowl model with a little ambient and diffuse lighting and a lot of specular lighting to make it look shiny.

The effect of multiple reflections on a rounded glass object is much more complex. Especially if you want it to look convincing when there is something other than a blank background behind the cup. This is fairly easy to do in raytracer, but not in a rasterizer like OpenGL. Take a look at Caustics. Methods exist to approximate this effect, but they are not beginners. According to this, GLUT has some examples if you are serious about it. http://www.opengl.org/resources/faq/technical/lights.htm

+3


a source


I know this post is over a year old, but I came across this post on the internet that might help. (Its Russian or whatever, use google translate to change it to English)



enter image description here

+3


a source


With programmable shaders, you can create pleasing glass effects such as reflection combined with refraction. OpenGL ES 2.0 has programmable shaders, but OpenGL ES 1.X does not.

A good example of glass with OpenGL ES 2.0 comes with AMD RenderMonkey (free). Download here and take a look at glass examples.

0


a source







All Articles