 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
J-Fox
Joined: 26 Sep 2007 Posts: 15 Location: Hannover, Germany
|
Posted: Sat Feb 02, 2008 10:54 am Post subject: Texture splatting - 2 Textures (Alpha / Color) |
|
|
I would like to use a grayscale image (r=g=b, GU_PSM_5650) as alpha for another image (GU_PSM_5650).
So basicly I m trying this:
- I render my scene to a rendertarget, works
- Blur that rendertarget, works
- Get zbuffer to rendertarget, works
and now I would like to render the sharp scene, and then put the blurred scene with the zbuffer as alpha above (depth of field effect)
How could I do that?
---
My idea was to subtract the zbuffer from the blurred scene (which will make stuff far away from the camera darker), then rendering the sharp/original scene and use additive blending to blend the blurred scene. I m not sure which blend functions to use then though... |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Sat Feb 02, 2008 10:52 pm Post subject: |
|
|
Well, though your idea is nice, it won't work out. The problem is that the additively blended scene would change the color effects of the output image in a non-realistic way. You really need alpha blending for it to work. You could achieve that by using DST*SRC blend and DST*(1-SRC), then adding those together, but that would cost too much pixelrate to be practical.
Here's how I'd do it:
- render depthbuffer (downsampled) into a 565 rendertarget
- render original scene (downsampled) into the same rendertarget, but this time as 4444 with disabled stencil (hence leaving the upper most 4 bits from the depth buffer as alpha channel)
- render the rendertarget with alphablending onto original scene (upsampled)
If you do several more downsampled (2x,4x,8x, etc.) versions and use a good palette for the depthbuffer reads (T16) to distribute the depth, then add the results together you can get a very smooth depth of field effect. Also, the rendercost shouldn't increase dramatically with more steps, since the rendertarget becomes smaller and smaller - so throughput becomes less of an issue. _________________ <Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
Alexander Berl |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|