Skip to content

Commit

Permalink
1.19 animations start working
Browse files Browse the repository at this point in the history
  • Loading branch information
maltiez2 committed Dec 24, 2023
1 parent c1dd023 commit 74ae108
Show file tree
Hide file tree
Showing 10 changed files with 1,090 additions and 96 deletions.
70 changes: 60 additions & 10 deletions AnimationManager/AnimationManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,58 @@
<Private>False</Private>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Open.Nat">
<HintPath>..\..\game_19\Lib\Open.Nat.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Audio.OpenAL">
<HintPath>..\..\game_19\Lib\OpenTK.Audio.OpenAL.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Compute">
<HintPath>..\..\game_19\Lib\OpenTK.Compute.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Core">
<HintPath>..\..\game_19\Lib\OpenTK.Core.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Graphics">
<HintPath>..\..\game_19\Lib\OpenTK.Graphics.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Input">
<HintPath>..\..\game_19\Lib\OpenTK.Input.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Mathematics">
<HintPath>..\..\game_19\Lib\OpenTK.Mathematics.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Windowing.Common">
<HintPath>..\..\game_19\Lib\OpenTK.Windowing.Common.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Windowing.Desktop">
<HintPath>..\..\game_19\Lib\OpenTK.Windowing.Desktop.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="OpenTK.Windowing.GraphicsLibraryFramework">
<HintPath>..\..\game_19\Lib\OpenTK.Windowing.GraphicsLibraryFramework.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="VintagestoryAPI">
<HintPath>D:\Projects\Firearms\game/VintagestoryAPI.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/VintagestoryAPI.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VSImGui">
Expand All @@ -23,39 +73,39 @@
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="VSSurvivalMod">
<HintPath>D:\Projects\Firearms\game/Mods/VSSurvivalMod.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Mods/VSSurvivalMod.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VSEssentials">
<HintPath>D:\Projects\Firearms\game/Mods/VSEssentials.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Mods/VSEssentials.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VSCreativeMod">
<HintPath>D:\Projects\Firearms\game/Mods/VSCreativeMod.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Mods/VSCreativeMod.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>D:\Projects\Firearms\game/Lib/Newtonsoft.Json.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Lib/Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony">
<HintPath>D:\Projects\Firearms\game/Lib/0Harmony.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Lib/0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VintagestoryLib">
<HintPath>D:\Projects\Firearms\game/VintagestoryLib.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/VintagestoryLib.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="protobuf-net">
<HintPath>D:\Projects\Firearms\game/Lib/protobuf-net.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Lib/protobuf-net.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="cairo-sharp">
<HintPath>D:\Projects\Firearms\game/Lib/cairo-sharp.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Lib/cairo-sharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Data.SQLite">
<HintPath>D:\Projects\Firearms\game/Lib/System.Data.SQLite.dll</HintPath>
<HintPath>D:\Projects\Firearms\game_19/Lib/System.Data.SQLite.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions AnimationManager/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"Client": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "\"D:/Projects/Firearms/game/Vintagestory.dll\" --tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\" \"-o\" \"test_fsm_2\"",
"workingDirectory": "D:/Projects/Firearms/game"
"commandLineArgs": "\"D:/Projects/Firearms/game_19/Vintagestory.dll\" --tracelog --dataPath \"C:/Users/user/AppData/Roaming/VintagestoryDataDev\" --addModPath \"C:/Users/user/AppData/Roaming/VintagestoryDataDev/Mods\" \"$(ProjectDir)/bin/$(Configuration)/Mods\" \"-o\" \"test_fsm_2\"",
"workingDirectory": "D:/Projects/Firearms/game_19"
},
"Server": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "\"D:/Projects/Firearms/game/VintagestoryServer.dll\" --tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\" \"-o\" \"test_fsm_2\"",
"workingDirectory": "D:/Projects/Firearms/game"
"commandLineArgs": "\"D:/Projects/Firearms/game_19/VintagestoryServer.dll\" --tracelog --dataPath \"C:/Users/user/AppData/Roaming/VintagestoryDataDev\" --addModPath \"C:/Users/user/AppData/Roaming/VintagestoryDataDev/Mods\" \"$(ProjectDir)/bin/$(Configuration)/Mods\" \"-o\" \"test_fsm_2\"",
"workingDirectory": "D:/Projects/Firearms/game_19"
}
}
}
118 changes: 118 additions & 0 deletions AnimationManager/assets/animationmanagerlib/shaders/customstandart.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#version 330 core
#extension GL_ARB_explicit_attrib_location: enable

layout(location = 0) out vec4 outColor;
layout(location = 1) out vec4 outGlow;
#if SSAOLEVEL > 0
in vec4 gnormal;
layout(location = 2) out vec4 outGNormal;
layout(location = 3) out vec4 outGPosition;
#endif

uniform sampler2D tex;
uniform float extraGodray = 0;
uniform float alphaTest = 0.001;
uniform float ssaoAttn = 0;
uniform int applySsao = 1;

// Texture overlay "hack"
// We only have the base texture UV coordinates, which, for blocks and items in inventory is the block or item texture atlas, but none uv coords for a dedicated overlay texture
// So lets remove the base offset (baseUvOrigin) and rescale the coords (baseTextureSize / overlayTextureSize) to get useful UV coordinates for the overlay texture
uniform sampler2D tex2dOverlay;
uniform float overlayOpacity;
uniform vec2 overlayTextureSize;
uniform vec2 baseTextureSize;
uniform vec2 baseUvOrigin;
uniform int normalShaded;
uniform float damageEffect = 0;
#if ALLOWDEPTHOFFSET > 0
uniform float depthOffset;
#endif

