I am new write a pixel shader and use in my managed directx project, where i can get some basic sample to start it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m assuming you know how to create a device.
First, you need to prepare the shader itself.
Here’s a little sample pixel shader (which uses pixel shader 1.4, as seen by ps_1_4; r0 is a register that is read as the final result; v0 is a register that stores primary colour (of diffuse lighting)):
This shader, which is in shader assembly, has to be assembled. You can do that as follows (note that you need D3DX library referenced, otherwise you won’t see the ShaderLoader class):
After assembling the shader, you can finally create a PixelShader object as follows:
To apply the pixel shader, use:
where Device is the Direct3D Device.
A similar process applies for compiling shaders in case you use HLSL.
Edit:
Just noticed this was an year old question.