Files
loop/shader/cloud/basic.frag
2023-03-21 16:04:56 +00:00

28 lines
979 B
GLSL

#version 450 core
in vec4 vPosID;
in vec4 vCol;
in vec4 vCenterSize;
in vec4 vControls;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=2) out vec4 fNorm;
void main()
{
// there are quite a few intricate controls concerning the normals
// we want normals to be bigger towards the center, so that when two clouds
// are blended central normals predominate
// similarly, we want normals to be bigger the further up the cloud is
// finally, we want normals to allow for shadows at the edge of a cloud
// when a light is direcly above the cloud
float d = dot(vControls,vControls);
if (d > 1) {discard;}
//fCol = vCol;
fCol = vec4(vCol.xyz,vCol.w*(1-d));
//float rad = vCenterSize.w*0.5;
float rad = vCenterSize.w;
float h = (1-d) * rad;
fPos = vec4(vPosID.xy, vPosID.z + h, vCol.w*(1-d));
vec3 fn1 = fPos.z*normalize(vec3(vCenterSize.xyz - fPos.xyz));
fNorm = vec4(fn1,fPos.w);
}