Fix dust rendering
This commit is contained in:
+2
-17
@@ -1,30 +1,15 @@
|
||||
#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 = vec4(vCol.xyz,vCol.w*(1-d));
|
||||
//fCol = vCol;
|
||||
//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 vCen =
|
||||
//vec3 fn1 = fPos.z*normalize(vec3(vCenterSize.xyz - fPos.xyz));
|
||||
vec3 fn1 = fPos.z*normalize(vec3(vCenterSize.xy - vPosID.xy,0));
|
||||
//fNorm = vec4(fn1,fPos.w);
|
||||
fNorm = vec4(vControls.xy, 0.1 ,fPos.w);
|
||||
fPos = vec4(vPosID.xyz, vCol.w*(1-d));
|
||||
fNorm = vec4(vControls.xy, 0.1 ,fPos.w); // note arbirary 0.1, might want to point downwards at the edges?
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#version 450 core
|
||||
layout (location = 0) in vec4 posID;
|
||||
layout (location = 1) in vec4 col;
|
||||
layout (location = 2) in vec4 centerSize;
|
||||
layout (location = 3) in vec4 controls;
|
||||
//layout (location = 2) in vec4 centerSize;
|
||||
layout (location = 2) in vec4 controls;
|
||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||
out vec4 vPosID;
|
||||
out vec4 vCol;
|
||||
out vec4 vCenterSize;
|
||||
//out vec4 vCenterSize;
|
||||
out vec4 vControls;
|
||||
void main()
|
||||
{
|
||||
gl_Position = theMat * vec4(posID.xyz,1);
|
||||
vPosID = posID;
|
||||
vCol = col;
|
||||
vCenterSize = centerSize;
|
||||
//vCenterSize = centerSize;
|
||||
vControls = controls;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,8 @@ preloadRender = do
|
||||
chasmshader <- makeShaderUsingVBO "positional/blank" [vert, frag] (toFloatVAs [3]) pmTriangles chasmvbo
|
||||
|
||||
putStrLn "Setup cloud VBO, shader"
|
||||
let cloudverxsizes = [4, 4, 4, 4]
|
||||
--let cloudverxsizes = [4, 4, 4, 4]
|
||||
let cloudverxsizes = [4, 4, 4]
|
||||
cloudvbo <- setupVBO (floatSize * sum cloudverxsizes)
|
||||
(cloudshader, cloudebo) <-
|
||||
makeShaderEBO "cloud/basic" [vert, frag] (toFloatVAs cloudverxsizes) pmTriangles cloudvbo
|
||||
|
||||
@@ -22,7 +22,8 @@ pokeCloudVerx :: Ptr Float -> Cloud -> Int -> Int -> (Float, Float) -> IO ()
|
||||
pokeCloudVerx ptr cl nv i (dx, dy) =
|
||||
UV.imapM_ (pokeCloudFloat ptr (nv + i)) $
|
||||
UV.fromList
|
||||
[x, y, cz, 1, r, g, b, a, cx, cy, cz, rad, dx, dy, 0, 0]
|
||||
--[x, y, cz, 1, r, g, b, a, cx, cy, cz, rad, dx, dy, 0, 0]
|
||||
[x, y, cz, 1, r, g, b, a, dx, dy, 0, 0]
|
||||
where
|
||||
V3 cx cy cz = _clPos cl
|
||||
V2 x y = V2 cx cy - rad *.* V2 dx dy
|
||||
@@ -41,7 +42,8 @@ clColor = \case
|
||||
|
||||
pokeCloudFloat :: Ptr Float -> Int -> Int -> Float -> IO ()
|
||||
{-# INLINE pokeCloudFloat #-}
|
||||
pokeCloudFloat ptr nv i = pokeElemOff ptr (nv * 16 + i)
|
||||
--pokeCloudFloat ptr nv i = pokeElemOff ptr (nv * 16 + i)
|
||||
pokeCloudFloat ptr nv i = pokeElemOff ptr (nv * 12 + i)
|
||||
|
||||
pokeCloudIndex :: Ptr GLushort -> Int -> Int -> Int -> Int -> IO ()
|
||||
{-# INLINE pokeCloudIndex #-}
|
||||
@@ -58,7 +60,8 @@ pokeDustVerx :: Ptr Float -> Dust -> Int -> Int -> (Float, Float) -> IO ()
|
||||
pokeDustVerx ptr cl nv i (dx, dy) =
|
||||
UV.imapM_ (pokeDustFloat ptr (nv + i)) $
|
||||
UV.fromList
|
||||
[x, y, cz, 1, r, g, b, a, cx, cy, cz, rad, dx, dy, 0, 0]
|
||||
--[x, y, cz, 1, r, g, b, a, cx, cy, cz, rad, dx, dy, 0, 0]
|
||||
[x, y, cz, 1, r, g, b, a, dx, dy, 0, 0]
|
||||
where
|
||||
V3 cx cy cz = _dsPos cl
|
||||
V2 x y = V2 cx cy - rad *.* V2 dx dy
|
||||
@@ -73,7 +76,8 @@ dustColor = materialColor . _dsType
|
||||
|
||||
pokeDustFloat :: Ptr Float -> Int -> Int -> Float -> IO ()
|
||||
{-# INLINE pokeDustFloat #-}
|
||||
pokeDustFloat ptr nv i = pokeElemOff ptr (nv * 16 + i)
|
||||
--pokeDustFloat ptr nv i = pokeElemOff ptr (nv * 16 + i)
|
||||
pokeDustFloat ptr nv i = pokeElemOff ptr (nv * 12 + i)
|
||||
|
||||
pokeDustIndex :: Ptr GLushort -> Int -> Int -> Int -> Int -> IO ()
|
||||
{-# INLINE pokeDustIndex #-}
|
||||
|
||||
Reference in New Issue
Block a user