Ecere SDK/eC Forums
http://ecere.org/community/
Print view

Glass
http://ecere.org/community/viewtopic.php?f=7&t=21
Page 1 of 1
Author:  sacrebleu [ Thu Jan 21, 2010 6:29 pm ]
Post subject:  Glass

:? How to draw glass? Is this handled by the engine?
Author:  jerome [ Mon Apr 05, 2010 9:34 pm ]
Post subject:  Re: Glass

Take a look at this FAQ at openGL.org.
15.040 How can I render glass with OpenGL?
This question is difficult to answer, because what looks like glass to one person might not to another. What follows is a general algorithm to get you started.
First render all opaque objects in your scene. Disable lighting, enable blending, and render your glass geometry with a small alpha value. This should result in a faint rendering of your object in the framebuffer. (Note: You may need to sort your glass geometry, so it's rendered in back to front Z order.)
Now, you need to add the specular highlight. Set your ambient and diffuse material colors to black, and your specular material and light colors to white. Enable lighting. Set glDepthFunc(GL_EQUAL), then render your glass object a second time.
When you set a material to be translucent and call ApplyTranslucency() on a Mesh (as indicated in the thread about materials), primitives are broken up and get rendered from back to front Z order. There is also a Display::DrawTranslucency() method which lets you control when the translucent primitives are drawn, otherwise it is drawn when you reset the camera to 'null' on the display (usually at the end of an OnRedraw() method). You can try using this to draw your glass objects in 2 passes following the OpenGL.org's advice above.

You can use both translucent textures and translucent material color attributes to achieve the glass effect you're looking for. So far not so many nice glass effects have been achieved with Ecere yet, and you're most welcome to share with us your findings or screenshots :).

Here are some screenshots from the 3D samples:
The 'cube2' sample (translucent texture)
The 'cube2' sample (translucent texture)
The 'transCube' sample (50% opacity with opaque textures)
The 'transCube' sample (50% opacity with opaque textures)
A pick-up (3DS model) in the ModelViewer
A pick-up (3DS model) in the ModelViewer
Hoping this inspires you to render some great looking glass :)

Cheers,

Jerome
All times are UTC-05:00 Page 1 of 1