From 7b6224ec1558c0c5ebf7b4ebc4c13458d0d55a06 Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Sat, 21 Dec 2024 17:09:23 +0100 Subject: [PATCH] did stuff --- .gitignore | 2 + Shaders/FlatForwardPass.fsh | 62 +++++ Shaders/FlatForwardPass.vsh | 30 +++ Shaders/ForwardPass.fsh | 239 ++++++++++++++++++ Shaders/ForwardPass.vsh | 38 +++ Shaders/Link.fsh | 14 + Shaders/Link.vsh | 38 +++ Shaders/MapGen.fsh | 10 + Shaders/MapGen.vsh | 19 ++ Shaders/MapGenPP.fsh | 109 ++++++++ Shaders/MapGenPP.fsh.bak | 145 +++++++++++ Shaders/MapGenPP.vsh | 11 + Shaders/ShadowPass.fsh | 10 + Shaders/ShadowPass.vsh | 16 ++ deps/vgcore/deps/IconFontCppHeaders | 2 +- .../Source/NativeImpl/Stub/NativeAssembly.h | 25 ++ .../NativeImpl/Stub/NativeAssemblyInternals.h | 13 + deps/vgcore/deps/assimp | 2 +- deps/vgcore/deps/glfw | 2 +- deps/vgcore/deps/glm | 2 +- deps/vgcore/src/virintox/gcore/gui/StrOpts.h | 32 +++ res/Shaders/FlatForwardPass.fsh | 62 +++++ res/Shaders/FlatForwardPass.vsh | 30 +++ res/Shaders/ForwardPass.fsh | 239 ++++++++++++++++++ res/Shaders/ForwardPass.vsh | 38 +++ res/Shaders/Link.fsh | 14 + res/Shaders/Link.vsh | 38 +++ res/Shaders/MapGen.fsh | 10 + res/Shaders/MapGen.vsh | 19 ++ res/Shaders/MapGenPP.fsh | 109 ++++++++ res/Shaders/MapGenPP.fsh.bak | 145 +++++++++++ res/Shaders/MapGenPP.vsh | 11 + res/Shaders/ShadowPass.fsh | 10 + res/Shaders/ShadowPass.vsh | 16 ++ 34 files changed, 1558 insertions(+), 4 deletions(-) create mode 100644 Shaders/FlatForwardPass.fsh create mode 100644 Shaders/FlatForwardPass.vsh create mode 100644 Shaders/ForwardPass.fsh create mode 100644 Shaders/ForwardPass.vsh create mode 100644 Shaders/Link.fsh create mode 100644 Shaders/Link.vsh create mode 100644 Shaders/MapGen.fsh create mode 100644 Shaders/MapGen.vsh create mode 100644 Shaders/MapGenPP.fsh create mode 100644 Shaders/MapGenPP.fsh.bak create mode 100644 Shaders/MapGenPP.vsh create mode 100644 Shaders/ShadowPass.fsh create mode 100644 Shaders/ShadowPass.vsh create mode 100644 deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssembly.h create mode 100644 deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssemblyInternals.h create mode 100644 deps/vgcore/src/virintox/gcore/gui/StrOpts.h create mode 100644 res/Shaders/FlatForwardPass.fsh create mode 100644 res/Shaders/FlatForwardPass.vsh create mode 100644 res/Shaders/ForwardPass.fsh create mode 100644 res/Shaders/ForwardPass.vsh create mode 100644 res/Shaders/Link.fsh create mode 100644 res/Shaders/Link.vsh create mode 100644 res/Shaders/MapGen.fsh create mode 100644 res/Shaders/MapGen.vsh create mode 100644 res/Shaders/MapGenPP.fsh create mode 100644 res/Shaders/MapGenPP.fsh.bak create mode 100644 res/Shaders/MapGenPP.vsh create mode 100644 res/Shaders/ShadowPass.fsh create mode 100644 res/Shaders/ShadowPass.vsh diff --git a/.gitignore b/.gitignore index f35e3c0..6594021 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *build* +.idea +*.zip diff --git a/Shaders/FlatForwardPass.fsh b/Shaders/FlatForwardPass.fsh new file mode 100644 index 0000000..6efb69f --- /dev/null +++ b/Shaders/FlatForwardPass.fsh @@ -0,0 +1,62 @@ +#version 460 +in vec2 TexCoord; +in vec4 WldPos; +in vec3 Normal; + +in mat3 TBN; + +layout(location = 0) out vec4 FragColor; +layout(location = 1) out int ObjId; +layout(location = 2) out vec4 WorldPos; +uniform sampler2D TextureSampler; +uniform sampler2D NormalMapSampler; +uniform sampler2D EmmissionMapSampler; +uniform sampler2D SpecularMapSampler; +uniform sampler2D TeamcolorMap; +uniform sampler2D ShadowMapSampler; +uniform int ObjIdIn; +uniform vec4 ObjColor; +uniform vec3 LightDirection; +uniform vec3 CameraPosition; +uniform vec3 CamFwdDir; +uniform int TeamId; + +vec4 TeamIdColors[3] = vec4[3](vec4(0.41568628f, 0.74901962f, 0.04705882f, 1.00000000f ), + vec4(1.00000000f, 0.89999998f, 0.00000000f, 1.00000000f ), + vec4(0.55000001f, 0.05000000f, 0.50000000f, 1.00000000f )); + +float calcMissing(vec3 normal){ + return abs(sqrt(1-(normal.x*normal.x+normal.y*normal.y))); +} + +vec4 transition(vec4 v1,vec4 v2,float val){ + return v1 * val + v2 * (1-val); +} + +void main(){ + + vec3 CamDir = normalize(CameraPosition - WldPos.xyz); + + vec3 normal = vec3(texture(NormalMapSampler, TexCoord)); + + normal = normal * 2.0 - 1.0; + + normal.y = -normal.y; + + normal.z = calcMissing(normal); + + normal = normalize(TBN * normal); + + ObjId = ObjIdIn; + WorldPos = vec4(WldPos.xyz,1); + //if(WldPos.w == 0) WorldPos=vec4(WldPos.xyz,1); + vec4 textel = texture(TextureSampler,TexCoord); + if(textel.a < 0.3) discard; + //textel.a = (CamPos.z / CamPos.w) / 100; + vec4 col = textel * ObjColor; + + FragColor = vec4(col.rgb * min(0.35 + dot(CamDir,normal),1),col.a); + + FragColor *= transition(TeamIdColors[TeamId],vec4(1,1,1,1), texture(TeamcolorMap, TexCoord).a); + //FragColor = vec4(1,1,1,1); +} diff --git a/Shaders/FlatForwardPass.vsh b/Shaders/FlatForwardPass.vsh new file mode 100644 index 0000000..a1d93a6 --- /dev/null +++ b/Shaders/FlatForwardPass.vsh @@ -0,0 +1,30 @@ +#version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; +uniform mat4 NormalRotationMatrix; +uniform mat4 ModelMatrix; +out vec2 TexCoord; +out vec4 WldPos; +out vec3 Normal; + +out mat3 TBN; + +void main(){ + vec4 prepos = MVP * vec4(aPos,1); + + gl_Position = vec4(prepos.x,-prepos.y,prepos.zw); + + WldPos = ModelMatrix * vec4(aPos.xyz,1); + + TexCoord = aTexCoord; + Normal = (NormalRotationMatrix * vec4(aNormal,1)).xyz; + + vec3 T = normalize(vec3(NormalRotationMatrix * vec4(aTangent, 0.0))); + vec3 B = normalize(vec3(NormalRotationMatrix * vec4(aBitangent, 0.0))); + vec3 N = normalize(vec3(NormalRotationMatrix * vec4(aNormal, 0.0))); + TBN = mat3(T, B, N); +} diff --git a/Shaders/ForwardPass.fsh b/Shaders/ForwardPass.fsh new file mode 100644 index 0000000..45b39f1 --- /dev/null +++ b/Shaders/ForwardPass.fsh @@ -0,0 +1,239 @@ +#version 460 +in vec2 TexCoord; +in vec4 WldPos; +in mat3 TBN; +in vec3 aanormal; +layout(location = 0) out vec4 FragColor; +layout(location = 1) out int ObjId; +layout(location = 2) out vec4 WorldPos; +uniform sampler2D TextureSampler; +uniform sampler2D NormalMapSampler; +uniform sampler2D EmmissionMapSampler; +uniform sampler2D SpecularMapSampler; +uniform sampler2D TeamcolorMap; +uniform sampler2D ShadowMapSampler; +uniform int ObjIdIn; +uniform vec4 ObjColor; +uniform vec3 LightDirection; +uniform vec3 CameraPosition; +uniform float distribution; +uniform float shadowHardness; + +in vec3 shadowSpacePos; + +const float pixel = 1.0f / 8192.0f; + +vec4 TeamIdColors[3] = vec4[3](vec4(0.41568628f, 0.74901962f, 0.04705882f, 1.00000000f ), + vec4(1.00000000f, 0.89999998f, 0.00000000f, 1.00000000f ), + vec4(0.55000000f, 0.05000000f, 0.50000000f, 1.00000000f )); + +vec2 ShadowOffsets[81] = vec2[81]( +vec2(-4.0f*pixel,-4.0f*pixel), +vec2(-4.0f*pixel,-3.0f*pixel), +vec2(-4.0f*pixel,-2.0f*pixel), +vec2(-4.0f*pixel,-1.0f*pixel), +vec2(-4.0f*pixel,0.0f*pixel), +vec2(-4.0f*pixel,1.0f*pixel), +vec2(-4.0f*pixel,2.0f*pixel), +vec2(-4.0f*pixel,3.0f*pixel), +vec2(-4.0f*pixel,4.0f*pixel), +vec2(-3.0f*pixel,-4.0f*pixel), +vec2(-3.0f*pixel,-3.0f*pixel), +vec2(-3.0f*pixel,-2.0f*pixel), +vec2(-3.0f*pixel,-1.0f*pixel), +vec2(-3.0f*pixel,0.0f*pixel), +vec2(-3.0f*pixel,1.0f*pixel), +vec2(-3.0f*pixel,2.0f*pixel), +vec2(-3.0f*pixel,3.0f*pixel), +vec2(-3.0f*pixel,4.0f*pixel), +vec2(-2.0f*pixel,-4.0f*pixel), +vec2(-2.0f*pixel,-3.0f*pixel), +vec2(-2.0f*pixel,-2.0f*pixel), +vec2(-2.0f*pixel,-1.0f*pixel), +vec2(-2.0f*pixel,0.0f*pixel), +vec2(-2.0f*pixel,1.0f*pixel), +vec2(-2.0f*pixel,2.0f*pixel), +vec2(-2.0f*pixel,3.0f*pixel), +vec2(-2.0f*pixel,4.0f*pixel), +vec2(-1.0f*pixel,-4.0f*pixel), +vec2(-1.0f*pixel,-3.0f*pixel), +vec2(-1.0f*pixel,-2.0f*pixel), +vec2(-1.0f*pixel,-1.0f*pixel), +vec2(-1.0f*pixel,0.0f*pixel), +vec2(-1.0f*pixel,1.0f*pixel), +vec2(-1.0f*pixel,2.0f*pixel), +vec2(-1.0f*pixel,3.0f*pixel), +vec2(-1.0f*pixel,4.0f*pixel), +vec2(0.0f*pixel,-4.0f*pixel), +vec2(0.0f*pixel,-3.0f*pixel), +vec2(0.0f*pixel,-2.0f*pixel), +vec2(0.0f*pixel,-1.0f*pixel), +vec2(0.0f*pixel,0.0f*pixel), +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.0f*pixel,2.0f*pixel), +vec2(0.0f*pixel,3.0f*pixel), +vec2(0.0f*pixel,4.0f*pixel), +vec2(1.0f*pixel,-4.0f*pixel), +vec2(1.0f*pixel,-3.0f*pixel), +vec2(1.0f*pixel,-2.0f*pixel), +vec2(1.0f*pixel,-1.0f*pixel), +vec2(1.0f*pixel,0.0f*pixel), +vec2(1.0f*pixel,1.0f*pixel), +vec2(1.0f*pixel,2.0f*pixel), +vec2(1.0f*pixel,3.0f*pixel), +vec2(1.0f*pixel,4.0f*pixel), +vec2(2.0f*pixel,-4.0f*pixel), +vec2(2.0f*pixel,-3.0f*pixel), +vec2(2.0f*pixel,-2.0f*pixel), +vec2(2.0f*pixel,-1.0f*pixel), +vec2(2.0f*pixel,0.0f*pixel), +vec2(2.0f*pixel,1.0f*pixel), +vec2(2.0f*pixel,2.0f*pixel), +vec2(2.0f*pixel,3.0f*pixel), +vec2(2.0f*pixel,4.0f*pixel), +vec2(3.0f*pixel,-4.0f*pixel), +vec2(3.0f*pixel,-3.0f*pixel), +vec2(3.0f*pixel,-2.0f*pixel), +vec2(3.0f*pixel,-1.0f*pixel), +vec2(3.0f*pixel,0.0f*pixel), +vec2(3.0f*pixel,1.0f*pixel), +vec2(3.0f*pixel,2.0f*pixel), +vec2(3.0f*pixel,3.0f*pixel), +vec2(3.0f*pixel,4.0f*pixel), +vec2(4.0f*pixel,-4.0f*pixel), +vec2(4.0f*pixel,-3.0f*pixel), +vec2(4.0f*pixel,-2.0f*pixel), +vec2(4.0f*pixel,-1.0f*pixel), +vec2(4.0f*pixel,0.0f*pixel), +vec2(4.0f*pixel,1.0f*pixel), +vec2(4.0f*pixel,2.0f*pixel), +vec2(4.0f*pixel,3.0f*pixel), +vec2(4.0f*pixel,4.0f*pixel) +); + +uniform int TeamId; + +float specPow = 128.0f; +//float specPow = 16; + + +float euler = 2.71828182845904523536f; + + + + +float gaussian(float x){ + return pow(euler, + -(pow(x,2) + / + pow(2.0f*distribution,2))); +} + + +float calcMissing(vec3 normal){ + return abs(sqrt(1-(normal.x*normal.x+normal.y*normal.y))); +} + +vec4 transition(vec4 v1,vec4 v2,float val){ + return v1 * val + v2 * (1-val); +} + +void main(){ + + vec3 lightDir = normalize(LightDirection); + WorldPos = vec4(WldPos.xyz,1); + + + vec3 CamDir = normalize(CameraPosition - WldPos.xyz); + + + + vec4 textel = texture(TextureSampler,TexCoord); + + //vec4 textel = texture(NormalMapSampler,TexCoord); + + vec3 normal = vec3(texture(NormalMapSampler, TexCoord)); + + normal = normal * 2.0f - 1.0f; + + normal.y = -normal.y; + + normal.z = calcMissing(normal); + + normal = normalize(TBN * normal); + + vec3 ReflectionVec = normalize(reflect(-lightDir, normal)); + + float spec = 0.0f; + + if(textel.a < 0.5f) discard; + //textel.a = (CamPos.z / CamPos.w) / 100.0f; + float reflect = dot(normal,lightDir); + + float lightness = pow(clamp((reflect),0.0f,1.0f),1.25f); + + float darkness = clamp(reflect,-1.0f,0.0f) * 0.1f; + + float shadowness = 0.0f; + + if(length(shadowSpacePos.xy) < 1){ + vec3 ShadowScreenSpace = shadowSpacePos * 0.5f + 0.5f; + + float shadowDiv = 0.0f; + + + vec2 ShadowHardCenter = vec2(float(int(ShadowScreenSpace.x / pixel)*pixel), float(int(ShadowScreenSpace.y / pixel)*pixel)); + for(int i = 0; i < 81; i++){ + vec2 SamplePos = ShadowHardCenter.xy + ShadowOffsets[i].xy; + float ShadowDepth = texture(ShadowMapSampler, SamplePos).r; + + float gaussDiff = gaussian(distance(SamplePos,ShadowScreenSpace.xy) / pixel); + + shadowDiv += gaussDiff; + + shadowness += gaussDiff * clamp(((ShadowScreenSpace.z - ShadowDepth) * 750.0f),0.0f,1.0f); + } + + //shadowness = clamp(shadowness,0.0f,1.0f); + + shadowness /= shadowDiv; + + shadowness = clamp(((shadowness - 0.5f) * shadowHardness) + 0.5f, 0.0f, 1.0f); + + lightness *= (1.0f - shadowness); + + if(shadowness >= 0.9f) + lightness = clamp((reflect),0.0f,1.0f) * 0.1f; + } + + if(lightness != 0.0f){ + spec = pow(clamp(dot(CamDir,ReflectionVec),0.0f,1.0f), specPow); + + spec *= texture(SpecularMapSampler,TexCoord).a; + } + + + spec *= lightness; + + //lightness += darkness; + + lightness += 0.35f; + + vec4 emmission = texture(EmmissionMapSampler, TexCoord); + + vec4 diffuseColor = vec4((textel.rgb * ObjColor.rgb * lightness),textel.a * ObjColor.a); + + FragColor = vec4((diffuseColor.rgb * (1.0f - emmission.a * emmission.r)) + (textel.rgb * emmission.a * emmission.r) * 1.5f,textel.a); + + FragColor *= transition(TeamIdColors[TeamId],vec4(1.0f,1.0f,1.0f,1.0f), texture(TeamcolorMap, TexCoord).a); + + FragColor += vec4(spec,spec,spec,0.0f); + + ObjId = ObjIdIn; + + //FragColor = vec4(normal,1.0f); + + //FragColor = vec4(vec3(1.0f, 1.0f, 1.0f) * shadowness,1.0f); + + //FragColor = vec4(spec,spec,spec,1.0f); +}; diff --git a/Shaders/ForwardPass.vsh b/Shaders/ForwardPass.vsh new file mode 100644 index 0000000..671c04b --- /dev/null +++ b/Shaders/ForwardPass.vsh @@ -0,0 +1,38 @@ + #version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; +uniform mat4 ModelMatrix; +uniform mat4 NormalRotationMatrix; +out vec2 TexCoord; +out vec4 WldPos; +out mat3 TBN; + +out vec3 shadowSpacePos; + +//out vec3 glPos; + + +uniform mat4 SunVP; + + +void main(){ + WldPos = ModelMatrix * vec4(aPos.xyz,1.0f); + vec4 prepos = MVP * vec4(aPos,1.0f); + + gl_Position = vec4(prepos.x,-prepos.y,prepos.zw); + + TexCoord = aTexCoord; + + vec4 ShadowClipSpace = SunVP * ModelMatrix * vec4(aPos,1.0f); + shadowSpacePos = ShadowClipSpace.xyz / ShadowClipSpace.w; + + + vec3 T = normalize(vec3(NormalRotationMatrix * vec4(aTangent, 0.0f))); + vec3 B = normalize(vec3(NormalRotationMatrix * vec4(aBitangent, 0.0f))); + vec3 N = normalize(vec3(NormalRotationMatrix * vec4(aNormal, 0.0f))); + TBN = mat3(T, B, N); +}; diff --git a/Shaders/Link.fsh b/Shaders/Link.fsh new file mode 100644 index 0000000..a86ca5a --- /dev/null +++ b/Shaders/Link.fsh @@ -0,0 +1,14 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +uniform vec4 color; + +in float depth; + +void main(){ + if(depth > 1 || + depth < 0) + discard; + + FragColor = color; +} diff --git a/Shaders/Link.vsh b/Shaders/Link.vsh new file mode 100644 index 0000000..8aa8437 --- /dev/null +++ b/Shaders/Link.vsh @@ -0,0 +1,38 @@ +#version 460 +uniform vec3 position[2]; +uniform vec2 width; + + +out float depth; + + + +void main(){ + vec2 direction = normalize(position[1].xy - position[0].xy); + + vec2 leftdir = vec2(direction.y,-direction.x); + vec2 rightdir = vec2(-direction.y,direction.x); + + + + switch(gl_VertexID){ + case 0: + gl_Position = vec4(position[0].xy + leftdir * width, 0.0f, 1.0f); + depth = position[0].z; + break; + case 1: + case 3: + gl_Position = vec4(position[0].xy + rightdir * width, 0.0f, 1.0f); + depth = position[0].z; + break; + case 2: + case 5: + gl_Position = vec4(position[1].xy + leftdir * width, 0.0f, 1.0f); + depth = position[1].z; + break; + case 4: + gl_Position = vec4(position[1].xy + rightdir * width, 0.0f, 1.0f); + depth = position[1].z; + break; + } +} diff --git a/Shaders/MapGen.fsh b/Shaders/MapGen.fsh new file mode 100644 index 0000000..590b150 --- /dev/null +++ b/Shaders/MapGen.fsh @@ -0,0 +1,10 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +in vec2 TexCoord; + +uniform sampler2D MapTex; + +void main(){ + FragColor = texture(MapTex,TexCoord.xy); +} diff --git a/Shaders/MapGen.vsh b/Shaders/MapGen.vsh new file mode 100644 index 0000000..804a6f5 --- /dev/null +++ b/Shaders/MapGen.vsh @@ -0,0 +1,19 @@ + +#version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; +uniform mat4 TransformationMatrixNoYInv; +uniform mat4 NormalRotationMatrix; +out vec2 TexCoord; + +void main(){ + vec4 prepos = MVP * vec4(aPos,1); + + gl_Position = vec4(prepos.x,-prepos.y,prepos.zw); + + TexCoord = (MVP * vec4(aPos.xyz,1)).xy; +} diff --git a/Shaders/MapGenPP.fsh b/Shaders/MapGenPP.fsh new file mode 100644 index 0000000..3469e3d --- /dev/null +++ b/Shaders/MapGenPP.fsh @@ -0,0 +1,109 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +in vec2 TexCoord; + +uniform sampler2D Tex; + +float pixel = 1.0f/1600.0f; + +vec3 accentColor = vec3(0.8f,0.533f,0.6f); +//vec3(0,1,1); + + +vec2 SampleCircle[22] = vec2[22]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.28173255684142967f*pixel,0.9594929736144974f*pixel), +vec2(0.5406408174555976f*pixel,0.8412535328311812f*pixel), +vec2(0.7557495743542583f*pixel,0.6548607339452851f*pixel), +vec2(0.9096319953545183f*pixel,0.41541501300188644f*pixel), +vec2(0.9898214418809327f*pixel,0.14231483827328512f*pixel), +vec2(0.9898214418809328f*pixel,-0.142314838273285f*pixel), +vec2(0.9096319953545184f*pixel,-0.4154150130018863f*pixel), +vec2(0.7557495743542583f*pixel,-0.654860733945285f*pixel), +vec2(0.5406408174555978f*pixel,-0.8412535328311811f*pixel), +vec2(0.28173255684142967f*pixel,-0.9594929736144974f*pixel), +vec2(0.00000000000000012246467991473532f*pixel,-1.0f*pixel), +vec2(-0.2817325568414294f*pixel,-0.9594929736144975f*pixel), +vec2(-0.5406408174555976f*pixel,-0.8412535328311812f*pixel), +vec2(-0.7557495743542582f*pixel,-0.6548607339452852f*pixel), +vec2(-0.9096319953545184f*pixel,-0.4154150130018864f*pixel), +vec2(-0.9898214418809327f*pixel,-0.14231483827328523f*pixel), +vec2(-0.9898214418809328f*pixel,0.14231483827328487f*pixel), +vec2(-0.9096319953545186f*pixel,0.41541501300188605f*pixel), +vec2(-0.7557495743542582f*pixel,0.6548607339452853f*pixel), +vec2(-0.5406408174555974f*pixel,0.8412535328311812f*pixel), +vec2(-0.2817325568414298f*pixel,0.9594929736144974f*pixel) +); + +vec2 SampleCircleSmol[16] = vec2[16]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.3826834323650898f*pixel,0.9238795325112867f*pixel), +vec2(0.7071067811865475f*pixel,0.7071067811865476f*pixel), +vec2(0.9238795325112867f*pixel,0.38268343236508984f*pixel), +vec2(1.0f*pixel,0.00000000000000006123233995736766f*pixel), +vec2(0.9238795325112867f*pixel,-0.3826834323650897f*pixel), +vec2(0.7071067811865476f*pixel,-0.7071067811865475f*pixel), +vec2(0.3826834323650899f*pixel,-0.9238795325112867f*pixel), +vec2(0.00000000000000012246467991473532f*pixel,-1.0f*pixel), +vec2(-0.38268343236508967f*pixel,-0.9238795325112868f*pixel), +vec2(-0.7071067811865475f*pixel,-0.7071067811865477f*pixel), +vec2(-0.9238795325112865f*pixel,-0.38268343236509034f*pixel), +vec2(-1.0f*pixel,-0.00000000000000018369701987210297f*pixel), +vec2(-0.9238795325112866f*pixel,0.38268343236509f*pixel), +vec2(-0.7071067811865477f*pixel,0.7071067811865474f*pixel), +vec2(-0.3826834323650904f*pixel,0.9238795325112865f*pixel) +); + +vec2 SampleDirs[4] = vec2[4](vec2(-pixel,0.0f), + vec2(0.0f,-pixel), + vec2(0.0f,pixel), + vec2(pixel,0.0f)); + +float euler = 2.71828182845904523536f; + +float distribution = 7.5f; + +float maxinc = 0.5f; + +float gaussian(float x){ + return maxinc * pow(euler, + -(pow(x,2.0f) + / + pow(2.0f*distribution,2.0f))); +} + +void main(){ + vec4 color = texture(Tex,TexCoord.xy); + + FragColor = color; + + if(color.a != 1){ + for(int j = 1; j <= 2; j++){ + for(int i = 0; i < 16; i++){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircleSmol[i].xy * j))).a; + + if(Test != 0) + FragColor = vec4(accentColor,1); + } + } + } + + if(color.a > 0){ + bool finished = false; + for(float i = 1.0f; i < 64.0f; i += 2.0f){ + for(int j = 0; j < 22; j++){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * i))).a; + + if(Test == 0 && !finished){ + float val = gaussian(i); + + FragColor = vec4((accentColor * val * 2.0f ) + (color.xyz * 1.0f - val ),1.0f); + finished = true; + + } + } + } + } + +} diff --git a/Shaders/MapGenPP.fsh.bak b/Shaders/MapGenPP.fsh.bak new file mode 100644 index 0000000..01dfc1d --- /dev/null +++ b/Shaders/MapGenPP.fsh.bak @@ -0,0 +1,145 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +in vec2 TexCoord; + +uniform sampler2D Tex; + +float pixel = 1f/1600f; + +vec3 accentColor = vec3(0.8,0.533,0.6); +//vec3(0,1,1); + + +vec2 SampleCircle[45] = vec2[45]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.13917310096006544f*pixel,0.9902680687415704f*pixel), +vec2(0.27563735581699916f*pixel,0.9612616959383189f*pixel), +vec2(0.4067366430758002f*pixel,0.9135454576426009f*pixel), +vec2(0.5299192642332049f*pixel,0.848048096156426f*pixel), +vec2(0.6427876096865393f*pixel,0.766044443118978f*pixel), +vec2(0.7431448254773942f*pixel,0.6691306063588582f*pixel), +vec2(0.8290375725550417f*pixel,0.5591929034707468f*pixel), +vec2(0.898794046299167f*pixel,0.43837114678907746f*pixel), +vec2(0.9510565162951535f*pixel,0.30901699437494745f*pixel), +vec2(0.984807753012208f*pixel,0.17364817766693041f*pixel), +vec2(0.9993908270190958f*pixel,0.03489949670250108f*pixel), +vec2(0.9945218953682733f*pixel,-0.10452846326765355f*pixel), +vec2(0.9702957262759965f*pixel,-0.24192189559966779f*pixel), +vec2(0.9271838545667874f*pixel,-0.37460659341591207f*pixel), +vec2(0.8660254037844387f*pixel,-0.4999999999999998f*pixel), +vec2(0.788010753606722f*pixel,-0.6156614753256583f*pixel), +vec2(0.6946583704589971f*pixel,-0.7193398003386512f*pixel), +vec2(0.5877852522924732f*pixel,-0.8090169943749473f*pixel), +vec2(0.4694715627858907f*pixel,-0.882947592858927f*pixel), +vec2(0.3420201433256689f*pixel,-0.9396926207859083f*pixel), +vec2(0.20791169081775931f*pixel,-0.9781476007338057f*pixel), +vec2(0.06975647374412552f*pixel,-0.9975640502598242f*pixel), +vec2(-0.06975647374412527f*pixel,-0.9975640502598242f*pixel), +vec2(-0.2079116908177595f*pixel,-0.9781476007338056f*pixel), +vec2(-0.34202014332566866f*pixel,-0.9396926207859084f*pixel), +vec2(-0.46947156278589086f*pixel,-0.8829475928589269f*pixel), +vec2(-0.587785252292473f*pixel,-0.8090169943749476f*pixel), +vec2(-0.6946583704589974f*pixel,-0.7193398003386511f*pixel), +vec2(-0.7880107536067221f*pixel,-0.6156614753256581f*pixel), +vec2(-0.8660254037844384f*pixel,-0.5000000000000004f*pixel), +vec2(-0.9271838545667873f*pixel,-0.3746065934159123f*pixel), +vec2(-0.9702957262759965f*pixel,-0.24192189559966779f*pixel), +vec2(-0.9945218953682734f*pixel,-0.10452846326765336f*pixel), +vec2(-0.9993908270190958f*pixel,0.03489949670250128f*pixel), +vec2(-0.9848077530122081f*pixel,0.17364817766692997f*pixel), +vec2(-0.9510565162951536f*pixel,0.30901699437494723f*pixel), +vec2(-0.898794046299167f*pixel,0.4383711467890774f*pixel), +vec2(-0.8290375725550416f*pixel,0.559192903470747f*pixel), +vec2(-0.7431448254773946f*pixel,0.6691306063588578f*pixel), +vec2(-0.6427876096865396f*pixel,0.7660444431189778f*pixel), +vec2(-0.529919264233205f*pixel,0.848048096156426f*pixel), +vec2(-0.40673664307580015f*pixel,0.913545457642601f*pixel), +vec2(-0.27563735581699894f*pixel,0.9612616959383189f*pixel), +vec2(-0.13917310096006588f*pixel,0.9902680687415703f*pixel) +); + +vec2 SampleCircleSmol[8] = vec2[8]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.7071067811865475f*pixel,0.7071067811865476f*pixel), +vec2(1.0f*pixel,0.00000000000000006123233995736766f*pixel), +vec2(0.7071067811865476f*pixel,-0.7071067811865475f*pixel), +vec2(0.00000000000000012246467991473532f*pixel,-1.0f*pixel), +vec2(-0.7071067811865475f*pixel,-0.7071067811865477f*pixel), +vec2(-1.0f*pixel,-0.00000000000000018369701987210297f*pixel), +vec2(-0.7071067811865477f*pixel,0.7071067811865474f*pixel) +); + +vec2 SampleDirs[4] = vec2[4](vec2(-pixel,0), + vec2(0,-pixel), + vec2(0,pixel), + vec2(pixel,0)); + +float euler = 2.71828182845904523536f; + +float distribution = 7.5f; + +float maxinc = 0.5f; + +float gaussian(float x){ + return maxinc * pow(euler, + -(pow(x,2) + / + pow(2f*distribution,2))); +} + +void main(){ + vec4 color = texture(Tex,TexCoord.xy); + + FragColor = color; + + if(color.a != 1){ + for(int j = 1; j <= 2; j++){ + for(int i = 0; i < 8; i++){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircleSmol[i].xy * j))).a; + + if(Test != 0) + FragColor = vec4(accentColor,1); + } + } + } + + if(color.a > 0){ + bool hit = false; + + for(int j = 0; j < 45; j += 9){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * 64))).a; + + if(Test == 0){ + hit = true; + break; + } + } + + if(hit){ + + + + bool finished = false; + for(float i = 1; i < 64; i += 2){ + int step = int(45f/(2f*i)); + if(step == 0){ + step = 1; + } + + for(int j = 0; j < 45; j += step){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * i))).a; + + if(Test == 0 && !finished){ + float val = gaussian(i); + + FragColor = vec4((accentColor * val * 2 ) + (color.xyz * 1f - val ),1); + finished = true; + + } + } + } + } + } + +} diff --git a/Shaders/MapGenPP.vsh b/Shaders/MapGenPP.vsh new file mode 100644 index 0000000..e5b807e --- /dev/null +++ b/Shaders/MapGenPP.vsh @@ -0,0 +1,11 @@ + +#version 460 +layout (location = 0) in vec2 aPos; + +out vec2 TexCoord; + +void main(){ + TexCoord = (aPos.xy / 2) + vec2(0.5,0.5); + gl_Position = vec4(aPos,1,1); + +} diff --git a/Shaders/ShadowPass.fsh b/Shaders/ShadowPass.fsh new file mode 100644 index 0000000..7cf09f7 --- /dev/null +++ b/Shaders/ShadowPass.fsh @@ -0,0 +1,10 @@ +#version 460 + +uniform sampler2D TextureSampler; + +in vec2 texCoord; + +void main(){ + if(texture(TextureSampler,texCoord).a < 0.5) + discard; +}; diff --git a/Shaders/ShadowPass.vsh b/Shaders/ShadowPass.vsh new file mode 100644 index 0000000..6295182 --- /dev/null +++ b/Shaders/ShadowPass.vsh @@ -0,0 +1,16 @@ +#version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; + +out vec2 texCoord; + + +void main(){ + + texCoord = aTexCoord; + gl_Position = MVP * vec4(aPos,1); +}; diff --git a/deps/vgcore/deps/IconFontCppHeaders b/deps/vgcore/deps/IconFontCppHeaders index 1a083cc..d7254bc 160000 --- a/deps/vgcore/deps/IconFontCppHeaders +++ b/deps/vgcore/deps/IconFontCppHeaders @@ -1 +1 @@ -Subproject commit 1a083cca7d650c0615e32a1d39d56892a2ce8c5b +Subproject commit d7254bc4e4d8e1f1260adc1c2d8fec219469e858 diff --git a/deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssembly.h b/deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssembly.h new file mode 100644 index 0000000..771ee0f --- /dev/null +++ b/deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssembly.h @@ -0,0 +1,25 @@ +// +// Created by tv on 09.08.23. +// + +#ifndef ENGINE_NATIVEASSEMBLYIMPL_H +#define ENGINE_NATIVEASSEMBLYIMPL_H + + +#include "NativeImpl/NativeAssembly.h" +#include +#include +#include + +namespace VMirror{ + NativeAssembly::NativeAssembly(std::string name) { + } + + void *NativeAssembly::getExport(const std::string &name) { + } + + NativeAssembly::~NativeAssembly() { + } +} + +#endif //ENGINE_NATIVEASSEMBLYIMPL_H diff --git a/deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssemblyInternals.h b/deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssemblyInternals.h new file mode 100644 index 0000000..e148627 --- /dev/null +++ b/deps/vgcore/deps/VMirror/Source/NativeImpl/Stub/NativeAssemblyInternals.h @@ -0,0 +1,13 @@ +// +// Created by tv on 09.08.23. +// + +#ifndef ENGINE_NATIVEASSEMBLYINTERNALS_H +#define ENGINE_NATIVEASSEMBLYINTERNALS_H + +namespace VMirror{ + struct NativeAssemblyInternals { + }; +} + +#endif //ENGINE_NATIVEASSEMBLYINTERNALS_H diff --git a/deps/vgcore/deps/assimp b/deps/vgcore/deps/assimp index 7b6bf13..5d5496f 160000 --- a/deps/vgcore/deps/assimp +++ b/deps/vgcore/deps/assimp @@ -1 +1 @@ -Subproject commit 7b6bf139cfc674838d30b8fec5beac0425324d3a +Subproject commit 5d5496f1ad895297cede723b3c96b513263f82ed diff --git a/deps/vgcore/deps/glfw b/deps/vgcore/deps/glfw index 3eaf125..b4c3ef9 160000 --- a/deps/vgcore/deps/glfw +++ b/deps/vgcore/deps/glfw @@ -1 +1 @@ -Subproject commit 3eaf1255b29fdf5c2895856c7be7d7185ef2b241 +Subproject commit b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1 diff --git a/deps/vgcore/deps/glm b/deps/vgcore/deps/glm index 47585fd..2993560 160000 --- a/deps/vgcore/deps/glm +++ b/deps/vgcore/deps/glm @@ -1 +1 @@ -Subproject commit 47585fde0c49fa77a2bf2fb1d2ead06999fd4b6e +Subproject commit 2993560ec9d0307da420e7bda0f23674102deb91 diff --git a/deps/vgcore/src/virintox/gcore/gui/StrOpts.h b/deps/vgcore/src/virintox/gcore/gui/StrOpts.h new file mode 100644 index 0000000..f5c21b7 --- /dev/null +++ b/deps/vgcore/src/virintox/gcore/gui/StrOpts.h @@ -0,0 +1,32 @@ +// +// Created by tv on 21.12.23. +// + +#pragma once +#include +#include +#include + +inline std::vector splitString(const std::string &str, std::initializer_list delimiters) { + std::vector ret; + + std::string remainingStr = str; + + while(true){ + unsigned long endCpy = 0xFFFFFFFF; + + for(char c: delimiters) + endCpy = std::min(endCpy, remainingStr.find(c)); + + if(endCpy == std::numeric_limits::max()) { + if(!remainingStr.empty()) + ret.push_back(remainingStr); + return ret; + } + + + + ret.push_back(remainingStr.substr(0,endCpy)); + remainingStr = remainingStr.substr(endCpy + 1); + } +} \ No newline at end of file diff --git a/res/Shaders/FlatForwardPass.fsh b/res/Shaders/FlatForwardPass.fsh new file mode 100644 index 0000000..6efb69f --- /dev/null +++ b/res/Shaders/FlatForwardPass.fsh @@ -0,0 +1,62 @@ +#version 460 +in vec2 TexCoord; +in vec4 WldPos; +in vec3 Normal; + +in mat3 TBN; + +layout(location = 0) out vec4 FragColor; +layout(location = 1) out int ObjId; +layout(location = 2) out vec4 WorldPos; +uniform sampler2D TextureSampler; +uniform sampler2D NormalMapSampler; +uniform sampler2D EmmissionMapSampler; +uniform sampler2D SpecularMapSampler; +uniform sampler2D TeamcolorMap; +uniform sampler2D ShadowMapSampler; +uniform int ObjIdIn; +uniform vec4 ObjColor; +uniform vec3 LightDirection; +uniform vec3 CameraPosition; +uniform vec3 CamFwdDir; +uniform int TeamId; + +vec4 TeamIdColors[3] = vec4[3](vec4(0.41568628f, 0.74901962f, 0.04705882f, 1.00000000f ), + vec4(1.00000000f, 0.89999998f, 0.00000000f, 1.00000000f ), + vec4(0.55000001f, 0.05000000f, 0.50000000f, 1.00000000f )); + +float calcMissing(vec3 normal){ + return abs(sqrt(1-(normal.x*normal.x+normal.y*normal.y))); +} + +vec4 transition(vec4 v1,vec4 v2,float val){ + return v1 * val + v2 * (1-val); +} + +void main(){ + + vec3 CamDir = normalize(CameraPosition - WldPos.xyz); + + vec3 normal = vec3(texture(NormalMapSampler, TexCoord)); + + normal = normal * 2.0 - 1.0; + + normal.y = -normal.y; + + normal.z = calcMissing(normal); + + normal = normalize(TBN * normal); + + ObjId = ObjIdIn; + WorldPos = vec4(WldPos.xyz,1); + //if(WldPos.w == 0) WorldPos=vec4(WldPos.xyz,1); + vec4 textel = texture(TextureSampler,TexCoord); + if(textel.a < 0.3) discard; + //textel.a = (CamPos.z / CamPos.w) / 100; + vec4 col = textel * ObjColor; + + FragColor = vec4(col.rgb * min(0.35 + dot(CamDir,normal),1),col.a); + + FragColor *= transition(TeamIdColors[TeamId],vec4(1,1,1,1), texture(TeamcolorMap, TexCoord).a); + //FragColor = vec4(1,1,1,1); +} diff --git a/res/Shaders/FlatForwardPass.vsh b/res/Shaders/FlatForwardPass.vsh new file mode 100644 index 0000000..a1d93a6 --- /dev/null +++ b/res/Shaders/FlatForwardPass.vsh @@ -0,0 +1,30 @@ +#version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; +uniform mat4 NormalRotationMatrix; +uniform mat4 ModelMatrix; +out vec2 TexCoord; +out vec4 WldPos; +out vec3 Normal; + +out mat3 TBN; + +void main(){ + vec4 prepos = MVP * vec4(aPos,1); + + gl_Position = vec4(prepos.x,-prepos.y,prepos.zw); + + WldPos = ModelMatrix * vec4(aPos.xyz,1); + + TexCoord = aTexCoord; + Normal = (NormalRotationMatrix * vec4(aNormal,1)).xyz; + + vec3 T = normalize(vec3(NormalRotationMatrix * vec4(aTangent, 0.0))); + vec3 B = normalize(vec3(NormalRotationMatrix * vec4(aBitangent, 0.0))); + vec3 N = normalize(vec3(NormalRotationMatrix * vec4(aNormal, 0.0))); + TBN = mat3(T, B, N); +} diff --git a/res/Shaders/ForwardPass.fsh b/res/Shaders/ForwardPass.fsh new file mode 100644 index 0000000..45b39f1 --- /dev/null +++ b/res/Shaders/ForwardPass.fsh @@ -0,0 +1,239 @@ +#version 460 +in vec2 TexCoord; +in vec4 WldPos; +in mat3 TBN; +in vec3 aanormal; +layout(location = 0) out vec4 FragColor; +layout(location = 1) out int ObjId; +layout(location = 2) out vec4 WorldPos; +uniform sampler2D TextureSampler; +uniform sampler2D NormalMapSampler; +uniform sampler2D EmmissionMapSampler; +uniform sampler2D SpecularMapSampler; +uniform sampler2D TeamcolorMap; +uniform sampler2D ShadowMapSampler; +uniform int ObjIdIn; +uniform vec4 ObjColor; +uniform vec3 LightDirection; +uniform vec3 CameraPosition; +uniform float distribution; +uniform float shadowHardness; + +in vec3 shadowSpacePos; + +const float pixel = 1.0f / 8192.0f; + +vec4 TeamIdColors[3] = vec4[3](vec4(0.41568628f, 0.74901962f, 0.04705882f, 1.00000000f ), + vec4(1.00000000f, 0.89999998f, 0.00000000f, 1.00000000f ), + vec4(0.55000000f, 0.05000000f, 0.50000000f, 1.00000000f )); + +vec2 ShadowOffsets[81] = vec2[81]( +vec2(-4.0f*pixel,-4.0f*pixel), +vec2(-4.0f*pixel,-3.0f*pixel), +vec2(-4.0f*pixel,-2.0f*pixel), +vec2(-4.0f*pixel,-1.0f*pixel), +vec2(-4.0f*pixel,0.0f*pixel), +vec2(-4.0f*pixel,1.0f*pixel), +vec2(-4.0f*pixel,2.0f*pixel), +vec2(-4.0f*pixel,3.0f*pixel), +vec2(-4.0f*pixel,4.0f*pixel), +vec2(-3.0f*pixel,-4.0f*pixel), +vec2(-3.0f*pixel,-3.0f*pixel), +vec2(-3.0f*pixel,-2.0f*pixel), +vec2(-3.0f*pixel,-1.0f*pixel), +vec2(-3.0f*pixel,0.0f*pixel), +vec2(-3.0f*pixel,1.0f*pixel), +vec2(-3.0f*pixel,2.0f*pixel), +vec2(-3.0f*pixel,3.0f*pixel), +vec2(-3.0f*pixel,4.0f*pixel), +vec2(-2.0f*pixel,-4.0f*pixel), +vec2(-2.0f*pixel,-3.0f*pixel), +vec2(-2.0f*pixel,-2.0f*pixel), +vec2(-2.0f*pixel,-1.0f*pixel), +vec2(-2.0f*pixel,0.0f*pixel), +vec2(-2.0f*pixel,1.0f*pixel), +vec2(-2.0f*pixel,2.0f*pixel), +vec2(-2.0f*pixel,3.0f*pixel), +vec2(-2.0f*pixel,4.0f*pixel), +vec2(-1.0f*pixel,-4.0f*pixel), +vec2(-1.0f*pixel,-3.0f*pixel), +vec2(-1.0f*pixel,-2.0f*pixel), +vec2(-1.0f*pixel,-1.0f*pixel), +vec2(-1.0f*pixel,0.0f*pixel), +vec2(-1.0f*pixel,1.0f*pixel), +vec2(-1.0f*pixel,2.0f*pixel), +vec2(-1.0f*pixel,3.0f*pixel), +vec2(-1.0f*pixel,4.0f*pixel), +vec2(0.0f*pixel,-4.0f*pixel), +vec2(0.0f*pixel,-3.0f*pixel), +vec2(0.0f*pixel,-2.0f*pixel), +vec2(0.0f*pixel,-1.0f*pixel), +vec2(0.0f*pixel,0.0f*pixel), +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.0f*pixel,2.0f*pixel), +vec2(0.0f*pixel,3.0f*pixel), +vec2(0.0f*pixel,4.0f*pixel), +vec2(1.0f*pixel,-4.0f*pixel), +vec2(1.0f*pixel,-3.0f*pixel), +vec2(1.0f*pixel,-2.0f*pixel), +vec2(1.0f*pixel,-1.0f*pixel), +vec2(1.0f*pixel,0.0f*pixel), +vec2(1.0f*pixel,1.0f*pixel), +vec2(1.0f*pixel,2.0f*pixel), +vec2(1.0f*pixel,3.0f*pixel), +vec2(1.0f*pixel,4.0f*pixel), +vec2(2.0f*pixel,-4.0f*pixel), +vec2(2.0f*pixel,-3.0f*pixel), +vec2(2.0f*pixel,-2.0f*pixel), +vec2(2.0f*pixel,-1.0f*pixel), +vec2(2.0f*pixel,0.0f*pixel), +vec2(2.0f*pixel,1.0f*pixel), +vec2(2.0f*pixel,2.0f*pixel), +vec2(2.0f*pixel,3.0f*pixel), +vec2(2.0f*pixel,4.0f*pixel), +vec2(3.0f*pixel,-4.0f*pixel), +vec2(3.0f*pixel,-3.0f*pixel), +vec2(3.0f*pixel,-2.0f*pixel), +vec2(3.0f*pixel,-1.0f*pixel), +vec2(3.0f*pixel,0.0f*pixel), +vec2(3.0f*pixel,1.0f*pixel), +vec2(3.0f*pixel,2.0f*pixel), +vec2(3.0f*pixel,3.0f*pixel), +vec2(3.0f*pixel,4.0f*pixel), +vec2(4.0f*pixel,-4.0f*pixel), +vec2(4.0f*pixel,-3.0f*pixel), +vec2(4.0f*pixel,-2.0f*pixel), +vec2(4.0f*pixel,-1.0f*pixel), +vec2(4.0f*pixel,0.0f*pixel), +vec2(4.0f*pixel,1.0f*pixel), +vec2(4.0f*pixel,2.0f*pixel), +vec2(4.0f*pixel,3.0f*pixel), +vec2(4.0f*pixel,4.0f*pixel) +); + +uniform int TeamId; + +float specPow = 128.0f; +//float specPow = 16; + + +float euler = 2.71828182845904523536f; + + + + +float gaussian(float x){ + return pow(euler, + -(pow(x,2) + / + pow(2.0f*distribution,2))); +} + + +float calcMissing(vec3 normal){ + return abs(sqrt(1-(normal.x*normal.x+normal.y*normal.y))); +} + +vec4 transition(vec4 v1,vec4 v2,float val){ + return v1 * val + v2 * (1-val); +} + +void main(){ + + vec3 lightDir = normalize(LightDirection); + WorldPos = vec4(WldPos.xyz,1); + + + vec3 CamDir = normalize(CameraPosition - WldPos.xyz); + + + + vec4 textel = texture(TextureSampler,TexCoord); + + //vec4 textel = texture(NormalMapSampler,TexCoord); + + vec3 normal = vec3(texture(NormalMapSampler, TexCoord)); + + normal = normal * 2.0f - 1.0f; + + normal.y = -normal.y; + + normal.z = calcMissing(normal); + + normal = normalize(TBN * normal); + + vec3 ReflectionVec = normalize(reflect(-lightDir, normal)); + + float spec = 0.0f; + + if(textel.a < 0.5f) discard; + //textel.a = (CamPos.z / CamPos.w) / 100.0f; + float reflect = dot(normal,lightDir); + + float lightness = pow(clamp((reflect),0.0f,1.0f),1.25f); + + float darkness = clamp(reflect,-1.0f,0.0f) * 0.1f; + + float shadowness = 0.0f; + + if(length(shadowSpacePos.xy) < 1){ + vec3 ShadowScreenSpace = shadowSpacePos * 0.5f + 0.5f; + + float shadowDiv = 0.0f; + + + vec2 ShadowHardCenter = vec2(float(int(ShadowScreenSpace.x / pixel)*pixel), float(int(ShadowScreenSpace.y / pixel)*pixel)); + for(int i = 0; i < 81; i++){ + vec2 SamplePos = ShadowHardCenter.xy + ShadowOffsets[i].xy; + float ShadowDepth = texture(ShadowMapSampler, SamplePos).r; + + float gaussDiff = gaussian(distance(SamplePos,ShadowScreenSpace.xy) / pixel); + + shadowDiv += gaussDiff; + + shadowness += gaussDiff * clamp(((ShadowScreenSpace.z - ShadowDepth) * 750.0f),0.0f,1.0f); + } + + //shadowness = clamp(shadowness,0.0f,1.0f); + + shadowness /= shadowDiv; + + shadowness = clamp(((shadowness - 0.5f) * shadowHardness) + 0.5f, 0.0f, 1.0f); + + lightness *= (1.0f - shadowness); + + if(shadowness >= 0.9f) + lightness = clamp((reflect),0.0f,1.0f) * 0.1f; + } + + if(lightness != 0.0f){ + spec = pow(clamp(dot(CamDir,ReflectionVec),0.0f,1.0f), specPow); + + spec *= texture(SpecularMapSampler,TexCoord).a; + } + + + spec *= lightness; + + //lightness += darkness; + + lightness += 0.35f; + + vec4 emmission = texture(EmmissionMapSampler, TexCoord); + + vec4 diffuseColor = vec4((textel.rgb * ObjColor.rgb * lightness),textel.a * ObjColor.a); + + FragColor = vec4((diffuseColor.rgb * (1.0f - emmission.a * emmission.r)) + (textel.rgb * emmission.a * emmission.r) * 1.5f,textel.a); + + FragColor *= transition(TeamIdColors[TeamId],vec4(1.0f,1.0f,1.0f,1.0f), texture(TeamcolorMap, TexCoord).a); + + FragColor += vec4(spec,spec,spec,0.0f); + + ObjId = ObjIdIn; + + //FragColor = vec4(normal,1.0f); + + //FragColor = vec4(vec3(1.0f, 1.0f, 1.0f) * shadowness,1.0f); + + //FragColor = vec4(spec,spec,spec,1.0f); +}; diff --git a/res/Shaders/ForwardPass.vsh b/res/Shaders/ForwardPass.vsh new file mode 100644 index 0000000..671c04b --- /dev/null +++ b/res/Shaders/ForwardPass.vsh @@ -0,0 +1,38 @@ + #version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; +uniform mat4 ModelMatrix; +uniform mat4 NormalRotationMatrix; +out vec2 TexCoord; +out vec4 WldPos; +out mat3 TBN; + +out vec3 shadowSpacePos; + +//out vec3 glPos; + + +uniform mat4 SunVP; + + +void main(){ + WldPos = ModelMatrix * vec4(aPos.xyz,1.0f); + vec4 prepos = MVP * vec4(aPos,1.0f); + + gl_Position = vec4(prepos.x,-prepos.y,prepos.zw); + + TexCoord = aTexCoord; + + vec4 ShadowClipSpace = SunVP * ModelMatrix * vec4(aPos,1.0f); + shadowSpacePos = ShadowClipSpace.xyz / ShadowClipSpace.w; + + + vec3 T = normalize(vec3(NormalRotationMatrix * vec4(aTangent, 0.0f))); + vec3 B = normalize(vec3(NormalRotationMatrix * vec4(aBitangent, 0.0f))); + vec3 N = normalize(vec3(NormalRotationMatrix * vec4(aNormal, 0.0f))); + TBN = mat3(T, B, N); +}; diff --git a/res/Shaders/Link.fsh b/res/Shaders/Link.fsh new file mode 100644 index 0000000..a86ca5a --- /dev/null +++ b/res/Shaders/Link.fsh @@ -0,0 +1,14 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +uniform vec4 color; + +in float depth; + +void main(){ + if(depth > 1 || + depth < 0) + discard; + + FragColor = color; +} diff --git a/res/Shaders/Link.vsh b/res/Shaders/Link.vsh new file mode 100644 index 0000000..8aa8437 --- /dev/null +++ b/res/Shaders/Link.vsh @@ -0,0 +1,38 @@ +#version 460 +uniform vec3 position[2]; +uniform vec2 width; + + +out float depth; + + + +void main(){ + vec2 direction = normalize(position[1].xy - position[0].xy); + + vec2 leftdir = vec2(direction.y,-direction.x); + vec2 rightdir = vec2(-direction.y,direction.x); + + + + switch(gl_VertexID){ + case 0: + gl_Position = vec4(position[0].xy + leftdir * width, 0.0f, 1.0f); + depth = position[0].z; + break; + case 1: + case 3: + gl_Position = vec4(position[0].xy + rightdir * width, 0.0f, 1.0f); + depth = position[0].z; + break; + case 2: + case 5: + gl_Position = vec4(position[1].xy + leftdir * width, 0.0f, 1.0f); + depth = position[1].z; + break; + case 4: + gl_Position = vec4(position[1].xy + rightdir * width, 0.0f, 1.0f); + depth = position[1].z; + break; + } +} diff --git a/res/Shaders/MapGen.fsh b/res/Shaders/MapGen.fsh new file mode 100644 index 0000000..590b150 --- /dev/null +++ b/res/Shaders/MapGen.fsh @@ -0,0 +1,10 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +in vec2 TexCoord; + +uniform sampler2D MapTex; + +void main(){ + FragColor = texture(MapTex,TexCoord.xy); +} diff --git a/res/Shaders/MapGen.vsh b/res/Shaders/MapGen.vsh new file mode 100644 index 0000000..804a6f5 --- /dev/null +++ b/res/Shaders/MapGen.vsh @@ -0,0 +1,19 @@ + +#version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; +uniform mat4 TransformationMatrixNoYInv; +uniform mat4 NormalRotationMatrix; +out vec2 TexCoord; + +void main(){ + vec4 prepos = MVP * vec4(aPos,1); + + gl_Position = vec4(prepos.x,-prepos.y,prepos.zw); + + TexCoord = (MVP * vec4(aPos.xyz,1)).xy; +} diff --git a/res/Shaders/MapGenPP.fsh b/res/Shaders/MapGenPP.fsh new file mode 100644 index 0000000..3469e3d --- /dev/null +++ b/res/Shaders/MapGenPP.fsh @@ -0,0 +1,109 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +in vec2 TexCoord; + +uniform sampler2D Tex; + +float pixel = 1.0f/1600.0f; + +vec3 accentColor = vec3(0.8f,0.533f,0.6f); +//vec3(0,1,1); + + +vec2 SampleCircle[22] = vec2[22]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.28173255684142967f*pixel,0.9594929736144974f*pixel), +vec2(0.5406408174555976f*pixel,0.8412535328311812f*pixel), +vec2(0.7557495743542583f*pixel,0.6548607339452851f*pixel), +vec2(0.9096319953545183f*pixel,0.41541501300188644f*pixel), +vec2(0.9898214418809327f*pixel,0.14231483827328512f*pixel), +vec2(0.9898214418809328f*pixel,-0.142314838273285f*pixel), +vec2(0.9096319953545184f*pixel,-0.4154150130018863f*pixel), +vec2(0.7557495743542583f*pixel,-0.654860733945285f*pixel), +vec2(0.5406408174555978f*pixel,-0.8412535328311811f*pixel), +vec2(0.28173255684142967f*pixel,-0.9594929736144974f*pixel), +vec2(0.00000000000000012246467991473532f*pixel,-1.0f*pixel), +vec2(-0.2817325568414294f*pixel,-0.9594929736144975f*pixel), +vec2(-0.5406408174555976f*pixel,-0.8412535328311812f*pixel), +vec2(-0.7557495743542582f*pixel,-0.6548607339452852f*pixel), +vec2(-0.9096319953545184f*pixel,-0.4154150130018864f*pixel), +vec2(-0.9898214418809327f*pixel,-0.14231483827328523f*pixel), +vec2(-0.9898214418809328f*pixel,0.14231483827328487f*pixel), +vec2(-0.9096319953545186f*pixel,0.41541501300188605f*pixel), +vec2(-0.7557495743542582f*pixel,0.6548607339452853f*pixel), +vec2(-0.5406408174555974f*pixel,0.8412535328311812f*pixel), +vec2(-0.2817325568414298f*pixel,0.9594929736144974f*pixel) +); + +vec2 SampleCircleSmol[16] = vec2[16]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.3826834323650898f*pixel,0.9238795325112867f*pixel), +vec2(0.7071067811865475f*pixel,0.7071067811865476f*pixel), +vec2(0.9238795325112867f*pixel,0.38268343236508984f*pixel), +vec2(1.0f*pixel,0.00000000000000006123233995736766f*pixel), +vec2(0.9238795325112867f*pixel,-0.3826834323650897f*pixel), +vec2(0.7071067811865476f*pixel,-0.7071067811865475f*pixel), +vec2(0.3826834323650899f*pixel,-0.9238795325112867f*pixel), +vec2(0.00000000000000012246467991473532f*pixel,-1.0f*pixel), +vec2(-0.38268343236508967f*pixel,-0.9238795325112868f*pixel), +vec2(-0.7071067811865475f*pixel,-0.7071067811865477f*pixel), +vec2(-0.9238795325112865f*pixel,-0.38268343236509034f*pixel), +vec2(-1.0f*pixel,-0.00000000000000018369701987210297f*pixel), +vec2(-0.9238795325112866f*pixel,0.38268343236509f*pixel), +vec2(-0.7071067811865477f*pixel,0.7071067811865474f*pixel), +vec2(-0.3826834323650904f*pixel,0.9238795325112865f*pixel) +); + +vec2 SampleDirs[4] = vec2[4](vec2(-pixel,0.0f), + vec2(0.0f,-pixel), + vec2(0.0f,pixel), + vec2(pixel,0.0f)); + +float euler = 2.71828182845904523536f; + +float distribution = 7.5f; + +float maxinc = 0.5f; + +float gaussian(float x){ + return maxinc * pow(euler, + -(pow(x,2.0f) + / + pow(2.0f*distribution,2.0f))); +} + +void main(){ + vec4 color = texture(Tex,TexCoord.xy); + + FragColor = color; + + if(color.a != 1){ + for(int j = 1; j <= 2; j++){ + for(int i = 0; i < 16; i++){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircleSmol[i].xy * j))).a; + + if(Test != 0) + FragColor = vec4(accentColor,1); + } + } + } + + if(color.a > 0){ + bool finished = false; + for(float i = 1.0f; i < 64.0f; i += 2.0f){ + for(int j = 0; j < 22; j++){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * i))).a; + + if(Test == 0 && !finished){ + float val = gaussian(i); + + FragColor = vec4((accentColor * val * 2.0f ) + (color.xyz * 1.0f - val ),1.0f); + finished = true; + + } + } + } + } + +} diff --git a/res/Shaders/MapGenPP.fsh.bak b/res/Shaders/MapGenPP.fsh.bak new file mode 100644 index 0000000..01dfc1d --- /dev/null +++ b/res/Shaders/MapGenPP.fsh.bak @@ -0,0 +1,145 @@ +#version 460 +layout(location = 0) out vec4 FragColor; + +in vec2 TexCoord; + +uniform sampler2D Tex; + +float pixel = 1f/1600f; + +vec3 accentColor = vec3(0.8,0.533,0.6); +//vec3(0,1,1); + + +vec2 SampleCircle[45] = vec2[45]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.13917310096006544f*pixel,0.9902680687415704f*pixel), +vec2(0.27563735581699916f*pixel,0.9612616959383189f*pixel), +vec2(0.4067366430758002f*pixel,0.9135454576426009f*pixel), +vec2(0.5299192642332049f*pixel,0.848048096156426f*pixel), +vec2(0.6427876096865393f*pixel,0.766044443118978f*pixel), +vec2(0.7431448254773942f*pixel,0.6691306063588582f*pixel), +vec2(0.8290375725550417f*pixel,0.5591929034707468f*pixel), +vec2(0.898794046299167f*pixel,0.43837114678907746f*pixel), +vec2(0.9510565162951535f*pixel,0.30901699437494745f*pixel), +vec2(0.984807753012208f*pixel,0.17364817766693041f*pixel), +vec2(0.9993908270190958f*pixel,0.03489949670250108f*pixel), +vec2(0.9945218953682733f*pixel,-0.10452846326765355f*pixel), +vec2(0.9702957262759965f*pixel,-0.24192189559966779f*pixel), +vec2(0.9271838545667874f*pixel,-0.37460659341591207f*pixel), +vec2(0.8660254037844387f*pixel,-0.4999999999999998f*pixel), +vec2(0.788010753606722f*pixel,-0.6156614753256583f*pixel), +vec2(0.6946583704589971f*pixel,-0.7193398003386512f*pixel), +vec2(0.5877852522924732f*pixel,-0.8090169943749473f*pixel), +vec2(0.4694715627858907f*pixel,-0.882947592858927f*pixel), +vec2(0.3420201433256689f*pixel,-0.9396926207859083f*pixel), +vec2(0.20791169081775931f*pixel,-0.9781476007338057f*pixel), +vec2(0.06975647374412552f*pixel,-0.9975640502598242f*pixel), +vec2(-0.06975647374412527f*pixel,-0.9975640502598242f*pixel), +vec2(-0.2079116908177595f*pixel,-0.9781476007338056f*pixel), +vec2(-0.34202014332566866f*pixel,-0.9396926207859084f*pixel), +vec2(-0.46947156278589086f*pixel,-0.8829475928589269f*pixel), +vec2(-0.587785252292473f*pixel,-0.8090169943749476f*pixel), +vec2(-0.6946583704589974f*pixel,-0.7193398003386511f*pixel), +vec2(-0.7880107536067221f*pixel,-0.6156614753256581f*pixel), +vec2(-0.8660254037844384f*pixel,-0.5000000000000004f*pixel), +vec2(-0.9271838545667873f*pixel,-0.3746065934159123f*pixel), +vec2(-0.9702957262759965f*pixel,-0.24192189559966779f*pixel), +vec2(-0.9945218953682734f*pixel,-0.10452846326765336f*pixel), +vec2(-0.9993908270190958f*pixel,0.03489949670250128f*pixel), +vec2(-0.9848077530122081f*pixel,0.17364817766692997f*pixel), +vec2(-0.9510565162951536f*pixel,0.30901699437494723f*pixel), +vec2(-0.898794046299167f*pixel,0.4383711467890774f*pixel), +vec2(-0.8290375725550416f*pixel,0.559192903470747f*pixel), +vec2(-0.7431448254773946f*pixel,0.6691306063588578f*pixel), +vec2(-0.6427876096865396f*pixel,0.7660444431189778f*pixel), +vec2(-0.529919264233205f*pixel,0.848048096156426f*pixel), +vec2(-0.40673664307580015f*pixel,0.913545457642601f*pixel), +vec2(-0.27563735581699894f*pixel,0.9612616959383189f*pixel), +vec2(-0.13917310096006588f*pixel,0.9902680687415703f*pixel) +); + +vec2 SampleCircleSmol[8] = vec2[8]( +vec2(0.0f*pixel,1.0f*pixel), +vec2(0.7071067811865475f*pixel,0.7071067811865476f*pixel), +vec2(1.0f*pixel,0.00000000000000006123233995736766f*pixel), +vec2(0.7071067811865476f*pixel,-0.7071067811865475f*pixel), +vec2(0.00000000000000012246467991473532f*pixel,-1.0f*pixel), +vec2(-0.7071067811865475f*pixel,-0.7071067811865477f*pixel), +vec2(-1.0f*pixel,-0.00000000000000018369701987210297f*pixel), +vec2(-0.7071067811865477f*pixel,0.7071067811865474f*pixel) +); + +vec2 SampleDirs[4] = vec2[4](vec2(-pixel,0), + vec2(0,-pixel), + vec2(0,pixel), + vec2(pixel,0)); + +float euler = 2.71828182845904523536f; + +float distribution = 7.5f; + +float maxinc = 0.5f; + +float gaussian(float x){ + return maxinc * pow(euler, + -(pow(x,2) + / + pow(2f*distribution,2))); +} + +void main(){ + vec4 color = texture(Tex,TexCoord.xy); + + FragColor = color; + + if(color.a != 1){ + for(int j = 1; j <= 2; j++){ + for(int i = 0; i < 8; i++){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircleSmol[i].xy * j))).a; + + if(Test != 0) + FragColor = vec4(accentColor,1); + } + } + } + + if(color.a > 0){ + bool hit = false; + + for(int j = 0; j < 45; j += 9){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * 64))).a; + + if(Test == 0){ + hit = true; + break; + } + } + + if(hit){ + + + + bool finished = false; + for(float i = 1; i < 64; i += 2){ + int step = int(45f/(2f*i)); + if(step == 0){ + step = 1; + } + + for(int j = 0; j < 45; j += step){ + float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * i))).a; + + if(Test == 0 && !finished){ + float val = gaussian(i); + + FragColor = vec4((accentColor * val * 2 ) + (color.xyz * 1f - val ),1); + finished = true; + + } + } + } + } + } + +} diff --git a/res/Shaders/MapGenPP.vsh b/res/Shaders/MapGenPP.vsh new file mode 100644 index 0000000..e5b807e --- /dev/null +++ b/res/Shaders/MapGenPP.vsh @@ -0,0 +1,11 @@ + +#version 460 +layout (location = 0) in vec2 aPos; + +out vec2 TexCoord; + +void main(){ + TexCoord = (aPos.xy / 2) + vec2(0.5,0.5); + gl_Position = vec4(aPos,1,1); + +} diff --git a/res/Shaders/ShadowPass.fsh b/res/Shaders/ShadowPass.fsh new file mode 100644 index 0000000..7cf09f7 --- /dev/null +++ b/res/Shaders/ShadowPass.fsh @@ -0,0 +1,10 @@ +#version 460 + +uniform sampler2D TextureSampler; + +in vec2 texCoord; + +void main(){ + if(texture(TextureSampler,texCoord).a < 0.5) + discard; +}; diff --git a/res/Shaders/ShadowPass.vsh b/res/Shaders/ShadowPass.vsh new file mode 100644 index 0000000..6295182 --- /dev/null +++ b/res/Shaders/ShadowPass.vsh @@ -0,0 +1,16 @@ +#version 460 +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec2 aTexCoord; +layout (location = 2) in vec3 aNormal; +layout (location = 3) in vec3 aTangent; +layout (location = 4) in vec3 aBitangent; +uniform mat4 MVP; + +out vec2 texCoord; + + +void main(){ + + texCoord = aTexCoord; + gl_Position = MVP * vec4(aPos,1); +};