Using more fx effect in one quad

Started by
18 comments, last by Adaline 10 years, 2 months ago

Hi guys ,

I have the same question a : http://www.gamedev.net/topic/366864-shader-effect-/

so , how i can use two effects (fx) in one quad ?

thanks

Advertisement

You either draw the quad twice, or you merge the code from both fx files together into a single effect.

You either draw the quad twice, or you merge the code from both fx files together into a single effect.

thanks for your reply ,i do what you say for draw quad twice , but that doesn't work :(

i do the following :

effect1 begin(...)

beginPass()

draw_quad()

EndPass()

effect1 End()

effect2 begin(...)

beginPass()

draw_quad()

EndPass()

effect2 End()

---------------------------

But doesnt work !!

You have to explain what it is that you're trying to do, what the effects are, and what "doesn't work" means.

Drawing the quad twice (each time using a different effect) is a solution to what you asked - to use two effects on one quad. The quad is being drawn using two different effects, but this probably isn't what you actually want to do!

What's the actual problem that you're trying to solve?

I have two effects (blur and bloom) , My problem is that the first effect is overwritten by the second effect , in final render i see just the second effect


My problem is that the first effect is overwritten by the second effect

Then you should probably render the second somewhere else besides on the same render target as the first effect.

Still more information needed to give any more details than that.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I have two effects (blur and bloom) , My problem is that the first effect is overwritten by the second effect , in final render i see just the second effect

A solution is to render the first effect onto a 'temporary' texture, then to render the second effect from this texture (not as a render target anymore but as a shader resource) on your final render target.


My problem is that the first effect is overwritten by the second effect

Then you should probably render the second somewhere else besides on the same render target as the first effect.

Still more information needed to give any more details than that.

L. Spiro

I want to combine two post process in one quad.

I have two effects (blur and bloom) , My problem is that the first effect is overwritten by the second effect , in final render i see just the second effect

A solution is to render the first effect onto a 'temporary' texture, then to render the second effect from this texture (not as a render target anymore but as a shader resource) on your final render target.

I'm using the same texture a the first render target , but finally i get the second effect !!.
can you give me small exemple ?

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 ...

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 !!

This topic is closed to new replies.

Advertisement