Jump to content

  • Log In with Google      Sign In   
  • Create Account


game_developer2013

Member Since 07 Sep 2013
Offline Last Active Mar 29 2014 05:49 AM
-----

Posts I've Made

In Topic: Using more fx effect in one quad

24 January 2014 - 12:31 PM

i still not get it working , is there any exemple ?

thank you Tournicoti


In Topic: Using more fx effect in one quad

17 January 2014 - 06:55 PM

This is my code :

i create an empty texture : D3DXCreateTextureFromFileInMemoryEx(engine_device,buffer,size,width,height,D3DX_FROM_FILE,D3DUSAGE_RENDERTARGET,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_ARGB(255, 255, 0, 255), 0, 0, &RTtexture);



then in render :

i set RTtexture a render target then i use it in first effect :


pixelShader1->SetTexture("textureMap", RTtexture);
pixelShader1->Begin()
for( UINT uPass = 0; uPass < uPasses; ++uPass )
{
    pixelShader1->BeginPass( uPass );
    pixelShader1->CommitChanges();

    engine_device->SetTexture(0,RTtexture);
    
    engine_device->SetStreamSource(0, QUAD_VB, 0, sizeof(SIZE_VERTEX));
    engine_device->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2); ////draw the quad
    pixelShader1->EndPass();

}

then i input the same texture to effect 2
pixelShader2->SetTexture("textureMap", RTtexture);
pixelShader2->Begin()
for( UINT uPass = 0; uPass < uPasses; ++uPass )
{
    pixelShader2->BeginPass( uPass );
    pixelShader2->CommitChanges();

    engine_device->SetTexture(0,RTtexture);
    
    engine_device->SetStreamSource(0, QUAD_VB, 0, sizeof(SIZE_VERTEX));
    engine_device->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);  //// draw the quad
    pixelShader2->EndPass();

}

the result is effect 2 !!!


In Topic: Using more fx effect in one quad

17 January 2014 - 04:42 AM

anyone ?


In Topic: Using more fx effect in one quad

15 January 2014 - 06:59 PM

First one side note:

You don't have to call CommitChanges, SetTexture and SetStreamSource for each pass. They don't change between passes, so calling the methods with the same arguments is just slowing your program.

 

Now to the main problem - you are not doing what people were telling you to do ;)

You need to create an empty texture using D3DXCreateTexture with D3DUSAGE_RENDERTARGET and the same width and height as your backbuffer. I'll refer to this texture as to <RTtexture>.

 

Then, when rendering, you set this <RTtexture> texture as your render target (this step doesn't have to do anything with effect) using device->SetRenderTarget. Now you render the quad with the first effect.

Then you set your backbuffer as the render target again using device->SetRenderTarget. And you also set your <RTtexture> texture as an input (resource) texture for your effect. And you render the quad using the second effect.

 

What happens is this:

- <RTtexture> texture starts as empty.

- you render the result of the first effect to it

- you use the result of the first effect, which now is in <RTtexture>, as input for the second effect

- you render the result of the second effect to the backbuffer and display it

 

Because you render the second effect using a texture which already has the first effect in it, you'll get combined effects.

 

I can't resolve this problem !

when i create a texture as empty , i set it to effect1 and i input it in effect 2 then i use it randertarget .
the problem here is , the RTtexture after first frame is become a randertarget , in this case i can't see the first effect because it overwrite by the second effect.

 

Can you give me small exemple plz happy.png ?


In Topic: Using more fx effect in one quad

15 January 2014 - 06:25 AM

Before the rendering loop :

Create a texture with the same attributes (size, format) as your render target.

 

When rendering :

Render the first effect on this texture as render target.

Render the second effect with this texture as shader resource on your final render target.

 

Here, effect1 result is overwritten by effect 2 result

That's why there's only the second effect 'left' at the end.

 

instead of this :

input->effect1->render target

input->effect2->render target

 

this :

input->effect1->texture

texture->effect2->render target

 

Hope it's more clear ...

 

Thank you man for the fast reply .

 

this what i do :

D3DXCreateTextureFromFileInMemoryEx(engine_device,buffer,size,width,height,D3DX_FROM_FILE,D3DUSAGE_RENDERTARGET,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_ARGB(255, 255, 0, 255), 0, 0, &effect_Texture);



in render i do :

   pixelShader1->SetTexture("textureMap", effect_Texture);
   pixelShader1->Begin()
   for( UINT uPass = 0; uPass < uPasses; ++uPass )
   {
	pixelShader1->BeginPass( uPass );
 	pixelShader1->CommitChanges();

	engine_device->SetTexture(0,effect_Texture);
	
	engine_device->SetStreamSource(0, QUAD_VB, 0, sizeof(SIZE_VERTEX));
	engine_device->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
	pixelShader1->EndPass();

   }

   pixelShader2->SetTexture("textureMap", effect_Texture);
   pixelShader2->Begin()
   for( UINT uPass = 0; uPass < uPasses; ++uPass )
   {
	pixelShader2->BeginPass( uPass );
 	pixelShader2->CommitChanges();

	engine_device->SetTexture(0,effect_Texture);
	
	engine_device->SetStreamSource(0, QUAD_VB, 0, sizeof(SIZE_VERTEX));
	engine_device->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
	pixelShader2->EndPass();

   }

but that give me the second effect !!


PARTNERS