Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does multitexturing work in DX11?

I have a series of shaders that I'm programatically generating by merging a series of fragments. Each fragment can have it's own textures, and it is responsible for uploading/binding the appropriate values.

All of the solutions I've found on Google work either with texture arrays or specifying register (e.g. http://www.rastertek.com/dx11tut17.html). This won't compose well. In GL, this is easy since you look up the texture by name.

Is there a better way here? Or do I have to keep track of how many textures each fragment used to address them by register?

like image 244
LPCRoy Avatar asked Aug 10 '26 05:08

LPCRoy


1 Answers

In OpenGL you use shader program introspection.

DirectX also has such capabilities:

ID3D11ShaderReflection

ID3D11ShaderReflectionConstantBuffer

ID3D11ShaderReflectionType

ID3D11ShaderReflectionVariable

Defined in D3DCompiler_xx.dll

And there are Effects framework (tutorial, reference), which is a wrapper around shader reflection and also allows something like you've made: "series of shaders that I'm programatically generating by merging a series of fragments".

Only one problem is that Microsoft doesn't allows deploying Windows Store Apps, containing these features. But it's okay for desktop apps.

You can find full source code for Effect11 in DirectX SDK, so you can implement such a thing on your own. Also see here for Win8SDK updated version.

Happy coding!

like image 56
Ivan Aksamentov - Drop Avatar answered Aug 13 '26 00:08

Ivan Aksamentov - Drop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!