mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +00:00
c/shaders: Tidy and codestyle
This commit is contained in:
parent
0b9bf9c772
commit
08135b6365
|
@ -4,6 +4,7 @@
|
|||
|
||||
#version 460
|
||||
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
layout(set = 0, binding = 2) uniform writeonly restrict image2D target;
|
||||
|
@ -15,6 +16,7 @@ layout(set = 0, binding = 3) uniform restrict Config
|
|||
mat4 transform[2];
|
||||
} data;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
uint ix = gl_GlobalInvocationID.x;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "srgb.inc.glsl"
|
||||
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D source[2];
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "srgb.inc.glsl"
|
||||
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D source[2];
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
#version 460
|
||||
|
||||
layout (location = 0) in vec2 uv;
|
||||
|
||||
layout (set = 0, binding = 0, std140) uniform Transformation {
|
||||
layout (set = 0, binding = 0, std140) uniform Transformation
|
||||
{
|
||||
mat4 mvp;
|
||||
ivec2 offset;
|
||||
ivec2 extent;
|
||||
|
@ -15,16 +15,19 @@ layout (set = 0, binding = 0, std140) uniform Transformation {
|
|||
|
||||
layout (set = 0, binding = 1) uniform sampler2D image;
|
||||
|
||||
layout (set = 1, binding = 0, std140) uniform Equirect {
|
||||
layout (set = 1, binding = 0, std140) uniform Equirect
|
||||
{
|
||||
vec2 scale;
|
||||
vec2 bias;
|
||||
float radius;
|
||||
} equirect;
|
||||
|
||||
layout (location = 0) in vec2 uv;
|
||||
layout (location = 0) out vec4 out_color;
|
||||
|
||||
const float PI = 3.1416;
|
||||
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec2 uv_sub = vec2(ubo.offset) + uv * vec2(ubo.extent);
|
||||
|
|
|
@ -13,10 +13,8 @@ layout (binding = 0, std140) uniform Transformation {
|
|||
|
||||
layout (location = 0) in vec3 position;
|
||||
layout (location = 1) in vec2 uv;
|
||||
|
||||
layout (location = 0) out vec2 out_uv;
|
||||
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
@ -28,7 +26,8 @@ const mat4 mvp = mat4(
|
|||
0, 0, 0, 1
|
||||
);
|
||||
|
||||
void main() {
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp * vec4 (position, 1.0f);
|
||||
gl_Position.y = -gl_Position.y;
|
||||
out_uv = uv;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#version 460
|
||||
|
||||
layout (location = 0) in vec2 uv;
|
||||
|
||||
layout (set = 0, binding = 0, std140) uniform Transformation {
|
||||
mat4 mvp;
|
||||
|
@ -22,11 +21,11 @@ layout (set = 1, binding = 0, std140) uniform Equirect {
|
|||
float lower_vertical_angle;
|
||||
} equirect;
|
||||
|
||||
layout (location = 0) in vec2 uv;
|
||||
layout (location = 0) out vec4 out_color;
|
||||
|
||||
const float PI = 3.1416;
|
||||
|
||||
// #define DEBUG 1
|
||||
|
||||
void main ()
|
||||
{
|
||||
|
@ -40,18 +39,20 @@ void main ()
|
|||
float lat = atan(view_dir.x, -view_dir.z) / (2 * PI);
|
||||
float lon = acos(view_dir.y) / PI;
|
||||
|
||||
#undef DEBUG
|
||||
#ifdef DEBUG
|
||||
int lat_int = int(lat * 1000.0);
|
||||
int lon_int = int(lon * 1000.0);
|
||||
|
||||
if (lat < 0.001 && lat > -0.001)
|
||||
if (lat < 0.001 && lat > -0.001) {
|
||||
out_color = vec4(1, 0, 0, 1);
|
||||
else if (lat_int % 50 == 0)
|
||||
} else if (lat_int % 50 == 0) {
|
||||
out_color = vec4(1, 1, 1, 1);
|
||||
else if (lon_int % 50 == 0)
|
||||
} else if (lon_int % 50 == 0) {
|
||||
out_color = vec4(1, 1, 1, 1);
|
||||
else
|
||||
} else {
|
||||
out_color = vec4(lat, lon, 0, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
float chan = equirect.central_horizontal_angle / (PI * 2.0f);
|
||||
|
@ -64,13 +65,15 @@ void main ()
|
|||
float uvan = equirect.upper_vertical_angle / PI + 0.5f;
|
||||
float lvan = equirect.lower_vertical_angle / PI + 0.5f;
|
||||
|
||||
if (lon < uvan && lon > lvan && lat < uhan && lat > lhan)
|
||||
if (lon < uvan && lon > lvan && lat < uhan && lat > lhan) {
|
||||
|
||||
#ifdef DEBUG
|
||||
out_color += texture(image, vec2(lat, lon)) / 2.0;
|
||||
#else
|
||||
out_color = texture(image, vec2(lat, lon));
|
||||
else
|
||||
} else {
|
||||
out_color = vec4(0, 0, 0, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
#version 460
|
||||
|
||||
layout (binding = 0, std140) uniform Transformation {
|
||||
|
||||
layout (binding = 0, std140) uniform Transformation
|
||||
{
|
||||
mat4 mvp;
|
||||
ivec2 offset;
|
||||
ivec2 extent;
|
||||
|
@ -13,11 +15,10 @@ layout (binding = 0, std140) uniform Transformation {
|
|||
|
||||
layout (location = 0) in vec3 position;
|
||||
layout (location = 1) in vec2 uv;
|
||||
|
||||
layout (location = 0) out vec2 out_uv;
|
||||
|
||||
|
||||
out gl_PerVertex {
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
|
@ -28,6 +29,7 @@ const mat4 mvp = mat4(
|
|||
0, 0, 0, 1
|
||||
);
|
||||
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp * vec4 (position, 1.0f);
|
||||
gl_Position.y = -gl_Position.y;
|
||||
|
|
|
@ -4,22 +4,24 @@
|
|||
|
||||
#version 460
|
||||
|
||||
layout (location = 0) in vec2 uv;
|
||||
|
||||
layout (binding = 0, std140) uniform Transformation {
|
||||
layout (binding = 0, std140) uniform Transformation
|
||||
{
|
||||
mat4 mvp;
|
||||
ivec2 offset;
|
||||
ivec2 extent;
|
||||
bool flip_y;
|
||||
} ubo;
|
||||
|
||||
layout (binding = 1) uniform sampler2D image;
|
||||
|
||||
layout (location = 0) in vec2 uv;
|
||||
layout (location = 0) out vec4 out_color;
|
||||
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec2 uv_sub = vec2(ubo.offset) + uv * vec2(ubo.extent);
|
||||
uv_sub /= textureSize(image, 0);
|
||||
out_color = texture(image, uv_sub);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
#version 460
|
||||
|
||||
layout (binding = 0, std140) uniform Transformation {
|
||||
|
||||
layout (binding = 0, std140) uniform Transformation
|
||||
{
|
||||
mat4 mvp;
|
||||
ivec2 offset;
|
||||
ivec2 extent;
|
||||
|
@ -13,14 +15,14 @@ layout (binding = 0, std140) uniform Transformation {
|
|||
|
||||
layout (location = 0) in vec3 position;
|
||||
layout (location = 1) in vec2 uv;
|
||||
|
||||
layout (location = 0) out vec2 out_uv;
|
||||
|
||||
|
||||
out gl_PerVertex {
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
|
||||
void main() {
|
||||
gl_Position = transformation.mvp * vec4 (position, 1.0f);
|
||||
gl_Position.y = -gl_Position.y;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#version 450
|
||||
|
||||
|
||||
layout (binding = 0) uniform sampler2D tex_sampler;
|
||||
|
||||
layout (location = 0) in vec2 in_ruv;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#version 450
|
||||
|
||||
|
||||
layout (binding = 1, std140) uniform ubo
|
||||
{
|
||||
vec4 vertex_rot;
|
||||
|
|
Loading…
Reference in a new issue