swizzle error?

I just want to make sure I’m not missing something here… The following vertex shader code does not seem to work:

		float2 left;
		left  = (_left_sep, 0.0);

The following works:

		float2 left;
		left.x = _left_sep;
		left.y = 0.0;

Basically I have two textures that are overlayed using a vertex/fragment shader, then I have a range slider (_left_sep) that slides one texture over the other texture on a plane (by adding _left_sep to the textcoord). If I use the top code block and move the slider, nothing happens. If I use the lower code block the texture slides across. Am I missing something, or is this a bug?

Cheers,
Paul Mikulecky
Lost Pencil Animation Studios Inc.
http://www.lostpencil.com

I’m not sure if your syntax is correct (have to check Cg manual). I’d assume this should work:

left = float2(_left_sep,0.0);

If it does not, it’s most likely a Cg compiler bug. The best way to check is looking at the generated vertex program assembly - select shader file in project view and the inspector will show the shader after all Cg compilation.

By the way, it’s possible to scroll the texture from script using Material’s SetTextureOffset function.

Thanks Aras, yes this works: float2(_left_sep, 0.0), funny that the one that doesn’t work doesn’t give a compile error or runtime error… Thanks also for the tip regarding the assembly. That will be useful.

As for the texture scrolling - yep, I realize that it can be done easier, but I’m just learning Cg and it was a test to see if I could do it.

Cheers,
Paul Mikulecky
Lost Pencil Animation Studios Inc.
http://www.lostpencil.com