Sign in to follow this  

[DX9] Common parameters for all shaders

Recommended Posts

Hi all.

Suppose I've more than one shaders and they include an ".fxh" file like this one:
uniform extern float3 g_ViewPos;
uniform extern matrix g_ViewMat;
uniform extern matrix g_ProjMat;

//blah blah blah

You know some parameters can be set per frame (like the parameters above), but some others "must" be set per object (or subset).

Now, what I want to do is this: I want to fill all the parameters declared in common.fxh "once per frame", and these parameters can be used all the other shaders includes common.fxh.

How can I do that?

Thx. in advance.

Share this post

Link to post
Share on other sites
If you want to avoid setting constants every frame you need to either use effect pools, or explicitly assign constants to registers so that there's no overlap. Like this:

// These are only set once per frame
float4x4 ViewMatrix : register (c0);
float4x4 ProjMatrix : register (c4);

// These are set every draw call
float4x4 WorldMatrix : register(c8);

[Edited by - MJP on December 5, 2010 2:38:04 PM]

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