#148181 - Rajveer - Thu Jan 03, 2008 11:32 am
Is there any way to draw only part of the current scene buffer? I want to fade from screen to screen starting off by drawing the first column of the new scene, next frame adding a column e.t.c. until I'm drawing the whole of the new scene on the screen.
#148190 - Peter - Thu Jan 03, 2008 1:37 pm
Maybe with the display-capture?
- Capture current framebuffer (old scene)
- switch to new scene
- 1. draw new scene
- 2. draw quad with old framebuffer mapped as texture over new scene
- 3. reduce quad size
- 4. goto 1
_________________
Kind Regards,
Peter
#148197 - Rajveer - Thu Jan 03, 2008 2:39 pm
I was thinking of the display-capture, but then the fade would be at 30fps, although it may look alright as it will constantly be at 30fps during the fade (oh no wait I'm wrong, as I'll only be capturing the old scene once, not every frame). I will however be using it in situations where I'll be maxing out all the main VRAM banks for textures.
#148199 - Cydrak - Thu Jan 03, 2008 3:16 pm
No need for capture. glViewport() clips per-polygon, so you can use that to clip both scenes. The trick is to fix the clip matrix so it looks like the viewport wasn't changed in the first place.
Eg. something like:
Code: |
s32 viewLeft = inttof32(0);
s32 viewBottom = inttof32(0);
s32 viewWidth = inttof32(256);
s32 viewHeight = inttof32(192);
s32 clipWidth = inttof32(clipRight - clipLeft);
s32 clipHeight = inttof32(clipTop - clipBottom);
s32 clipOrgX = inttof32(clipRight + clipLeft)/2;
s32 clipOrgY = inttof32(clipTop + clipBottom)/2;
// This will clip stuff.
// But the projection is scrunched to fill the new region...
glViewport( f32toint(clipLeft), f32toint(clipBottom),
f32toint(clipRight)-1, f32toint(clipTop)-1 );
// So you need to adjust the projection, by stretching a
// smaller part of clip-space, to fill the whole +/-1.0 range.
GLvector sv, tv;
sv.x = divf32(viewWidth, clipWidth);
sv.y = divf32(viewHeight, clipHeight);
sv.z = inttof32(1);
tv.x = inttof32(1) - divf32(2*(clipOrgX - viewLeft), viewWidth);
tv.y = inttof32(1) - divf32(2*(clipOrgY - viewBottom), viewHeight);
tv.z = inttof32(0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glScalev(&sv);
glTranslatev(&tv);
// Set up the view as usual
glOrtho/gluPerspective/whatnot(...);
glMatrixMode(GL_MODELVIEW);
...
// Render the clipped scene
...
|
Then you can do the same for the second scene, but clipped to the other half of the frame.
Things to watch out for:
- glViewport() is inclusive--(0,0,0,0) gives a single pixel viewport.
- glViewport() only ranges 0..255. Broader clip coordinates will themselves need clipping. :-)
- There's only one Z buffer. So if you have like a cool effect that circles in (read: overlaps) on the other scene, I would guess some care with the Z range is needed. (Would the same method would work, as for X and Y?)
- You might get vertex jitter as glViewport() changes.. it's possible to avoid most of it, so not a big deal. Unfortunately polys at the clipped edge don't cover quite the same pixels as they would if unclipped.
Also if you scroll down, there's source and demo in this thread on faking a scissor test.
Last edited by Cydrak on Thu Jan 03, 2008 3:33 pm; edited 1 time in total
#148200 - Lick - Thu Jan 03, 2008 3:16 pm
Maybe take a look at the window feature?
_________________
http://licklick.wordpress.com
#148202 - elhobbs - Thu Jan 03, 2008 3:45 pm
you could try main memory display fifo. not sure exactly how it works, but you could be able to capture the frame and save it to main memory then set the display to main memory fifo and blend it with the other layers.
#148203 - Peter - Thu Jan 03, 2008 3:58 pm
Cydrak wrote: |
No need for capture. glViewport() clips per-polygon, so you can use that to clip both scenes. The trick is to fix the clip matrix so it looks like the viewport wasn't changed in the first place. |
This is a good idea, but it requires to render both scenes.
When one scene already pushes the NDS to its limit, this appraoch is probably not possible. Or you have to cull both scenes in software (object culling) depending on the cliprectangle. Usually you need object culling in your 3d scene management anway, so maybe it's not too much work to implement it.
_________________
Kind Regards,
Peter
#148210 - silent_code - Thu Jan 03, 2008 5:15 pm
afaik there's 60 hz capture code on the net (search the forum - one of the ds bloom demos is running at 60 hz). capturing a frame once wouldn't hurt performance, then you could just put it into a bg and draw the new scene with "scissor testing" (as Cydrac already pointed out [glViewport()] - it' in the shadow volume demo on my site).
happy coding!
#148213 - kusma - Thu Jan 03, 2008 5:35 pm
Perhaps you could use viewport / scissoring to draw both scenes at the same time?
edit: eh, sorry for posting suggestions that has already been made. I forgot to refresh the page over a long period of time ;)
#148214 - Cydrak - Thu Jan 03, 2008 5:38 pm
Peter: Yeah, it's a tradeoff. Do you give up a large chunk of texture RAM (and if both scenes are animated--framerate), or half your scene polys? Or do you write more code for culling? Something has to give. (And he does say he's getting cramped for textures...)
GBATek has this to say: "Polygons ... fully outside of the View Volume aren't stored in Vertex RAM ... "
So, depending on the scene, it looks like the hardware will do some culling. You still spend time uploading, and on the T&L however, so I'd agree, a good software solution could be worth it.
#148218 - silent_code - Thu Jan 03, 2008 5:53 pm
well, but in the case that both scenes use totally different textures you may still be off better with the capture and without rendering the first scene. temporarily cutting off one bank shouldn't be that painful in a non-gameplay situation like that.
in the end, it all depends on your needs and designs.
good luck with it!
#148220 - DekuTree64 - Thu Jan 03, 2008 6:04 pm
Peter's method is the best, IMO. The only drawback is that it needs almost an entire VRAM bank, but generally during a transition you can fade out the minimap (what else would you use that other screen for?) and steal its VRAM. You could even go fancy and render thin vertical quads near the dividing line with decreasing alpha to make a fuzzy edge.
The viewport split has its uses, but it does jitter, and if you're changing to an entirely different scene, then having all the textures loaded for both scenes during the transition would probably be more VRAM trouble than capture.
Cydrak wrote: |
Peter: Yeah, it's a tradeoff. Do you give up a large chunk of texture RAM (and if both scenes are animated--framerate), or half your scene polys? |
Hmm, both scenes animating is an entirely different beast... Actually the viewport split would be pretty much the only way to go then, since with the capture method, you'd still have to have both scenes loaded, plus 2 VRAM banks since you can't capture to one while it's being used for textures.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#148224 - silent_code - Thu Jan 03, 2008 6:47 pm
maybe Rajveer should say something (considering the scenes, if animated or not - i can't find that info anywhere in his posts and making up every possible implementation needs on our own is a bit of a waste of time, isn't it) to help us help him (where did i hear that before? ...). :^)
so, mister? ;^P
#148228 - Rajveer - Thu Jan 03, 2008 7:34 pm
Thats alot of information! Thanks guys!
Sorry for the late reply, to be honest I was thinking of giving up on the idea. I'm mainly fading to black, unloading and loading, and fading to the new scene. This works great because any jitters and stops caused by this code are hidden to the user.
But giving it some more thought, I can think of some situations where I'd really want the effect, solely during gameplay (I was considering menu changes also before). There'd be no animations, but I'd rather not have any limits on the VRAM as I intend to make full use of it, and it should be full! The 2 scenes will have the same texture data, it would just be a change in the world camera, so no unloading and loading new data during the fade. I won't be maxing out the polys in either scene during the fade but rendering twice will still half the frame rate no?
silent_code wrote: |
Rajveer |
Wow that sounds weird, usually people call me by my nickname :D
#148230 - DekuTree64 - Thu Jan 03, 2008 7:55 pm
Rajveer wrote: |
I won't be maxing out the polys in either scene during the fade but rendering twice will still half the frame rate no? |
Might hurt your frame rate because of sending down more polygons, but the technique of changing the viewport alone doesn't cut you to 30fps or anything.
Sounds like an interesting game. I don't think I've seen anyone do split-screen gameplay on the DS yet :)
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#148233 - Dark Knight ez - Thu Jan 03, 2008 8:41 pm
It's impossible to say use VRAM banks F and H for main and sub BG and just use a (completely black) tiled background scrolling to the right?
_________________
AmplituDS website
#148241 - thoduv - Thu Jan 03, 2008 9:33 pm
Windows have been designed exactly for this usage. Using them should be the best option.
#148243 - Peter - Thu Jan 03, 2008 9:50 pm
thoduv wrote: |
Windows have been designed exactly for this usage. Using them should be the best option. |
I don't see how the windows feature can help here, except the wants to "scissor" the scene with untextured scanlines, but as I understand his post, he wants to have a transition between two 3d scenes. Could you explain me how you would do this with the windows feature? *confused*
_________________
Kind Regards,
Peter
#148276 - M3d10n - Fri Jan 04, 2008 5:37 am
Just to reiterate: the display capture can work without changing the framerate. It just gives you the option to have the 3D output saved on VRAM or even main RAM.
You can set the scene to render both the the screen and RAM, or only to RAM, and by using 2D layers you can make use of the rendered scene in the same frame, as the 60fps glow demo demonstrates. Need for Speed Most Wanted also uses display capture to do overexposure and motion trail effects at 60fps.
#148294 - thoduv - Fri Jan 04, 2008 1:50 pm
Peter wrote: |
thoduv wrote: | Windows have been designed exactly for this usage. Using them should be the best option. |
I don't see how the windows feature can help here, except the wants to "scissor" the scene with untextured scanlines, but as I understand his post, he wants to have a transition between two 3d scenes. Could you explain me how you would do this with the windows feature? *confused* |
Sorry, I misunderstood the question.
Next time, I'll read question twice...
#148378 - Rajveer - Sat Jan 05, 2008 3:13 am
Once again cheers for the advice guys, I'll take a look at it when development has progressed!