DirectX 11 Compile Single HLSL Files (No Effects)

First, I am completely new to DirectX11. Since Microsoft has been deprecated from Effects and D3DX with the release of Windows 8, I want to use the Effects alternative. However, I have no idea how to do this, I just know that every HLSL file must have 1 entry point for a specific shader (vertex, pixel, computation, ...). Which is basically the case, does anyone know of a good tutorial on hlsl shaders without effects? Or can someone tell me how they do it?

Thanks in advance!

+3


source to share


1 answer


If you are completely new to DirectX and want to jump straight into the newest version for Windows 8, then you are looking for a tutorial for DirectX 11.1 or DirectX 11.2. I would suggest this specific tutorial to help you understand the essence of shaders:

http://www.directxtutorial.com/Lesson.aspx?lessonid=111-4-5

These are part of the DirectX 11.1 tutorials for Windows 8, so you should follow them well to find out which parts of DX 11.1 you still don't understand.

So let me summarize the tutorial on how shaders are handled without effects in the new DX 11.1 world.

HLSL shader files are now part of Visual Studio solutions. You must create separate files for the vertex and pixel shaders. They will be compiled with your program code, so you must load them at runtime - this is already compiled binary. You store this code in byte arrays (e.g. VSFile-> Data and PSFile-> Data) and create shader objects using:



//dev is the Device pointer
dev->CreateVertexShader(VSFile->Data, VSFile->Length, nullptr, &vertexshader);
dev->CreatePixelShader(PSFile->Data, PSFile->Length, nullptr, &pixelshader);

      

then you set active shaders like this:

//devcon is the DeviceContext pointer
devcon->VSSetShader(vertexshader.Get(), nullptr, 0);
devcon->PSSetShader(pixelshader.Get(), nullptr, 0);

      

I hope this problem becomes clear.

+5


source







All Articles