Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

transparency/beginner question

This topic is 5189 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, still working through the tutorials (quite useful!) how would I specify which objects within a certain scene have transparent faces, and those that don''t? I.e., using the crate example, say I wanted two crates -- one 50% alpha (so you can see ''into'' the crate), and the other one totally opaque... how would that be accomplished? maybe it''s just something listed later - but trying glEnable(gl_blend) around the quads, and then disable outside of it doesn''t seem to work... thanks!

Share this post


Link to post
Share on other sites
Advertisement
You also need to specify a blend function for blending. This depends on how you want things to look and what surface material you''re trying to display.

First you''ll need to set a transparency value somehow. Typically you can do this via the vertex alpha in the colour. So instead of glColour3f you use the 4f version. 1 is fully opaque and 0 is totally transparent. So you''ll need to set that to 0.5 for 50% transparency.

Assuming you want a glass-like surface, try glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) which basically gets you a weighted avarage of existing colour (your background) and the incomming colour (the crate being drawn). But be aware that this means you will need to sort transparent object back to front or you''ll get weird looking overlaps.
glBlendFunc(GL_SRC_ALPHA, GL_ONE) will get you additive blending, which is great for particles and doesn''t need objects to be sorted.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!