# Adding 2 vectors & normalizing result in RegCombiners using nvparse

I’m using a geforce3. Bear in mind I’m pretty new to nvparse (and its odd syntax).
I have an animated ‘normal’ texture (tex1), and a static ‘normal’ texture (tex2).
In the register combiners, I want to add a normal from tex1 to tex2, and normalise the result - then dot product this vector with the light vector (col0).
I’m getting ‘white-out’ when I try this:-

nvparse(
"!!RC1.0
"
// add normal from animated texture (tex1) onto normal from static texture (tex2)
"{
"
" rgb {
"
" discard = expand(tex1);
"
" discard = expand(tex2);
"
" spare0 = sum();
"
" }
"
"}
"

``````	// normalise this vector
"{
``````

"
" rgb {
"
" spare1 = spare0 . spare0;
"
" }
"
"}
"
"{
"
" rgb {
"
" discard = spare0;
"
" discard = half_bias(spare0) * unsigned_invert(spare1);
"
" spare0 = sum();
"
" }
"
"}
"

``````	// dot product the normalised vector with the light vector
"{
``````

"
" rgb {
"
" spare1 = spare0 . expand(col0);
"
" }
"
"}
"

``````	// output the dot product result directly, for testing purposes
"out.rgb = spare1;
``````

"
"out.a = unsigned_invert(zero);
" );

Just a guess, but I think that things in register combiners are always clamped to
[-1,1] so maybe when you add your two normals it is getting truncated.

Try multiplying each normalmap normal by 0.5 before summing them. You could do this either by pre-multiplying the normal maps or using register combiner constants.

– Zeno

I think your error comes from the fact the second normalization stage expects spare0 to be unexpanded (so that half_bias(spare0) effect is expanding and multiplying by 0.5)

try this:

combiner #0:
change both expand to half_bias
(this will do what Zeno suggested)

combiner #2: