Jump to content

Writing VEX normal map - What's wrong?


JonathanGranskg

Recommended Posts

Hey, I'm getting a syntax error.

"...:16:24: Error 1088: Syntax error, unexpected identifier, expecting ´}´."

 

The error is on the line where I create the matrix and it gives me this error when I try to grab a component of a vector and put it in the matrix. What I want is in the comment. If I replace "Vt.x" with 1 it compiles perfectly.

 

Here's the code:

 

#pragma hint map image
#pragma label map "Normal Map"
#pragma label amp "Amplitude"

surface normalMapTest(float amp = 0.1; string map = "";){
    
    vector Nn = normalize(N);
    vector tex, newN;
    
    // normal map
    if (map != ""){
        tex = texture(map)*2 - {1,1,1};
        vector Vs = normalize((dPds * Dv(t)) - (dPdt * Du(t)));
        vector Vt = normalize(cross(Nn, Vs));
        Vs = normalize(cross(Vt, Nn));
        matrix m = { {Vt.x,0,0}, {0,1,0}, {0,0,1} }; //{{Vt.x, Vt.y, Vt.z}, {Vs.x, Vs.y, Vs.z}, {Nn.x, Nn.y, Nn.z}};
        newN = normalize(tex * m);
    } else {
        newN = Nn;
    }

    F = diffuse(newN);
}

 

Oh and if you see any other errors, please tell me. I wanted to do this as an exercise in VEX Shader Writing.

 

Cheers,

Jonathan

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...