in vec2 uv;
in vec4 color;
in vec4 rgbaFog;
in float fogAmount;
in float glowLevel;
in vec4 rgbaGlow;
in vec4 camPos;
in vec4 worldPos;
in vec3 normal;
flat in int renderFlags;


#include fogandlight.fsh
#include noise2d.ash

void main() {
float b = 1;

if (damageEffect > 0) {
float f = cnoise2(floor(vec2(uv.x, uv.y) * 4096) / 4);
if (f < damageEffect - 1.3) discard;
b = min(1, f * 1.5 + 0.65 + (1-damageEffect));
}

if (overlayOpacity > 0) {
vec2 uvOverlay = (uv - baseUvOrigin) * (baseTextureSize / overlayTextureSize);

vec4 col1 = texture(tex2dOverlay, uvOverlay);
vec4 col2 = texture(tex, uv);

float a1 = overlayOpacity * col1.a * min(1, col2.a * 100);
float a2 = col2.a * (1 - a1);

outColor = vec4(
(a1 * col1.r + col2.r * a2) / (a1+a2),
(a1 * col1.b + col2.g * a2) / (a1+a2),
(a1 * col1.g + col2.b * a2) / (a1+a2),
a1 + a2
) * color;

} else {
outColor = texture(tex, uv) * color;
}

#if BLOOM == 0
outColor.rgb *= 1 + glowLevel;
#endif

if (normalShaded > 0) {
float b = min(1, getBrightnessFromNormal(normal, 1, 0.45) + glowLevel);
outColor *= vec4(b, b, b, 1);
}

outColor = applyFogAndShadow(outColor, fogAmount);

#if NORMALVIEW == 0
if (outColor.a < alphaTest) discard;
#endif

float glow = 0;
#if SHINYEFFECT > 0
outColor = mix(applyReflectiveEffect(outColor, glow, renderFlags, uv, normal, worldPos, camPos, vec3(1)), outColor, min(1, 2 * fogAmount));
glow = pow(max(0, dot(normal, lightPosition)), 6) / 8 * shadowIntensity * (1 - fogAmount);
#endif

#if SSAOLEVEL > 0
if (applySsao > 0) {
outGPosition = vec4(camPos.xyz, fogAmount + glowLevel);
} else {
outGPosition = vec4(camPos.xyz, 1);
}
outGNormal = vec4(gnormal.xyz, ssaoAttn);

#endif

#if NORMALVIEW > 0
outColor = vec4((normal.x + 1) / 2, (normal.y + 1)/2, (normal.z+1)/2, 1);
#endif

outColor.rgb *= b;
outGlow = vec4(glowLevel + glow, extraGodray - fogAmount, 0, outColor.a);

#if ALLOWDEPTHOFFSET > 0
// This likely tanks performance in any other scenario so we do only only for the first person mode rendering. See also https://www.khronos.org/opengl/wiki/Early_Fragment_Test#Limitations
gl_FragDepth = gl_FragCoord.z + depthOffset;
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#version 330 core
#extension GL_ARB_explicit_attrib_location: enable

layout(location = 0) in vec3 vertexPositionIn;
layout(location = 1) in vec2 uvIn;
layout(location = 2) in vec4 colorIn;
layout(location = 3) in int flags;
layout(location = 4) in int jointId;

uniform vec4 rgbaTint;
uniform vec3 rgbaAmbientIn;
uniform vec4 rgbaLightIn;
uniform vec4 rgbaGlowIn;
uniform vec4 rgbaFogIn;
uniform int extraGlow;
uniform float fogMinIn;
uniform float fogDensityIn;

uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 modelMatrix;
uniform mat4x3 elementTransforms[46];

uniform int dontWarpVertices;
uniform int addRenderFlags;
uniform float extraZOffset;

out vec2 uv;
out vec4 color;
out vec4 rgbaFog;
out vec4 rgbaGlow;
out float fogAmount;
out vec4 camPos;
out vec4 worldPos;
flat out int renderFlags;

out vec3 normal;
#if SSAOLEVEL > 0
out vec4 gnormal;
#endif


#include vertexflagbits.ash
#include shadowcoords.vsh
#include fogandlight.vsh
#include vertexwarp.vsh

void main(void)
{
mat4 animModelMat = modelMatrix * mat4(elementTransforms[jointId]);

worldPos = animModelMat * vec4(vertexPositionIn, 1.0);

if (dontWarpVertices == 0) {
worldPos = applyVertexWarping(flags | addRenderFlags, worldPos);
worldPos = applyGlobalWarping(worldPos);
}

camPos = viewMatrix * worldPos;

uv = uvIn;
int glow = min(255, extraGlow + (flags & GlowLevelBitMask));
renderFlags = glow | (flags & ~GlowLevelBitMask);
rgbaGlow = rgbaGlowIn;

color = rgbaTint * applyLight(rgbaAmbientIn, rgbaLightIn, renderFlags, camPos) * colorIn;
color.rgb = mix(color.rgb, rgbaGlowIn.rgb, glow / 255.0 * rgbaGlowIn.a);

// Distance fade out
color.a *= clamp(20 * (1.10 - length(worldPos.xz) / viewDistance) - 5, -1, 1);

rgbaFog = rgbaFogIn;
gl_Position = projectionMatrix * camPos;
calcShadowMapCoords(viewMatrix, worldPos);

fogAmount = getFogLevel(worldPos, fogMinIn, fogDensityIn);

gl_Position.w += extraZOffset;

normal = unpackNormal(flags);
normal = normalize((modelMatrix * vec4(normal.x, normal.y, normal.z, 0)).xyz);

#if SSAOLEVEL > 0
gnormal = viewMatrix * vec4(normal, 0);
#endif
}
Loading

0 comments on commit 74ae108

Please sign in to comment.