- tc = position;
- tc_left = vec2(tc.x - 0.5f / textureSize(diffusivity_tex, 0).x, tc.y);
- tc_down = vec2(tc.x, tc.y - 0.5f / textureSize(diffusivity_tex, 0).y);
+ gl_Layer = gl_InstanceID;
+
+ const vec2 half_texel = 0.5f / textureSize(diffusivity_tex, 0).xy;
+
+ vec2 tc = position;
+ vec2 tc_left = vec2(tc.x - half_texel.x, tc.y);
+ vec2 tc_down = vec2(tc.x, tc.y - half_texel.y);
+
+ // Adjust for different texel centers.
+ tc0 = vec3(tc.x - half_texel.x, tc.y, gl_InstanceID);
+ tc_left0 = vec3(tc_left.x - half_texel.x, tc_left.y, gl_InstanceID);
+ tc_down0 = vec3(tc_down.x - half_texel.x, tc_down.y, gl_InstanceID);
+
+ tc1 = vec3(tc.x + half_texel.x, tc.y, gl_InstanceID);
+ tc_left1 = vec3(tc_left.x + half_texel.x, tc_left.y, gl_InstanceID);
+ tc_down1 = vec3(tc_down.x + half_texel.x, tc_down.y, gl_InstanceID);
+
+ line_offset = position.y * textureSize(diffusivity_tex, 0).y - 0.5f;