Jump to content
  • Advertisement
Sign in to follow this  
Drepern

pixel shader question (HLSL)

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

I've just started learning shaders and have with the help of some tutorials written a pixel shader in (HLSL) which blends multiple textures togheter (3 textures, input looks like this). PS_INPUT { float2 t0 : TEXCOORD0; float2 t1 : TEXCOORD1; float2 t2 : TEXCOORD2; }; So I have this terrain where each vertex has position, normal and 3 texture cordinates (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX3). The problem I have is if I enable the pixel shader, the textures blend correctly, but there is no FFP lightning. If i turn off shader the terrain get correctly lit by the FFP lightning, but there is no blend. So is it possible to use the FFP lightning with my pixel shader and what must be done? I dont want to create a vertex shader and write the lightning just yet. Any help would be welcome.

Share this post


Link to post
Share on other sites
Advertisement
They are mutually exclusive - either fixed function or a pixel shader, never both at the same time.

You'll find plenty of examples of implementing lighting models identical or similar to fixed-function online. Look up 'Blinn-Phong' lighting [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Actually, you can mix fixed function vertex processing with a pixel shader (of 1.x or 2.x variety). Just declare your inputs to include a "float4 lighting : color0".

It gets tricky sometimes, as the fixed pipe outputs what ps.1.1 needs, not necessarily what's in your vertex format. For example if your vertex has a single coord, and two stages have texcoordindex set to 0, it outputs two identical texcoords, since you can't read from the coord multiple times in ps.1.1. But this also means you can use special texcoordindex values, like camera space normal, etc.

Share this post


Link to post
Share on other sites
Thanks for the links, also what Namethatnobodyelsetook said works, cheers! I've got it running with the FFP lightning and the pixelshader. I will try to implement a 'Blinn-Phong' lighting model using only shaders in the future.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!