Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 505fc29
  • /
  • glsl
  • /
  • mesh_colors_quad.tes
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:2c9833be22045636d5ed3a3ae803cd8e38f60433
directory badge
swh:1:dir:0906aec91d57b1165889895671be426ffdbe1398

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
mesh_colors_quad.tes
#version 430

layout(quads, equal_spacing) in;

in TCS_OUT
{
	vec2 pos;
} vIn[];

out vec4 vertexColor;

uniform vec2 overflow;

patch in uint quadId;

uniform int R;

struct QuadData
{
	vec2 cornerTexCoords[4];
	vec2 texCoords[9];
	uint cPtr;
};

layout(std430, binding = 0) buffer quadData
{
    QuadData quads[];
};

layout(std430, binding = 1) buffer colorData
{
    vec4 c[];
};

vec4 colorDisplacement(uvec2 coord)
{
	vec4 ret;
	ret = c[quads[quadId].cPtr + coord.x + coord.y * (R + 1)];

	return ret;
}

void main(void)
{
	vec2 uv = gl_TessCoord.xy;
	
	uvec2 i = uvec2(round(R * uv));
	vec4 cd = colorDisplacement(i);

	vertexColor = vec4(cd.rgb, 1);	
	const float gamma = 2.2 * 1.2;
	vertexColor.rgb = pow(vertexColor.rgb, vec3(1.0 / gamma));

	vec2 center = quads[quadId].texCoords[4];

	int leftInterpol, rightInterpol;
	float leftWeight;
	if(i.x == 0)
	{
		leftInterpol = rightInterpol = 0;
		leftWeight = 0.5;
	}
	else if(i.x == R / 2)
	{
		leftInterpol = rightInterpol = 1;
		leftWeight = 0.5;
	}
	else if(i.x == R)
	{
		leftInterpol = rightInterpol = 2;
		leftWeight = 0.5;
	}
	else if(i.x < R/2)
	{
		leftInterpol = 0;
		rightInterpol = 1;
		leftWeight = 2 * (0.5 - uv.x);
	}
	else
	{
		leftInterpol = 1;
		rightInterpol = 2;
		leftWeight = 2 * (1 - uv.x);
	}

	int bottomInterpol, topInterpol;
	float bottomWeight;
	if(i.y == 0)
	{
		bottomInterpol = topInterpol = 0;
		bottomWeight = 0.5;
	}
	else if(i.y == R / 2)
	{
		bottomInterpol = topInterpol = 1;
		bottomWeight = 0.5;
	}
	else if(i.y == R)
	{
		bottomInterpol = topInterpol = 2;
		bottomWeight = 0.5;
	}
	else if(i.y < R/2)
	{
		bottomInterpol = 0;
		topInterpol = 1;
		bottomWeight = 2 * (0.5 - uv.y);
	}
	else
	{
		bottomInterpol = 1;
		topInterpol = 2;
		bottomWeight = 2 * (1 - uv.y);
	}

	//leftInterpol = 0;
	//rightInterpol = 2;
	//leftWeight = 1-uv.x;
	//bottomInterpol = 0;
	//topInterpol = 2;
	//bottomWeight = 1-uv.y;

	vec2 p;
	
	//vertexColor.r = leftWeight;
	//vertexColor.g = bottomWeight;

	QuadData quad = quads[quadId];
	p = (1 - uv.x) * ((1 - uv.y) * vIn[0].pos + uv.y * vIn[3].pos) + uv.x * ((1 - uv.y) * vIn[1].pos + uv.y * vIn[2].pos);
	p = leftWeight * (bottomWeight * quad.texCoords[leftInterpol + 3 * bottomInterpol] + (1 - bottomWeight) * quad.texCoords[leftInterpol + 3 * topInterpol])
		+ (1 - leftWeight) * (bottomWeight * quad.texCoords[rightInterpol + 3 * bottomInterpol] + (1 - bottomWeight) * quad.texCoords[rightInterpol + 3 * topInterpol]);

	if(overflow != vec2(0, 0))
		p = p + normalize(p - center) * overflow;

	gl_Position = vec4(2 * p - vec2(1, 1), 0, 1);
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API