diff --git a/next.config.js b/next.config.js index 78a50013e..d923618ce 100644 --- a/next.config.js +++ b/next.config.js @@ -4,18 +4,18 @@ const withVanillaExtract = createVanillaExtractPlugin({ tests: /\.css$/ }); /** @type {import('next').NextConfig} */ const nextConfig = { - ...withVanillaExtract(), + ...withVanillaExtract({ + webpack: (config) => { + config.module.rules.push({ + test: /\.glsl$/, + type: 'asset/source', + }); + return config; + }, + }), distDir: 'dist/website', reactStrictMode: false, - - webpack: (config) => { - config.module.rules.push({ - test: /\.glsl$/, - type: 'asset/source', - }); - return config; - }, }; export default nextConfig; diff --git a/src/components/ArmorMesh/shaders/fragment.glsl b/src/components/ArmorMesh/shaders/fragment.glsl index 496f6fe31..b34232105 100644 --- a/src/components/ArmorMesh/shaders/fragment.glsl +++ b/src/components/ArmorMesh/shaders/fragment.glsl @@ -15,13 +15,27 @@ void main() { bool twoCaliberRule = caliber > 2.0 * thickness; bool threeCaliberRule = caliber > 3.0 * thickness; float finalNormalization = twoCaliberRule ? (normalization * 1.4 * caliber) / (2.0 * thickness) : normalization; - + float finalPenetration = penetration; float effectiveArmor = thickness / cos(angle - finalNormalization); if(angle < ricochet) { // no auto-ricochet, resume checks - if(effectiveArmor <= penetration || threeCaliberRule) { + if(threeCaliberRule) { penetrationChance = 1.0; + } else { + float maxRandomPenetrationBuff = finalPenetration * 0.05; + float penetrationDifference = effectiveArmor - finalPenetration; + + if(penetrationDifference > maxRandomPenetrationBuff) { + // even with a +5% buff, can't penetrate + penetrationChance = 0.0; + } else if(penetrationDifference < -maxRandomPenetrationBuff) { + // event with a -5% nerf, can penetrate + penetrationChance = 1.0; + } else { + // penetration gradiant + penetrationChance = 1.0 - (penetrationDifference + maxRandomPenetrationBuff) / (2.0 * maxRandomPenetrationBuff); + } } }