Use vertex pulling for clouds

This commit is contained in:
2025-11-12 19:57:07 +00:00
parent ce1937c78e
commit 409180959c
11 changed files with 202 additions and 107 deletions
+15
View File
@@ -0,0 +1,15 @@
#version 450 core
in vec3 vPos;
in vec4 vCol;
in vec2 vControls;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=2) out vec4 fNorm;
void main()
{
float d = dot(vControls,vControls);
if (d > 1) {discard;}
fCol = vec4(vCol.xyz,vCol.w*(1-d));
fPos = vec4(vPos, vCol.w*(1-d));
fNorm = vec4(-vControls, -0.1 + 0.2 * d ,fPos.w);
}
+25
View File
@@ -0,0 +1,25 @@
#version 450 core
struct CloudPosCol { vec4 pos; vec4 col; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std430, binding = 6) readonly buffer CPos { CloudPosCol data[]; };
const vec2 indices[6] =
{vec2(-1,-1) // 0 2--3
,vec2( 1,-1) // 1 | |
,vec2( 1, 1) // 3 0--1
,vec2(-1,-1) // 0
,vec2(-1, 1) // 2
,vec2( 1, 1) // 3
};
out vec4 vCol;
out vec2 vControls;
out vec3 vPos;
void main()
{
uint i = gl_VertexID / 6;
uint k = gl_VertexID % 6;
vCol = data[i].col;
// vCol = vec4(1,0.5,0,1);
vControls = indices[k];
vPos = vec3(data[i].pos.xy + 20*vControls, data[i].pos.z);
gl_Position = theMat * vec4(vPos,1);
}
+18
View File
@@ -0,0 +1,18 @@
#version 450 core
struct Verx { vec4 pos; vec4 col; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std430, binding = 6) readonly buffer Pos { Verx data[]; };
int indices[6] = {0,1,3,0,3,2};
out vec4 vColC;
out vec4 vColE;
out vec4 vPos;
out vec2 vDist;
void main()
{
uint i0 = gl_VertexID / 6;
uint k = indices[gl_VertexID % 6];
vec4 br =
//gl_Position = theMat * vec4(pos,1);
gl_Position = vec4(pos,1);
vCol = col;
}
-1
View File
@@ -9,6 +9,5 @@ void main()
{
fCol = vCol;
fPos = vPos;
//fNorm = vec4(vNorm.xyz - vPos.xyz,1);
fNorm = vNorm ;
}
+1 -4
View File
@@ -1,7 +1,5 @@
#version 450 core
//struct PosColNorm { vec4 pos; vec4 norm;uint col; uint dummy; };
struct PosColNorm { vec4 pos; uint norm;uint col; };
// I don't know if the dummy is necessary
struct PosColNorm { vec4 pos; uint norm; uint col; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std430, binding = 3) readonly buffer Data { PosColNorm data[]; };
layout (std430, binding = 4) readonly buffer Indices { uint indices[]; };
@@ -12,7 +10,6 @@ void main() {
vPos = data[indices[gl_VertexID]].pos;
vCol = unpackUnorm4x8(data[indices[gl_VertexID]].col);
vNorm = unpackSnorm4x8(data[indices[gl_VertexID]].norm);
//vNorm = n *2 - vec4(1,1,1,1);
gl_Position = theMat * vec4(vPos.xyz,1);
}
//layout (location = 0) in vec4 pos;