Jump to content
  • Advertisement
Sign in to follow this  
programci_84

[DX9] Common parameters for all shaders

This topic is 2787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all.

Suppose I've more than one shaders and they include an ".fxh" file like this one:
//common.fxh
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.
-R

Share this post


Link to post
Share on other sites
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 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
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!