3
votes

First off, I'm completely new to DirectX11. As Microsoft deprecated Effects & D3DX with the release of Windows 8, I want to use an alternative to Effects. However I have no idea how to do it, I just know that every HLSL file has to have 1 entry point for the specific shader (vertex, pixel, compute, ...). That's basically it, so, does anyone know a good tutorial about hlsl shaders without effects? Or could someone tell me how they do it?

Thanks in advance!

1
You can still use Effects even if Microsoft has deprecated them.Ross Ridge
I know, but I would rather notRakete1111

1 Answers

5
votes

If you're completely new to DirectX and want to jump right into the newest version for Windows 8, what you're looking for is a tutorial for DirectX 11.1 or DirectX 11.2. I would suggest this specific tutorial to help you understand the matter of shaders:

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

It's a part of DirectX 11.1 tutorials for Windows 8 so you should be good following them all to learn the parts do DX 11.1 that you still don't understand.

So now, let me sum up the tutorial about how shaders are handled without effects in the new world of DX 11.1.

HLSL shader files are now part of Visual studio sollutions. You should create separate files for vertex and pixel shaders. They will be compiled with your program code so what you should load at runtime is an already compiled binary code. You store this code in a byte arrays (eg. 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 that:

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

I hope it makes this issue clear.