Vectrosity: SetCamera(), aspect, resolution and rendertextures

Hi all! (and Eric, perhaps, particularly? :wink: )

I’m trying to draw some basic lines and points with Vectrosity. Its default settings work fine. One issue is that I need them drawn on top of GUI controls drawn using UnityGUI. These are always drawn last, with no way to change it, so to get around that, I’d like to render the Vectrosity lines into a RenderTexture, and then just display that in a call to GUI.DrawTexture.

My problem with this approach is that the rendertexture has a resolution and aspect ratio which are radically different from the screen’s. I need the rendertexture’s resolution to be 600x40, resulting in an aspect ratio of 600/40 = 15. The methods which set the camera with which Vectrosity renders its linemeshes do not pick up neither the aspect ratio nor the rendertarget of the camera I’m passing to it. I’m doing this:

RenderTexture PowerLinesRT = new RenderTexture(600, 40, 0, RenderTextureFormat.ARGB32); // No depth buffer needed. Will only contain 2D lines
camera.aspect = 600 / 40; // = 15
camera.targetTexture = PowerLinesRT;
VectorLine.SetCamera(camera); // Creates a camera for the vectorlines, but does not pick up the custom aspect ratio or the rendertarget

// I expect these endpoints to define a horizontal line from one end of the rendertexture to the other, 10 pixels from the top
Vector2 feedthroughStart = new Vector2(0, PowerLinesRT.height - 10);
Vector2 feedthroughStop = new Vector2(PowerLinesRT.width-1, PowerLinesRT.height - 10);

// PowerLineOffColor and PowerLineOff are colors and materials set in the editor, they work as expected
FeedthroughLine = new VectorLine("Feedthrough", new Vector2[] { feedthroughStart, feedthroughStop }, PowerLineOffColor, PowerLineOff, 20);

I tried to further customize the camera by picking up the reference returned by SetCamera, i.e. I can do this:

Camera vectrosityCam = VectorLine.SetCamera(camera); // Creates a camera for the vectorlines, but does not pick up the custom aspect ratio or the rendertarget
vectrosityCam.aspect = 600 / 40; // = 15
vectrosityCam.targetTexture = PowerLinesRT; // Manually set the vectrosity camera's rendertarget instead

This gives the vectrosity camera the desired aspect ratio and rendertarget. But it does not pick up the rendertexture’s resolution. The coordinates given to VectorLine’s constructor afterwards still look like they generate a mesh relative to the Screen’s resolution, and not the rendertexture’s. This is a problem. I’d really like to be able to give it coordinates relative to the rendertexture’s resolution. Is there a way to make it understand that? Or am I doing something really silly here?

The bad news is, it’s not quite that simple. The good news is, it so happens that Vectrosity 2.1 has a SetCameraRendertexture function, which makes the vector camera use a rendertexture, like this:

VectorLine.SetCameraRendertexture (myRenderTexture);

Then you can use

VectorLine.SetCameraRendertexture (null);

to make it stop rendering to a rendertexture. The other bad news is, Vectrosity 2.1 isn’t out yet. The other good news is, it will be out Real Soon Now (after I update the docs).