Ecere SDK/eC Forums • View topic - Glass

Ecere SDK/eC Forums

Ecere Developers Community


Help with the Ecere 3D Graphics Engine: Camera, Mesh, Object, Material, OpenGL integration, etc.


Postby sacrebleu » Thu Jan 21, 2010 6:29 pm

:? How to draw glass? Is this handled by the engine?
Posts: 27
Joined: Sun Jan 17, 2010 12:37 pm

Re: Glass

Postby jerome » Mon Apr 05, 2010 9:34 pm

Take a look at this FAQ at
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'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 'transCube' sample (50% opacity with opaque textures)

A pick-up (3DS model) in the ModelViewer

Hoping this inspires you to render some great looking glass :)


Site Admin
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Return to 3D Graphics

Who is online

Users browsing this forum: No registered users and 0 guests