Posted By: Yulor
Good first few shaders? - 03/15/05 12:58
What would be a few good shaders to try and make at first?
I want to get into shader development.
I want to get into shader development.
Quote:
Wolfgang Engel's "Pixel & Vertexshader" book looks quite nice and it has samples in it.
Quote:
If you understand all that im saying here, then you can move on to doing more interesting things. First try to doing some sort of multitexturing, like detail mapping. Simply blend the color texture with a detail texture by multiplying the samplers together. Then you can go on to more complex things.
Quote:That's why I recommended the other book. It also has a glossary in the back. Shader X2/3 is for advanced shader programmers.
If all the people in these books didn't just assume I already know how to code shaders, then I may just learn something from them..
Quote:
See this is what really keeps me back on shaders, what is a 'detail map' exactly, and what are the 'samplers?'
//this is the only matrix you need for this shader.. world*view*projection
float4x4 matWorldViewProj;
here is the vertex shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
};
//simple vertex shader calculates the vertex position and tex coords
VS_OUTPUT mainVS( float4 Pos : POSITION,
float2 Tex : TEXCOORD0 )
{
VS_OUTPUT Out = (VS_OUTPUT) 0;
Out.Pos = mul(Pos,matWorldViewProj );
Out.Tex = Tex;
return Out;
}
texture entSkin1;
//define the sampler for the entity skin
sampler basemap = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = clamp;
AddressV = clamp;
};
// Simple pixel shader samples the entity skin according to Tex.xy coords
float4 mainPS(float2 Tex: TEXCOORD0) : COLOR {
Color = tex2D( basemap, Tex.xy);
return Color;
}
technique blur
{
pass Object
{
alphablendenable=false;
ZENABLE = TRUE;
VertexShader = compile vs_1_1 mainVS();
PixelShader = compile ps_2_0 mainPS();
}
}