diff --git a/shader/posTwoD/arc.frag b/shader/posTwoD/arc.frag new file mode 100644 index 000000000..3119d572c --- /dev/null +++ b/shader/posTwoD/arc.frag @@ -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); +} diff --git a/shader/posTwoD/arc.geom b/shader/posTwoD/arc.geom new file mode 100644 index 000000000..ad9ab75d8 --- /dev/null +++ b/shader/posTwoD/arc.geom @@ -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(); +} diff --git a/shader/posTwoD/arc.vert b/shader/posTwoD/arc.vert new file mode 100644 index 000000000..cd30492ac --- /dev/null +++ b/shader/posTwoD/arc.vert @@ -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; +} diff --git a/shader/posTwoD/basic.frag b/shader/posTwoD/basic.frag new file mode 100644 index 000000000..aedc197fd --- /dev/null +++ b/shader/posTwoD/basic.frag @@ -0,0 +1,7 @@ +#version 430 core +in vec4 vColor; +out vec4 fColor; +void main() +{ + fColor = vColor; +} diff --git a/shader/posTwoD/basic.vert b/shader/posTwoD/basic.vert new file mode 100644 index 000000000..47ab24a9d --- /dev/null +++ b/shader/posTwoD/basic.vert @@ -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); +} diff --git a/shader/posTwoD/basicTweakZ.frag b/shader/posTwoD/basicTweakZ.frag new file mode 100644 index 000000000..aedc197fd --- /dev/null +++ b/shader/posTwoD/basicTweakZ.frag @@ -0,0 +1,7 @@ +#version 430 core +in vec4 vColor; +out vec4 fColor; +void main() +{ + fColor = vColor; +} diff --git a/shader/posTwoD/basicTweakZ.vert b/shader/posTwoD/basicTweakZ.vert new file mode 100644 index 000000000..b371bf9d4 --- /dev/null +++ b/shader/posTwoD/basicTweakZ.vert @@ -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; +} diff --git a/shader/posTwoD/bezierQuad.frag b/shader/posTwoD/bezierQuad.frag new file mode 100644 index 000000000..f0ee9d08e --- /dev/null +++ b/shader/posTwoD/bezierQuad.frag @@ -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; +} diff --git a/shader/posTwoD/bezierQuad.geom b/shader/posTwoD/bezierQuad.geom new file mode 100644 index 000000000..49b526cf3 --- /dev/null +++ b/shader/posTwoD/bezierQuad.geom @@ -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(); +} diff --git a/shader/posTwoD/bezierQuad.vert b/shader/posTwoD/bezierQuad.vert new file mode 100644 index 000000000..efa5da739 --- /dev/null +++ b/shader/posTwoD/bezierQuad.vert @@ -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 ; +} diff --git a/shader/posTwoD/character.frag b/shader/posTwoD/character.frag new file mode 100644 index 000000000..5f5e495d4 --- /dev/null +++ b/shader/posTwoD/character.frag @@ -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); +} diff --git a/shader/posTwoD/character.geom b/shader/posTwoD/character.geom new file mode 100644 index 000000000..b9216385c --- /dev/null +++ b/shader/posTwoD/character.geom @@ -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(); +} diff --git a/shader/posTwoD/character.vert b/shader/posTwoD/character.vert new file mode 100644 index 000000000..342ad1acf --- /dev/null +++ b/shader/posTwoD/character.vert @@ -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; +} diff --git a/shader/posTwoD/ellipse.frag b/shader/posTwoD/ellipse.frag new file mode 100644 index 000000000..22377dc5e --- /dev/null +++ b/shader/posTwoD/ellipse.frag @@ -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; +} diff --git a/shader/posTwoD/ellipse.geom b/shader/posTwoD/ellipse.geom new file mode 100644 index 000000000..78f2de1fa --- /dev/null +++ b/shader/posTwoD/ellipse.geom @@ -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(); +} diff --git a/shader/posTwoD/ellipse.vert b/shader/posTwoD/ellipse.vert new file mode 100644 index 000000000..79ad2fafe --- /dev/null +++ b/shader/posTwoD/ellipse.vert @@ -0,0 +1,6 @@ +#version 430 core +layout (location = 0) in vec3 position; +void main() +{ + gl_Position = vec4(position,1); +} diff --git a/src/Dodge/Item/Weapon.hs b/src/Dodge/Item/Weapon.hs index 9a331830a..41e0d0440 100644 --- a/src/Dodge/Item/Weapon.hs +++ b/src/Dodge/Item/Weapon.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/TriggerType.hs b/src/Dodge/Item/Weapon/TriggerType.hs index f5398722d..bb9bf5842 100644 --- a/src/Dodge/Item/Weapon/TriggerType.hs +++ b/src/Dodge/Item/Weapon/TriggerType.hs @@ -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