I have been learning Direct3D for a while now (DX11), and I ran into a bit of a dead end. I have Frank Luna's book on D3D programming, but I feel like I could find a better tutorial out there. I am at the point of writing the vertex shader (the first one he goes over), and it is confusing me. Anybody have any good references?
Currently, I am using .fx files to write the shaders. Is that right?
I think I got the exact same book, all I can recommend is reading over it again and let it properly sink in until you fully understand what is happening.
And using .fx files is right for writing shaders. But you must also remember that shaders are written in hlsl for DirectX.
After playing around a bit in VS2013 (the new version), I found that they support .hlsl file types. After creating one, the default code is:
1 2 3 4 5
// This is if you select a vertex shader. THere are seperate defaults for different options
float4 main( float4 pos : POSITION ) : SV_POSITION
{
return pos;
}
I guess this is progress? Where would I go from here? What exactly do I do to link the shader to the program itself? I haven't done anything and it seems like the program has already changed after just adding the VertexShader.hlsl file.
You should probably write a pixel shader to accompany your vertex shader. MSDN has great Direct3D11 and 10 tutorials. Any D3D10 resource is very relevant to a Direct3D11 developer, because of the similarity of both APIs (mostly it's just a change from ID3D10* to ID3D11*).
You should also stay away from the Effect framework. IIRC it's depreciated.
I did write a pixel shader - well, no. I clicked "create pixel shader" and one was created for me. But I was really hoping you wouldn't bring up MSDN. I cannot navigate through that at all. The only way it works for me is if I find a link from somehwere. Thanks for the advice on the Effect framework. Now I have two excuses to not use it. (the first being that there are .hlsl files anyway)
I guess this is progress? Where would I go from here? What exactly do I do to link the shader to the program itself? I haven't done anything and it seems like the program has already changed after just adding the VertexShader.hlsl file.
Wait.
Have you created a vertex buffer already? Do you know how to load the shader?