Skip to main content
gamedev.net
🔒 Locked

FX Composer - Passing Annotations into Array

Started by steviedisco 0 replies 1.7k views
Original Post
steviedisco
steviedisco
Hi,

I'm currently learning shaders and have gone through all the basics (diffuse, specular lighting etc). The examples that I have read have referred to a one-light system.

Within FX Composer, you can tie lights to variables via the use of annotations and semantics. I've extended my base shader to two lights, but that is hard-coded. For instance:


float4 LightDirection1 : DIRECTION <
string Object = "Light0";
string UIName = "Light Direction 1";
string Space = "World";
> = {-0.5f, 2.0f, 1.25f, 1.0};

float4 LightDirection2 : DIRECTION <
string Object = "Light1";
string UIName = "Light Direction 2";
string Space = "World";
> = {0.5f, 1.0f, 0.5f, 1.0};


I'm trying to set up a more general case for an abitrary number of lights, say 3. I'd rather have an array of light structs like so:


struct Light
{
float4 Position : POSITION;
float4 Direction : DIRECTION;
float4 Color : COLOR;
};

Light Lights[3];


Any idea how to tie FX Composer's light objects to this via annotations? I can't seem to get it to work, I've made all sorts of attempts, but nothing will compile.

Do I need to do this via scripting or am I missing something simple? I think I know how to do this if I was connecting into my DirectX app, but I'm trying to keep it all within FX Composer while I develop.

Help a brother! Many thanks.
steviedisco
steviedisco
I got closer, but I think by the looks of what I have read I am trying to achieve the impossible, as far fetched as that might seem.

It appears that it *should* be possible like follows:


float3 LightPositions[MAXLIGHTS] : POSITION
<
string SasBindAddress = "Sas.Light<li>.Position";
>;

float3 LightDirections[MAXLIGHTS] : DIRECTION
<
string SasBindAddress = "Sas.Light<li>.Direction";
>;

float4 LightColors[MAXLIGHTS] : COLOR
<
string SasBindAddress = "Sas.Light<li>.Color";
>;


but either FX Composer doesn't support that method of SAS Binding or it used to and now doesn't. I can't seem to find any concrete information on this, just bits and pieces on forums which seem years old.

I can't be the only one wanting to do this can I?

I can work around it I think, just set a limit on the number of lights (say, 3) and hard-code the bindings in, but it would have been nice to have this all wrapped up in a neat little package.

To be honest, I'm not working toward a particular goal (ie, plugging into an engine), I'm just playing and expanding on what I've learnt so I can build up a good knowledge of shaders and in particular how FX Composer works. I could always take it right out of FX Composer and run it through a C++ app, in which case I could easily get it to work, but it would have been nice to get it all tied up in one environment.

oh well

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.