Sign in to follow this  
rohitgonsalves

Shader connections

Recommended Posts

I am working on a DirectX based software. This software has Number of objects inside. all are 3D. Using these 3D objects one can create some nice effects. Now I am converting everything to DX9. Previously the software was in DX7. I have a simple problem. The object can get a common properties which are coming from the common User interface set for all the objects. The properties are like Position, scaling, rotations, shadow, opacity, fog and lights. I want to write a shader that will take care of all these basic properties. Other shaders can be added as filters. My quiestion is How to handle the hierarchy of these common property shader and filters applied afterwards. CAn anyone give me some good idea to make this things as simple as possible. Is there any way through I can keep My basic property shader available to all other filters?

Share this post


Link to post
Share on other sites
Chances are you want to look into D3DX9's "fragment linker" technology. I've never needed to use it myself and I'm pretty sure it's still missing from D3D10 (with various noises suggesting it won't ever appear) but it should do what you want.

You can only ever have a single VS or PS bound to the pipeline at any one time so ultimately you need to find a way of compiling/generating a single shader from multiple parts. The fragment linker should help do this, but you can also use various conditional compilation tricks to generate many shaders from one set of code. Simple things like using uniform keywords in FX files to allow dead-code elimination or using C-style #ifdef/#endif and #include'ing arbitrary data.

It's not always a trivial problem and there isn't a single perfect way of solving it. SM1 and SM2 both have quite tight instruction count limits so you have to be careful how many pieces you want to smash together into a single shader, otherwise you have to split rendering into multiple passes (etc..)

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
You can only ever have a single VS or PS bound to the pipeline at any one time


This statement solved my problem. Now I have to categorized my shaders and filter shaders accordingly. Thanks for ur reply.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this