[DX9] Common parameters for all shaders

Started by
2 comments, last by MJP 13 years, 4 months ago
Hi all.

Suppose I've more than one shaders and they include an ".fxh" file like this one:
//common.fxhuniform 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.
-R
There's no "hard", and "the impossible" takes just a little time.
Advertisement
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 framefloat4x4 ViewMatrix : register (c0);float4x4 ProjMatrix : register (c4);// These are set every draw callfloat4x4 WorldMatrix : register(c8);


[Edited by - MJP on December 5, 2010 2:38:04 PM]
also check out the "shared" keyword in HLSL
Quote:Original post by skytiger
also check out the "shared" keyword in HLSL


"shared" is the keyword used by effect pools to denote constants shared between different effects.

This topic is closed to new replies.

Advertisement