~eliasnaur/gio-shader

abcd0e01d40c2aca541d3393b7f93be5809d8701 — Elias Naur 1 year, 1 month ago 64959e2 v1.0.7
gui: add opacity support to the blit shader

This is required to enable opacity layers in Gio.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
M gio/blit.frag => gio/blit.frag +2 -1
@@ 5,11 5,12 @@
precision mediump float;

layout(location=0) in highp vec2 vUV;
layout(location=1) in highp float opacity;

{{.Header}}

layout(location = 0) out vec4 fragColor;

void main() {
	fragColor = {{.FetchColorExpr}};
	fragColor = opacity*{{.FetchColorExpr}};
}

M gio/blit.vert => gio/blit.vert +3 -0
@@ 12,6 12,7 @@ layout(push_constant) uniform Block {
	vec4 transform;
	vec4 uvTransformR1;
	vec4 uvTransformR2;
	float opacity;
} _block;

layout(location = 0) in vec2 pos;


@@ 19,9 20,11 @@ layout(location = 0) in vec2 pos;
layout(location = 1) in vec2 uv;

layout(location = 0) out vec2 vUV;
layout(location = 1) out float opacity;

void main() {
	vec2 p = pos*_block.transform.xy + _block.transform.zw;
	gl_Position = vec4(transform3x2(windowTransform, vec3(p, 0)), 1);
	vUV = transform3x2(m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz), vec3(uv,1)).xy;
	opacity = _block.opacity;
}

M gio/shaders.go => gio/shaders.go +5 -5
@@ 13,7 13,7 @@ var (
	Shader_blit_frag = [...]shader.Sources{
		{
			Name:   "blit.frag",
			Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}},
			Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "opacity", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 1}},
			Uniforms: shader.UniformsReflection{
				Locations: []shader.UniformLocation{{Name: "_color.color", Type: 0x0, Size: 4, Offset: 112}},
				Size:      16,


@@ 21,7 21,7 @@ var (
		},
		{
			Name:   "blit.frag",
			Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}},
			Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "opacity", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 1}},
			Uniforms: shader.UniformsReflection{
				Locations: []shader.UniformLocation{{Name: "_gradient.color1", Type: 0x0, Size: 4, Offset: 96}, {Name: "_gradient.color2", Type: 0x0, Size: 4, Offset: 112}},
				Size:      32,


@@ 29,7 29,7 @@ var (
		},
		{
			Name:     "blit.frag",
			Inputs:   []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}},
			Inputs:   []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "opacity", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 1}},
			Textures: []shader.TextureBinding{{Name: "tex", Binding: 0}},
		},
	}


@@ 79,8 79,8 @@ var (
		Name:   "blit.vert",
		Inputs: []shader.InputLocation{{Name: "pos", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "uv", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 2}},
		Uniforms: shader.UniformsReflection{
			Locations: []shader.UniformLocation{{Name: "_block.transform", Type: 0x0, Size: 4, Offset: 0}, {Name: "_block.uvTransformR1", Type: 0x0, Size: 4, Offset: 16}, {Name: "_block.uvTransformR2", Type: 0x0, Size: 4, Offset: 32}},
			Size:      48,
			Locations: []shader.UniformLocation{{Name: "_block.transform", Type: 0x0, Size: 4, Offset: 0}, {Name: "_block.uvTransformR1", Type: 0x0, Size: 4, Offset: 16}, {Name: "_block.uvTransformR2", Type: 0x0, Size: 4, Offset: 32}, {Name: "_block.opacity", Type: 0x0, Size: 1, Offset: 48}},
			Size:      52,
		},
	}
	//go:embed zblit.vert.0.spirv

M gio/zblit.frag.0.dxbc => gio/zblit.frag.0.dxbc +0 -0
M gio/zblit.frag.0.glsl100es => gio/zblit.frag.0.glsl100es +2 -1
@@ 9,10 9,11 @@ struct Color

uniform Color _color;

varying highp float opacity;
varying highp vec2 vUV;

void main()
{
    gl_FragData[0] = _color.color;
    gl_FragData[0] = _color.color * opacity;
}


M gio/zblit.frag.0.glsl150 => gio/zblit.frag.0.glsl150 +2 -1
@@ 8,10 8,11 @@ struct Color
uniform Color _color;

out vec4 fragColor;
in float opacity;
in vec2 vUV;

void main()
{
    fragColor = _color.color;
    fragColor = _color.color * opacity;
}


