开发者

How to create a transparent glass cup in OpenGL ES/OpenGL? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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

see glass cup image

For simplicity, without handles.

Maybe, anybody has example with sources?

开发者_StackOverflow社区

Thanks.


Getting something that looks very close to the image you linked would be very complicated (the handle is not the hard part). If this is a learning project, I would suggest starting smaller. Rougher approximations would be a better starting place.

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

A basic level of replicating this object would be to use a hand-drawn grayish texture that looks sort of like the interior refractions and draw it on a camera-oriented sprite with partial transparency. Then render a regular cup-shaped model with high transparency with only a small amount of ambient and diffuse lighting and a lot of specular lighting to make it look shiny.

The multi-bounce refraction effect of a rounded glass object is much more difficult. Especially if you want it to look convincing when something other than a blank background is behind the cup. It's fairly straightforward to do in a raytracer, but not in a rasterizer like OpenGL. Look up Caustics. There are methods to approximate this effect but they are not beginner projects. According to this there are some examples in GLUT if you're serious about it. http://www.opengl.org/resources/faq/technical/lights.htm


I know this post is over a year old , but i came across this post on the internet, which may help. (Its russian or whatever, use google translate to change it to english)

How to create a transparent glass cup in OpenGL ES/OpenGL? [closed]


With programmable shaders it is possible to create nice 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 have a look at the glass examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