Jump to content
  • Advertisement
Sign in to follow this  
Shuryou

Transitions

This topic is 4419 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. For my game I need to have transitions in between scenes. Currently I only have crossfades, but that is pretty boring. I looked into some other programs to see how they did transitions. I like RPG Maker's way of doing transitions which is using a 256 colour image, each frame then goes through values 0 - 255 and if a pixel of the transition image is that colour then a pixel from the new scene is drawn in that position. Can anyone please explain how I can do this with DirectX, preferably with C#, but I'll be ok with C++ too.

Share this post


Link to post
Share on other sites
Advertisement
One way

Render your scene to a render target, then set the screen aligned quads' texture to the render target. Change the diffuse color, using time. Then something like this in the pixel shader

struct PS_INPUT
{
float4 Diffuse: COLOR0;
float2 Txr0: TEXCOORD0;
};


float4 ps_main(PS_INPUT In) : COLOR0
{
float4 o = In.Diffuse;
float4 d = tex2D(texture,In.Txr0);
if(o < d)
o = d;
return o;
}




Share this post


Link to post
Share on other sites
Thank you for your help, but I am confused on how I am supposed to do this. First off, here is my pixel shader:


sampler2D Trans;

struct PS_INPUT
{
float Diffuse: COLOR0;
float2 Txr0: TEXCOORD0;
};


float4 Diffuse(PS_INPUT In) : COLOR0
{
float o;
float4 d;

o = In.Diffuse;
d = tex2D(Trans, In.Txr0);

if( o < (d.r+d.b+d.g)/3.0f )
o = d;

return o;
}

technique DiffuseTransition
{
pass P0
{
VertexShader = NULL;
PixelShader = compile ps_2_0 Diffuse();
}
}



And this is my drawing code:


device.Clear(ClearFlags.Target, EngineState.BackgroundColour, 1.0f, 0);
device.BeginScene();

if (trans_running)
{
device.SetRenderTarget(0, tex_render_target.GetSurfaceLevel(0));
secondary.Draw();

device.SetRenderTarget(1, null);

scene_trans.SetValue("Trans", tex_render_target);

trans_sprite.Begin(SpriteFlags.None);
int passes = scene_trans.Begin(EffectFlags.None);

for (int i = 0; i < passes; i++)
{
scene_trans.BeginPass(i);
trans_sprite.Draw(TextureManager.GetTexture(trans_tex), null, Vector3.Empty, Vector3.Empty, GDI.Color.White);
scene_trans.EndPass();
}

scene_trans.End();
trans_sprite.End();

trans_step++;

if (trans_step >= 255)
{
trans_running = false;
TextureManager.FreeTexture(trans_tex);
secondary.Close();
}
}
else
{
primary.Draw();
}

device.EndScene();
device.Present();



What am I doing wrong?

Thanks in advance.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!