Trying to find a good way to implement custom effect interface

Started by
1 comment, last by brekehan 14 years, 11 months ago
I'm trying to implement custom effect interface for D3D10. (don't ask my why :p The game i'm working on already has custom effect interface for D3D9 and need to do it for D3D10) Here are my problems ... - there's no way to set shader variable based on register number (in dx9, you can do this via setvertexshaderconstant/setpixelshaderconstant ... but not in dx10) - I can't quite figure out how to create/maintain constant shader buffer. For example, say you have the following cbuffer in aaa.fx shared cbuffer { floa44x4 m; float3 n; bool a; } d3d10 effect interface can individually set up each of the shader variables, and i want to do the same for my custom effect interface. Anyone knows how D3D10 effect interface does this?
Advertisement
The shader reflection interface would probably be very helpful to you. The header is d3d10shader.h and the documentation is here: http://msdn.microsoft.com/en-us/library/bb205158(VS.85).aspx

This will let you find all of the important information about your shader, including all variables, their names, their types, where they reside in the constant buffer, and which constant buffer they are in.
I query each effect for its variables, thier types and names.
you can poor through the effect reference on how to do that.

I then have the effect create my own 'material' structure which contains the maps, with each map having the variable name as the key and the approproate type set to the current value for that material. I can then query an effect for a copy of it's 'material' shell, and store it where I like.

When it comes time to change the effect variable values, I change that material I stored to contain the proper values, hand it back to the effect, and the effect iterates through updating its effect variables as necessary.

This system has been excellant in keeping an interface for all manner of effects that may contain differant variables and types. One class suits all.

The only downside is the passing and looking up of strings back and forth. However, for my project I am still rendering 30,000 triangles at more than 1000 FPS. So, we'll see as it gets more complex.

This topic is closed to new replies.

Advertisement