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;
}