Add shaders that will just return positional information

This commit is contained in:
2021-08-31 18:32:50 +01:00
parent f58530cbb1
commit 146bab6fe3
18 changed files with 336 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
#version 430 core
in vec4 vColor;
in vec3 vparams;
out vec4 fColor;
void main()
{
float d = (dot(vec2(vparams.xy),vec2(vparams.xy)));
if ( d > 1 || d < vparams.z ) {discard;}
//if ( d > 1 ) {discard;}
fColor = vColor;
//fColor = (10,0,0,10);
}
+37
View File
@@ -0,0 +1,37 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in vec4 vparams [];
out vec4 gColor;
out float gRadIn;
out vec2 angles;
out vec2 dist;
uniform mat4 worldMat;
void main()
{
angles = vparams[0].xy;
vec4 cenPos = gl_in[0].gl_Position;
gColor = vColor[0];
float width = vparams[0].w ;
float rad = vparams[0].z + width;
gRadIn = 1 - width * 2 / rad;
// I am not currently sure why the multiplicand is 4 and not 2
gl_Position = worldMat * vec4 (cenPos.x + rad, cenPos.y + rad, cenPos.z , 1);
dist = vec2 (1,1);
EmitVertex();
gl_Position = worldMat * vec4 (cenPos.x - rad, cenPos.y + rad, cenPos.z , 1);
dist = vec2 (-1,1);
EmitVertex();
gl_Position = worldMat * vec4 (cenPos.x + rad, cenPos.y - rad, cenPos.z , 1);
dist = vec2 (1,-1);
EmitVertex();
gl_Position = worldMat * vec4 (cenPos.x - rad, cenPos.y - rad, cenPos.z , 1);
dist = vec2 (-1,-1);
EmitVertex();
EndPrimitive();
}
+13
View File
@@ -0,0 +1,13 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 2) in vec3 boxXboxYwidth;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 vColor;
out vec3 vparams;
void main()
{
gl_Position = theMat * vec4(position.xyz,1);
vColor = color;
vparams = boxXboxYwidth;
}
+7
View File
@@ -0,0 +1,7 @@
#version 430 core
in vec4 vColor;
out vec4 fColor;
void main()
{
fColor = vColor;
}
+9
View File
@@ -0,0 +1,9 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 vColor;
void main()
{
gl_Position = theMat * vec4(position,1);
vColor = vec4(position,1);
}
+7
View File
@@ -0,0 +1,7 @@
#version 430 core
in vec4 vColor;
out vec4 fColor;
void main()
{
fColor = vColor;
}
+12
View File
@@ -0,0 +1,12 @@
#version 430 core
layout (location = 0) in vec4 position;
layout (location = 1) in vec4 color;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 vColor;
void main()
{
vec4 posxy = theMat * vec4(position.xyz,1);
vec4 posz = theMat * vec4(position.xyw,1);
gl_Position = vec4(posxy.xy,posz.z,1);
vColor = color;
}
+16
View File
@@ -0,0 +1,16 @@
#version 430 core
in vec4 vColor;
in vec2 boxOut;
in vec2 boxIn;
out vec4 fColor;
void main()
{
//float d = x - y - 1 + 2* sqrt(y);
float d = sqrt(boxOut.x) + sqrt(boxOut.y) - 1.0;
// float e = sqrt(f(x,wStart)) + sqrt(f(y,wEnd)) - 1.0;
float e = sqrt(boxIn.x) + sqrt(boxIn.y) - 1.0;
if ( d < 0 || e > 0) { discard; }
fColor = vColor;
}
+76
View File
@@ -0,0 +1,76 @@
#version 430 core
layout (triangles) in;
layout (triangle_strip, max_vertices = 5) out;
in vec4 vColor[];
in vec2 vPosOff[];
in float vRadMag[];
out vec4 gColor;
out float wStart;
out float wEnd;
out vec3 gBoundingBox;
out vec2 box2 ;
vec2 normV2 (vec2 v)
{ return vec2(-v.y,v.x) ;
}
float lhs (vec2 da, vec2 db)
{ return sign(dot(da, normV2(db))) ;
}
float extrapolate (vec2 inOne, vec2 inZeroA, vec2 inZeroB, vec2 xy)
{
float det = inOne.x * (inZeroA.y - inZeroB.y)
+ inZeroA.x * (inZeroB.y - inOne.y)
+ inZeroB.x * (inOne.y - inZeroA.y)
;
float r = (inZeroA.y - inZeroB.y) ;
float s = (inZeroB.x - inZeroA.x) ;
float t = (inZeroA.x * inZeroB.y - inZeroB.x * inZeroA.y) ;
return r * xy.x + s * xy.y + t
/ det ;
}
void main()
{
vec3 pa = gl_in[0].gl_Position.xyz;
vec3 pb = gl_in[1].gl_Position.xyz;
vec3 pc = gl_in[2].gl_Position.xyz;
wStart = vRadMag [0];
wEnd = vRadMag [2];
box2 = vec2 (1,0);
gBoundingBox = vec3 (0.9,0.1,0);
gColor = vColor[0];
gl_Position = vec4 (vPosOff[0] , pa.z , 1);
EmitVertex();
box2 = vec2 (0,1);
gBoundingBox = vec3 (0.1,0.9,0);
gColor = vColor[2];
gl_Position = vec4 (vPosOff[2] , pc.z , 1);
EmitVertex();
box2 = vec2( extrapolate(vPosOff[0],vPosOff[2],pb.xy,pa.xy)
, extrapolate(vPosOff[2],vPosOff[0],pb.xy,pa.xy)
) ;
box2 = vec2(0.2,0);
gBoundingBox = vec3 (1,0,1);
gColor = vColor[0];
gl_Position = vec4 (pa, 1);
EmitVertex();
box2 = vec2( extrapolate(vPosOff[0],vPosOff[2],pb.xy,pc.xy)
, extrapolate(vPosOff[2],vPosOff[0],pb.xy,pc.xy)
) ;
box2 = vec2(0,0.2);
gBoundingBox = vec3 (0,1,1);
gColor = vColor[2];
gl_Position = vec4 (pc, 1);
EmitVertex();
box2 = vec2( 0,0 ) ;
gBoundingBox = vec3 (0,0,0);
gColor = vColor[1];
gl_Position = vec4 (pb, 1);
EmitVertex();
EndPrimitive();
}
+15
View File
@@ -0,0 +1,15 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 2) in vec4 boxes;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 vColor;
out vec2 boxOut;
out vec2 boxIn;
void main()
{
gl_Position = theMat * vec4(position.xyz,1);
vColor = color;
boxOut = boxes.xy ;
boxIn = boxes.zw ;
}
+15
View File
@@ -0,0 +1,15 @@
#version 430 core
out vec4 FragColor;
in vec4 gColor;
in vec2 gTexCoord;
uniform sampler2D aTexture;
void main()
{
FragColor = texture(aTexture, vec2 (gTexCoord.x * 0.0078125, gTexCoord.y)) * gColor;
// FragColor = texture(aTexture, vTexCoord);
// FragColor = gColor;
// FragColor = vec4 (1,1,1,1);
}
+35
View File
@@ -0,0 +1,35 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in vec3 vTexCoord [];
out vec4 gColor;
out vec2 gTex;
void main()
{
vec3 cenPos = gl_in[0].gl_Position.xyz;
float sizex = vTexCoord[0].y;
float sizey = vTexCoord[0].z;
//float size = 0.05;
gColor = vColor[0];
float texPos = vTexCoord[0].x;
gl_Position = vec4 (cenPos.x - sizex*0.5, cenPos.y - sizey*0.5, cenPos.z , 1);
//gl_Position = vec4 (0, 0 , 5 , 1);
gTex = vec2 (texPos*0.0078125, 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - sizex*0.5, cenPos.y + sizey*0.5, cenPos.z , 1);
//gl_Position = vec4 (0, 0.5 , 5 , 1);
gTex = vec2 (texPos*0.0078125, 0);
EmitVertex();
gl_Position = vec4 (cenPos.x + sizex*0.5, cenPos.y - sizey*0.5, cenPos.z , 1);
//gl_Position = vec4 (0.5, 0.5 , -5 , 1);
gTex = vec2 ((texPos+1)*0.0078125, 1);
EmitVertex();
gl_Position = vec4 (cenPos.x + sizex*0.5, cenPos.y + sizey*0.5, cenPos.z , 1);
gTex = vec2 ((texPos+1)*0.0078125, 0);
//gl_Position = vec4 (0.5, 0 , -5 , 1);
EmitVertex();
EndPrimitive();
}
+13
View File
@@ -0,0 +1,13 @@
#version 430 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec4 aColor;
layout (location = 2) in vec2 aTexCoord;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 gColor;
out vec2 gTexCoord;
void main()
{
gl_Position = theMat * vec4(aPos, 1.0);
gColor = aColor;
gTexCoord = aTexCoord;
}
+12
View File
@@ -0,0 +1,12 @@
#version 430 core
in vec4 gPos;
in vec2 gBoundingBox;
out vec4 fColor;
void main()
{
float d = dot(gBoundingBox,gBoundingBox);
if ( d > 1) { discard; }
fColor = gPos;
}
+32
View File
@@ -0,0 +1,32 @@
#version 430 core
layout (triangles) in;
layout (triangle_strip, max_vertices = 4) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 gPos;
out vec2 gBoundingBox;
void main()
{
vec4 pas = gl_in[0].gl_Position;
vec4 pbs = gl_in[1].gl_Position;
vec4 pcs = gl_in[2].gl_Position;
vec4 pa = theMat * pas;
vec4 pb = theMat * pbs;
vec4 pc = theMat * pcs;
gBoundingBox = vec2 (-1,1);
gl_Position = pb;
gPos = pbs;
EmitVertex();
gBoundingBox = vec2 (1,1);
gl_Position = pa;
gPos = pas;
EmitVertex();
gBoundingBox = vec2 (-1,-1);
gl_Position = pc;
gPos = pcs;
EmitVertex();
gBoundingBox = vec2 (1,-1);
gl_Position = pa + pc - pb;
gPos = pas + pcs - pbs;
EmitVertex();
EndPrimitive();
}
+6
View File
@@ -0,0 +1,6 @@
#version 430 core
layout (location = 0) in vec3 position;
void main()
{
gl_Position = vec4(position,1);
}
+9 -2
View File
@@ -322,7 +322,8 @@ ltAutoGun = defaultAutoGun
, useTimeCheckI
, withSoundI 0
, useAmmo 1
, withRandomDirI 0.3
, withRandomDirI 0.1
, torqueAfterI 0.2
, withSidePushI 50
, withMuzFlareI
]
@@ -357,25 +358,30 @@ miniGun = defaultAutoGun
[ ammoCheckI
, withWarmUpI 26
, useTimeCheckI
, withRecoilI 25
, withRecoilI recoilAmount
, withSoundForI 28 2
--, withThinSmokeI
, torqueAfterI 0.05
, withSidePushI 53
, withRecoilI recoilAmount
, withRandomOffsetI 12
, trigDoAlso (useAmmoParamsVelMod vm1)
--, torqueBeforeForcedI 0.001
, withSidePushI 52
, withRecoilI recoilAmount
, withRandomOffsetI 11
, withOldDir od1
, trigDoAlso (useAmmoParamsVelMod vm2)
--, torqueBeforeForcedI 0.001
, withSidePushI 51
, withRecoilI recoilAmount
, withRandomOffsetI 10
, withOldDir od2
, trigDoAlso (useAmmoParamsVelMod vm3)
, useAmmo 4
--, torqueBeforeForcedI 0.001
, withSidePushI 50
, withRecoilI recoilAmount
, withRandomOffsetI 9
, withMuzFlareI
, withOldDir od3
@@ -388,6 +394,7 @@ miniGun = defaultAutoGun
, _wpAmmo = basicBullet
}
where
recoilAmount = 5
[vm1,vm2,vm3,vm4] =
[ 0.25
, 0.5
+8
View File
@@ -19,6 +19,7 @@ module Dodge.Item.Weapon.TriggerType
, withRandomOffsetI
, withRandomDirI
, withRecoilI
, afterRecoil
, withSidePushAfterI
, withSidePushI
, withWarmUpI
@@ -153,6 +154,13 @@ withSoundForI soundid playTime f item cr
= soundFromPos (CrWeaponSound (_crID cr)) (_crPos cr) soundid playTime 0
. f item cr
afterRecoil
:: Float -- ^ Recoil amount
-> ChainEffect
afterRecoil recoilAmount eff item cr = eff item (pushback cr) . over (creatures . ix cid) pushback
where
cid = _crID cr
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((-recoilAmount) / _crMass cr ) 0))
withRecoilI
:: Float -- ^ Recoil amount
-> ChainEffect