 # Writing VEX normal map - What's wrong?

## 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

##### Share on other sites

use set():

```matrix3 m = set(Vt.x, Vt.y, Vt.z,
Vs.x, Vs.y, Vs.z,
Nn.x, Nn.y, Nn.z);```

Yep, it worked. Thanks for the quick answer!

##### Share on other sites

I'm not 100% sure what you're doing with the matrix (Haven't used a matrix for normal maps yet).

But be sure to change the Normal in object space. N is in camera space.

## Create an account

Register a new account