Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

precompile shader code?

This topic is 2520 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do i have my shader code precompiled into bytecode so i don't have to always make a call to Compile the shader code at runtime from my .fx file? Also Is it best practice to have the shader stages perform transformations from world space to projection or should it be done within my c++ code?

Share this post


Link to post
Share on other sites
Advertisement
Are you using D3D9? You can precompile effects from the command line using fxc.exe (use /Fo to output the binary to an object file), and then load load the binary with D3DXCreateEffectFromFile. You can also use ID3DXEffectCompiler if you want to compile shaders to bytecode in your C++ code.

You should definitely transform your vertices in the vertex shader, that's what they're good at. smile.png

Share this post


Link to post
Share on other sites

How do i have my shader code precompiled into bytecode so i don't have to always make a call to Compile the shader code at runtime from my .fx file? Also Is it best practice to have the shader stages perform transformations from world space to projection or should it be done within my c++ code?


Since there are usually fewer vertices than fragments, its usually a good idea to do as much within the vertex shader as you can. Beware that some values won't interpolate properly however. As with most things, the only way to know for certain is to test it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!