sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 638 forks source link

How to compile shaders in UWP? #822

Closed KySpace closed 7 years ago

KySpace commented 7 years ago

I wish to use this method

byte[] vertexShaderByteCode = ShaderBytecode.CompileFromFile(".......Transf_VS.hlsl", "VS", "vs_5_0");
                this.vertexShader = new D3D11.VertexShader(
                    device,
                    vertexShaderByteCode
                    );

But it throws exception of either file not found or file cannot be open. Is there any solution to this? I saw HelixToolkit using shader files that has already been compiled, how is it done then? Thank you

KySpace commented 7 years ago

I have posted similar questions here and here, please someone take a notice http://gamedev.stackexchange.com/questions/132777/how-to-compile-shader-files-in-uwp/132830#132830 http://gamedev.stackexchange.com/questions/132838/i-dont-think-my-shaders-are-working-looking-for-help

bdachev commented 7 years ago

To precompile the shaders in your project you could use the following command line tool that comes with SDK: https://msdn.microsoft.com/en-us/library/windows/desktop/bb232919(v=vs.85).aspx I think there also exist some extensions to visual studio that allow you to compile shader code as a custom action.

KySpace commented 7 years ago

Solutions have been found. It's rather complicated, and I've posted it here http://gamedev.stackexchange.com/questions/132777/how-to-compile-shader-files-in-uwp/132830#132830