Jump to content
  • Advertisement
Sign in to follow this  
jazztuffy

shaders basic question

This topic is 4476 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

hey is it possible to work with both pixel and vertex shaders together in a sinlge program. if so Can you tell how do i go about. Thank you

Share this post


Link to post
Share on other sites
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!