Sign in to follow this  
jazztuffy

shaders basic question

Recommended Posts

By "one program" do you mean in the same file ?

Yes you can combine the pixel and vertex shader into the same shader file, then deal with techniqes and passes in your code rather than indivdual pixel and vertex programs, though this is just a conveinence feature underneath the system will just be calling SetPixelShader/SetVertexShader:


VertexOut SimpleVS (VertexIn In)
{

VertexOut Out=(VertexOut)0;
Out.oPosition = mul(In.position , modelViewProj );
Out.oColor = In.color;
Out.oDiffuseUV = In.uv;
Out.oLocalPos = In.position;
Out.oLocalNormal = In.normal;

return Out;
}


float4 SimplePS(float4 color_in : COLOR, float2 uv : TEXCOORD0, float3 localPos : TEXCOORD1, float3 normal : TEXCOORD2) : COLOR
{
.
.
}

technique Simple
{
pass p0
{
VertexShader = compile vs_3_0 SimpleVS();
PixelShader = compile ps_3_0 SimplePS();
}
}



You cannot combine pixel and vertex shader commands in the same actual program as they do different things in the graphics hardware (you cannot have a single "main" function that is used by the pixel and vertex shader). The "unified" shader archtitecture that is implemented by ATI just means the different shaders share the same registers ect. (so that GPR that are not used by the vertex shader can be used by the pixel shader and vice versa) they are still doing very diffrent things.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The most common way is to combine shaders, actually I can't think of one single time where I just used one of them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this