Pasting an image with alpha mask on a texture
I have this big wall texture, and i want to paste on it some images with an alpha mask dynamically. To do this I found glTexSubImage2D, but unfortunately it replaces the whole rectangular area around the image, making the wall texture transparent where the image's pixels are transparent (while I'd like to keep the wall texture there)
What's an easy way to do this?
Thanks in advance.
What's an easy way to do this?
Thanks in advance.
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Are you certain you want to modify the wall texture? I'd instead draw the decal on top by drawing the quad twice. Once with the wall texture, and a second pass ( using glPolygonOffset ) with the decal texture and an appropriate blend mode.
Hm, that would require one (small) quad for each decal (splat)? If so there might be too many (too much blood
).
If nothing i think i can blit the image on the SDL surface of the texture, then get the small rectangle that has changed and pass it back in the opengl texture with glTexSubImage2D.
).If nothing i think i can blit the image on the SDL surface of the texture, then get the small rectangle that has changed and pass it back in the opengl texture with glTexSubImage2D.
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
You could accumulate the blood using two FBOs, ping ponging back and forth rendering the new blood over what was there previously. Would be much faster than doing it on the CPU in RAM.
Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Hm thanks reubert, I'm still a opengl newbie, I didn't know about FBOs.
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
this might be a good place to start:
http://www.gamedev.net/reference/article...le2331.asp
and in your situation it would be something like:
The main advantage being that everything is always in VRAM. You can also really easily rotate, color or scale your blood texture before rendering it over the wall, or use shaders to tweek the output even more.
http://www.gamedev.net/reference/article...le2331.asp
and in your situation it would be something like:
Code:
startup()
{
bindFrameBuffer(fboa)
renderWallInitialTextureToFBOQuad()
unbindFrameBuffer(fboa)
currentFBOTexture = fboa.texture
}
eachBloodAdd()
{
bindFrameBuffer(fbob)
renderWallToFBOQuadWithCurrentWallTexture(fboa.texture)
renderBloodOnTopOfFBOQuad()
unbindFrameBuffer(fbob)
currentFBOTexture = fbob.texture
swap(fbob, fboa)
}
eachFrame()
{
renderWallTextureToMainOutputGeometryWithWallTexture(currentFBOTexture)
}The main advantage being that everything is always in VRAM. You can also really easily rotate, color or scale your blood texture before rendering it over the wall, or use shaders to tweek the output even more.
Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Thanks for your help, I think i might have it working (after hours of blood (mine)).
I'm a bit worried about compatibility, but then again I can always go back to the other method.
I'm a bit worried about compatibility, but then again I can always go back to the other method.
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Najdorf Wrote:I'm a bit worried about compatibility...
I wouldn't worry too much about compatibility. With OpenGL, by the time you've figured out how to be more compatible, most of it (the older hardware) is already dead and gone. Fill in the users that it doesn't work for later, if needed. It is vastly more important that it works for you first.
Apple supports FBOs on NVIDIA GeForce 5200 and better, and ATI Radeon 9500 and better from 10.4.3 (or thereabouts). There are reasonable fallbacks (PBuffers and off-screen windows) for older OSes and hardware back to 10.2 and Rage 128.
I woke up in the middle of the night all worried because I realised you could do it with one FBO. Just don't clear the color buffer and keep rendering blood over the top. Duh!
Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
reubert Wrote:I woke up in the middle of the night all worried because I realised you could do it with one FBO. Just don't clear the color buffer and keep rendering blood over the top. Duh!
Yeah that's what I did really, sorry for not telling you
Still I'm not completely happy with the results, maybe i have to make a better splat texture :/
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Edge detection with sobel operator/mask | g00se | 5 | 9,229 |
May 20, 2011 12:23 AM Last Post: g00se |
|
| alpha not working in SDL image | NSDuo | 7 | 3,577 |
Feb 9, 2008 11:28 PM Last Post: NSDuo |
|
| Create texture from NSOpenGLContext image | Wong4 | 3 | 3,847 |
Sep 29, 2007 02:42 PM Last Post: OneSadCookie |
|
| Using 8-bit greyscale texture as an alpha channel? | TomorrowPlusX | 12 | 4,271 |
Apr 10, 2006 08:43 AM Last Post: TomorrowPlusX |
|
| Changing the Mask in OpenGL | kodex | 2 | 3,399 |
Jan 18, 2006 09:21 PM Last Post: kodex |
|

