XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Help! Optimization Tutorial: Particles : undeclared identifier error

Last post 05-03-2008 5:14 PM by KrazyKaveMan. 2 replies.
  • 04-16-2008 7:28 AM

    Help! Optimization Tutorial: Particles : undeclared identifier error

    Hi,

    I'm working through the Optimization Tutorial: Particles and High-Frequency Code sample.

    I've made every change (I think) but I get the following error and can't figure out why or how to fix it - I'm very, very new to this :O)

    Error 1 Errors compiling ... \SimpleScreen.fx:
    .. \SimpleScreen.fx(33): error X3004: undeclared identifier 'AttractorPos' 

     

    the error occurs in this line in the shader code:

    float3 distV = attractorPos - In.ObjectPos;

     

     

    even though earlier in the code, following the tutorial, i have entered:

    struct VS_OUTPUT

    {

    float4 ScreenPos: POSITION;

    float4 VertexColor: COLOR;

    float3 attractorPos;

    };

     

     

    do you think it is an error in the shader code or the C#?

     

    please help!

    Thanks,

    kingkatt

     

  • 04-16-2008 8:09 AM In reply to

    Re: Help! Optimization Tutorial: Particles : undeclared identifier error

    Answer
    Since attractorPos is a member of the VS_OUTPUT structure, you need to qualify that variable reference in your code with a variable of type VS_OUTPUT. 

    In the same line, you have In.ObjectPos.  This means get the variable named ObjectPos, which is a member of the structure type associated with the variable In.  You need to do the same thing with your attractorPos variable.  Somewhere in the same function you should have a variable of type VS_OUTPUT, let's say it is called Output.  Then, you would need Output.attractorPos.
    Microsoft DirectX/XNA MVP
  • 05-03-2008 5:14 PM In reply to

    Re: Help! Optimization Tutorial: Particles : undeclared identifier error

    If anyone is still looking for the answer to this the problem is caused by putting the line:
    float3 attractorPos;

    inside of struct VS_OUTPUT. like this:
    struct VS_OUTPUT
    {
        float3 attractorPos;
        float4 ScreenPos:   POSITION;
        float4 VertexColor: COLOR;
    };

    Solution:
    It must remain outside like this:

    struct VS_OUTPUT
    {
        float4 ScreenPos:   POSITION;
        float4 VertexColor: COLOR;
    };
    float3 attractorPos;
    float halfScreenWidth;
    float halfScreenHeight;
Page 1 of 1 (3 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG