How to convert PS 2.0 to 3.0 ? [edit : last post]

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

How to convert PS 2.0 to 3.0 ? [edit : last post]

Post by sobieh »

Hi.
Is there a possibility to set couple of shaders to one Material ?

For example to create a primitive Glow effect :
1 - HighPass Filter
2 - DownSample
3 - Horizontal Blur
4 - Vertical Blur

Do i need to render the output of each shader and pass it to another as
(Texture->1->Texture->2->Texture->3->Texture->4->Texture)
or i can pass shader output directly to another
(Texture->1->2->3->4->Texture) ?
Last edited by sobieh on Thu Feb 21, 2008 8:07 pm, edited 2 times in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You have to use a screen quad and two rendertargets.

Render to first render target.
Attach first one to screen quad.
Render this screen quad to second render target.
Attach second one to screen quad.
Render this screen quad to first render target.
Rinse and repeat.

As long as you have 2, you can double buffer them as long as you like.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

So its just as i thod. Thanks for reply.
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

I have another question about HLSL shaders so i append it to this thread :

1. Whats the difference between Shader Model 2.0 and 3.0 ?
2. What do i have to change in 2.0 pixel shaders to use it as 3.0 ?
3. Is the 3.0 faster/better than 2.0 ?

Example primitive PS code:

Code: Select all

sampler2D tex0 : register( s0 );

float4 highpass_demo ( float2 tex : TEXCOORD0, float4 color  : COLOR0 ) : COLOR0
{   
    float4 c = tex2D( tex0 , tex );
    float luminance = max( c.r, max( c.g, c.b ) );
 	
 	if( luminance < 0.7 )
	 { 
		c = 0;
	 }

	return c;                        
}
Frosty Topaz
Posts: 107
Joined: Sat Nov 04, 2006 9:42 pm

Post by Frosty Topaz »

SM3 has more features than SM2. I don't think there's anything in SM2 which isn't in 3 so you shouldn't have to make any changes for it to work (so long as your hardware supports SM3).

If you want details on what's changed you can probably find them in the DirectX docs on MSDN.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
sobieh
Posts: 54
Joined: Sat Feb 09, 2008 11:12 pm

Post by sobieh »

My hardware supports SM 4.0 but it's not the point.

The point is that this shader example i posted doesn't work when i set pixel shader to 3_0. I get whole screen filled by one solid color.

It looks like the texcoord doesn't work on 3_0 so im sure im doing something wrong. Thats why i ask :P I readed about that on MSDN and it's say that on 3.0 texcoord registers were unified with Input registers.

I didn't found any HLSL examples for 3.0 ... only 1.0 and 2.0.
Im looking for "whats new and how to use it" examples :)

I even checked DxSDK for D3D9/10 and it uses 1.4 , 2.0 or 4.0 ... no any usefull 3.0 example ...
Post Reply