Jump to content
  • Advertisement
Sign in to follow this  
svetpet

Black line like in film with DirectX

This topic is 2692 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

Hello. I want to acheive the effect in Fable, for instance, where when dialogue starts(for instance with the presents trader in the beginning) two black lines appears at top and bottom like in film.
How can i acheive this with DirectX?

Share this post


Link to post
Share on other sites
Advertisement
here's the ways:
  1. shader way: either with one shader[using some basic math to skip the middle] or with two shaders, one for high black bar and the one for lower
  2. good old way: map texture with discard flag, fill the black bars on cpu and then unmap
  3. naive method: just create alphamap with blackbars and merge it with your texture with alpha mapping[in shader or in fixed pipeline]
unless ur directx shader version is below 2.0 go with first method

Share this post


Link to post
Share on other sites
Draw a black line at the bottom and another at the top, covering what is behind them, or just change the viewport to not include the bottom and the top of the screen.

Share this post


Link to post
Share on other sites
Nevermind. Just did it with changing the viewport size, but this did change the picture aswell. How can i keep the size of the rendered picture and still change the viewport?
Here is what i did

D3DVIEWPORT9 vp;
vp.X = 0;
vp.Y = 100;
vp.Width = engine->md3dPP.BackBufferWidth;
vp.Height = engine->md3dPP.BackBufferHeight-200;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;

dxDevice->SetViewport(&vp);
dxDevice->Clear(0, 0, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);

dxDevice->BeginScene();

this is invoked in onRender

Share this post


Link to post
Share on other sites
Hidden
IMHO going the shader way is not the best. Either you need to duplicate each and every shader used in the scenery and extend them just with the path to output black in the bars, or else run the extended shaders all the time even in non dialog mode.

Using the viewport seems me both more natural and more efficient. Set the viewport to the top bar and clear with black, set it to the bottom bar and clear with black, set it to the center region and proceed as usual. That means 1 decision every frame (instead of 1 decision every pixel), early bailing out due to clipping in the rasterizer (instead of making decision in the fragment script), and to deal with a single as well as more clean set of shaders.

Share this post


Link to post
Prepend the view transformation with a scaling in vertical dimension only. The scaling factor needs to "undo" the virtual shrinking incorporated by D3D due to the viewport size. Hence it needs to be something like
buffer_height / viewport_height = buffer_height / ( buffer_height - 2 * bar_height )

Share this post


Link to post
Share on other sites
<3 you. Works just fine :)
Here is the final code invoked in onUpdate

D3DVIEWPORT9 vp;
vp.X = 0;
vp.Y = 100;
vp.Width = engine->md3dPP.BackBufferWidth;
vp.Height = engine->md3dPP.BackBufferHeight-200;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;

dxDevice->SetViewport(&vp);
camera->setLens(D3DX_PI * 0.25f, vp.Width/vp.Height, 1.0f, 2000.0f);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!