Skip to main content
GameDev.net gamedev.net
🔒 Locked

pixel shader

Started by mirza101 Dec 7, 2005 at 4:07 PM 0 replies 400+ views
Original Post
mirza101
mirza101
how can i use pixel shader? and could someone compare vertex and pixel shaders; what about pixel shader performance.. etc..
jollyjeffers
jollyjeffers
This is a very broad question, so I'll try my best. Post back with more specifics and we'll probably be able to give you a more direct answer.

Given that the programmable pipeline is the way forward, they're fairly well documented in the SDK help files:

Introduction to vertex shaders
Introduction to pixel shaders
Assembly shader reference (note: focus on HLSL)
Introduction to HLSL shaders

Before you even think about using pixel shaders you must consider what hardware you're using - they are very hardware specific. For Direct3D9 development, you'll want to use a Radeon 9500 (and above) or a Nvidia GeForce FX (and above).

After that, it basically follows two steps:

1. Create the pixel shader, that is, write it in HLSL or assembly (see links above). Typically you'll store it in a text file and then load it into your application using D3DXCompileShaderFromFile().

2. Configure your application to use the IDirect3DPixelShader9 object (IDirect3DDevice9::SetPixelShader()) and then configure it's various constants (how you pass parameters from your application for the pixel shader to use). How you configure the constants depends on how you wrote the original pixel shader (ASM or HLSL, and what constants are required).

Quote:
compare vertex and pixel shaders

They are different things. As the names suggest, one works on vertex data (defines the shape of your geometry) and one works on the rasterized pixels (what you actually see on screen). Typically there are many more pixels than there are vertices, such that you can offload common calculations from the pixel shader to the vertex shader to improve performance.

Quote:
what about pixel shader performance..

Can't really answer that. It depends on many factors - what hardware you're running, what shader model you're using, what features you use and how long your shader code is. In general, a good Direct3D9 piece of hardware is good at doing reasonably complex ps_2_0 shaders. Features such as flow control and conditional execution can really hurt performance.

Check out beyond3d for hardware reviews - they often factor shader performance into their reviews.
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.