Jump to content
  • Advertisement
Sign in to follow this  
schupf

Includer shader in multiple shader files

This topic is 2341 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

Hello,

I have HLSL shaders in .txt files and I want to use a common function (computeLight()) in multiple shader files. If I write the shader in a file common.psh and include it (with #include "common.psh") in files A.psh and B.psh : Will common.psh be compiled two times (for both A.psh and B.psh) or just one time?

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Hi!

It will be compiled twice. I haven’t seen an option to let fxc dump object files for each included file (and also no way to link against such) so fxc will compile them again. (This is better for optimizations, too). You always have to recompile shaders when an included file changed.

Cheers! smile.png

Share this post


Link to post
Share on other sites
The HLSL compiler will just compile everything. It's very simple in that regard...typically it will just inline everything when generating the assembly (which can be a really good thing, since it will tightly optimize everything along the way). The only real exception is if you use dynamic shader linkage in D3D11.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!