how render through holes?

Started by manji, July 30, 2009, 15:33:00

Previous topic - Next topic

manji

Let's say I have a single wall, and I want to make a window on it and render the scenery outside. The wallpaper is one texture, multiplied many times, so I can't just make a transparent spot on a texture. Could someone please give me hint?
toyWars game blog: http://toywars.wordpress.com/

bobjob

yes you could make the wall one texture. This effect is useful for something like a wire fence.

make sure to setup openGL like so:
GL11.glEnable(GL11.GL_BLEND); // Enabled blending
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // selects blending method
GL11.glEnable(GL11.GL_ALPHA_TEST); // allows alpha channels or transperancy
GL11.glAlphaFunc(GL11.GL_GREATER, 0.9f); // sets aplha function

as well as turn depth testing on.
and when you make your texture get rid of the alpha range as much as possible, so that the is 100% transperant, or %0 transperant.


if you want the texture to be semi-transperant, then you will have to draw it after the scene.


Ciardhubh


  • You could make a wall model that actually has a hole/window in it.
  • You could draw the wall, then draw a quad/decal where your hole/window is supposed to be and use a texture with the scenery outside; render the scenery to an FBO and use this. Getting the perspective right could be a bit challenging, though.
  • Look into stencil testing. Make a stencil that prevents drawing where the window/hole is and draw the wall. Switch to a window-area stencil and draw the scenery outside.

manji

Thank you both for you answers. I'll see what I can do.
@Ciardhubh
I have made a model with a hole on it. The problem is how to apply the texture (it's a small texture, repeated as many times needed).
Let's exclude the second option, too diffcult for me.
I have also tried stencil testing and I could't make it. The scenery outside wasn't seen from inside. I should study more for this.
toyWars game blog: http://toywars.wordpress.com/

Ciardhubh

Quote from: manji on July 31, 2009, 10:04:31
I have made a model with a hole on it. The problem is how to apply the texture (it's a small texture, repeated as many times needed).

For simple models like a wall you could look into texture coordinate generation (glTexGen*(...), http://www.glprogramming.com/red/chapter09.html). This can automatically generate your texture coordinates for you.

It might also be useful to set texture coordinates by hand as a learning exercise and then move to a modelling program (e.g. Blender) to do them for you later on.

Quote from: manji on July 31, 2009, 10:04:31
I have also tried stencil testing and I could't make it. The scenery outside wasn't seen from inside. I should study more for this.

http://www.glprogramming.com/red/chapter10.html