M gio/zblit.frag.0.metallibios => gio/zblit.frag.0.metallibios +0 -0
M gio/zblit.frag.0.metallibiossimulator => gio/zblit.frag.0.metallibiossimulator +0 -0
M gio/zblit.frag.0.metallibmacos => gio/zblit.frag.0.metallibmacos +0 -0
M gio/zblit.frag.0.spirv => gio/zblit.frag.0.spirv +0 -0
M gio/zblit.frag.1.dxbc => gio/zblit.frag.1.dxbc +0 -0
M gio/zblit.frag.1.glsl100es => gio/zblit.frag.1.glsl100es +2 -1
@@ 10,10 10,11 @@ struct Gradient

uniform Gradient _gradient;

varying highp float opacity;
varying highp vec2 vUV;

void main()
{
    gl_FragData[0] = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0)));
    gl_FragData[0] = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0))) * opacity;
}


M gio/zblit.frag.1.glsl150 => gio/zblit.frag.1.glsl150 +2 -1
@@ 9,10 9,11 @@ struct Gradient
uniform Gradient _gradient;

out vec4 fragColor;
in float opacity;
in vec2 vUV;

void main()
{
    fragColor = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0)));
    fragColor = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0))) * opacity;
}


M gio/zblit.frag.1.metallibios => gio/zblit.frag.1.metallibios +0 -0
M gio/zblit.frag.1.metallibiossimulator => gio/zblit.frag.1.metallibiossimulator +0 -0
M gio/zblit.frag.1.metallibmacos => gio/zblit.frag.1.metallibmacos +0 -0
M gio/zblit.frag.1.spirv => gio/zblit.frag.1.spirv +0 -0
M gio/zblit.frag.2.dxbc => gio/zblit.frag.2.dxbc +0 -0
M gio/zblit.frag.2.glsl100es => gio/zblit.frag.2.glsl100es +2 -1
@@ 4,10 4,11 @@ precision highp int;

uniform mediump sampler2D tex;

varying highp float opacity;
varying highp vec2 vUV;

void main()
{
    gl_FragData[0] = texture2D(tex, vUV);
    gl_FragData[0] = texture2D(tex, vUV) * opacity;
}


M gio/zblit.frag.2.glsl150 => gio/zblit.frag.2.glsl150 +2 -1
@@ 3,10 3,11 @@
uniform sampler2D tex;

out vec4 fragColor;
in float opacity;
in vec2 vUV;

void main()
{
    fragColor = texture(tex, vUV);
    fragColor = texture(tex, vUV) * opacity;
}


M gio/zblit.frag.2.metallibios => gio/zblit.frag.2.metallibios +0 -0
M gio/zblit.frag.2.metallibiossimulator => gio/zblit.frag.2.metallibiossimulator +0 -0
M gio/zblit.frag.2.metallibmacos => gio/zblit.frag.2.metallibmacos +0 -0
M gio/zblit.frag.2.spirv => gio/zblit.frag.2.spirv +0 -0
M gio/zblit.vert.0.dxbc => gio/zblit.vert.0.dxbc +0 -0
M gio/zblit.vert.0.glsl100es => gio/zblit.vert.0.glsl100es +3 -0
@@ 11,6 11,7 @@ struct Block
    vec4 transform;
    vec4 uvTransformR1;
    vec4 uvTransformR2;
    float opacity;
};

uniform Block _block;


@@ 18,6 19,7 @@ uniform Block _block;
attribute vec2 pos;
varying vec2 vUV;
attribute vec2 uv;
varying float opacity;

vec3 transform3x2(m3x2 t, vec3 v)
{


@@ 33,5 35,6 @@ void main()
    m3x2 param_2 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz);
    vec3 param_3 = vec3(uv, 1.0);
    vUV = transform3x2(param_2, param_3).xy;
    opacity = _block.opacity;
}


M gio/zblit.vert.0.glsl150 => gio/zblit.vert.0.glsl150 +3 -0
@@ 11,6 11,7 @@ struct Block
    vec4 transform;
    vec4 uvTransformR1;
    vec4 uvTransformR2;
    float opacity;
};

uniform Block _block;


@@ 18,6 19,7 @@ uniform Block _block;
in vec2 pos;
out vec2 vUV;
in vec2 uv;
out float opacity;

vec3 transform3x2(m3x2 t, vec3 v)
{


@@ 33,5 35,6 @@ void main()
    m3x2 param_2 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz);
    vec3 param_3 = vec3(uv, 1.0);
    vUV = transform3x2(param_2, param_3).xy;
    opacity = _block.opacity;
}


M gio/zblit.vert.0.metallibios => gio/zblit.vert.0.metallibios +0 -0
M gio/zblit.vert.0.metallibiossimulator => gio/zblit.vert.0.metallibiossimulator +0 -0
M gio/zblit.vert.0.metallibmacos => gio/zblit.vert.0.metallibmacos +0 -0
M gio/zblit.vert.0.spirv => gio/zblit.vert.0.spirv +0 -0