Commit 936b472d authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

BF: Need separate x/y scaling factors in NDC (e.g. what if canvas is not square)

parent bd8a9c15
......@@ -37,11 +37,12 @@ out vec3 fragVertex;
out vec3 fragNormal;
/*
* Line/cylinder width - must be defined
* in terms of normalised device coordinates
* Line width scaling factors along x/y
* axesa - must be defined in terms of
* normalised device coordinates
* (i.e. after MVP has been applied).
*/
uniform float lineWidth;
uniform vec2 lineWidth;
/* Not used */
uniform int resolution;
......@@ -73,7 +74,7 @@ void main(void) {
projstart = start - camera * dot(start, camera);
projend = end - camera * dot(end, camera);
offset = projend - projstart;
offset = normalize(cameraRotation * offset) * lineWidth / 2;
offset = normalize(cameraRotation * offset) * vec3(lineWidth, 0) / 2;
// Lighting is not currently applied
// to line geometry, but we should
......
......@@ -38,12 +38,14 @@ out float fragClipVertexData;
out vec3 fragVertex;
out vec3 fragNormal;
/*
* Line/cylinder width - must be defined
* in terms of normalised device coordinates
* Tube width scaling factors along x/y
* axesa - must be defined in terms of
* normalised device coordinates
* (i.e. after MVP has been applied).
*/
uniform float lineWidth;
uniform vec2 lineWidth;
/*
* Cylinder resolution - it will be drawn
......@@ -99,7 +101,7 @@ void main(void) {
// Offset from the line at the current angle,
// on the plane perpendicular to the line.
offset = normalize(((normalx * cosa) + (normaly * sina)));
scaledOffset = offset * lineWidth / 2;
scaledOffset = offset * vec3(lineWidth, 0) / 2;
{% if colourMode == 'orientation' %}
fragOrient = geomOrient[0];
......
......@@ -264,7 +264,9 @@ class GLTractogram(globject.GLObject):
canvas = self.canvas
scaling = affine.concat(canvas.projectionMatrix,
canvas.viewScale)
lineWidth = lineWidth * scaling[0, 0]
lineWidth = [lineWidth * scaling[0, 0],
lineWidth * scaling[1, 1]]
else:
# return separate scales for each axis
lineWidth = affine.transform([lineWidth] * 3, mvp, vector=True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment