diff --git a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx index f0f77649c..e9a3b0d40 100644 --- a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx +++ b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx @@ -419,6 +419,11 @@ export function Characteristics() { {shell.damage.module * damageCoefficient} + {isExplosive(shell.type) && ( + + {shell.explosionRadius!} + + )} {shell.speed * shellVelocityCoefficient} diff --git a/src/components/Armor/components/CoreArmorSceneComponent/shaders/fragment.glsl b/src/components/Armor/components/CoreArmorSceneComponent/shaders/fragment.glsl index 195bbf966..283184728 100644 --- a/src/components/Armor/components/CoreArmorSceneComponent/shaders/fragment.glsl +++ b/src/components/Armor/components/CoreArmorSceneComponent/shaders/fragment.glsl @@ -1,5 +1,6 @@ varying vec3 vNormal; varying vec3 vViewPosition; +varying mat4 vProjectionMatrix; uniform float thickness; uniform float penetration; @@ -20,7 +21,7 @@ uniform highp sampler2D spacedArmorDepth; float depthToDistance(float depth) { vec4 clipPosition = vec4(gl_FragCoord.xy / resolution * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0); - vec4 eyePosition = viewMatrix * clipPosition; + vec4 eyePosition = inverse(vProjectionMatrix) * clipPosition; return length(eyePosition.xyz / eyePosition.w); } @@ -41,36 +42,42 @@ void main() { bool twoCalibersRule = caliber > thickness * 2.0 && thickness > 0.0; float finalNormalization = twoCalibersRule ? ((1.4 * normalization * caliber) / (2.0 * thickness)) : normalization; float finalThickness = thickness / cos(max(0.0, angle - finalNormalization)); - float remainingPenetration = penetration; - // world space is in meters + // world space in meters vec4 spacedArmorDepthFragment = texture2D(spacedArmorDepth, screenCoordinates); float spacedArmorDistance = depthToDistance(spacedArmorDepthFragment.r); float coreArmorDistance = depthToDistance(gl_FragCoord.z); float distanceFromSpacedArmor = coreArmorDistance - spacedArmorDistance; - if (useSpacedArmor && isUnderSpacedArmor) { + if (canSplash && useSpacedArmor && isUnderSpacedArmor) { float spacedArmorThickness = spacedArmorBufferFragment.r * penetration; - remainingPenetration -= spacedArmorThickness; + float finalDamage = 0.5 * damage * (1.0 - distanceFromSpacedArmor / explosionRadius) - 1.1 * (thickness + spacedArmorThickness); - if (isExplosive && remainingPenetration > 0.0) { - // there is a 50% penetration loss per meter for HEAT shells - remainingPenetration -= 0.5 * remainingPenetration * distanceFromSpacedArmor; - } - } - - remainingPenetration = max(0.0, remainingPenetration); - float delta = finalThickness - remainingPenetration; - float randomization = remainingPenetration * 0.05; - penetrationChance = clamp(1.0 - (delta + randomization) / (2.0 * randomization), 0.0, 1.0); - - if (canSplash) { - // only allow splashing if the damage equation deals more than 0 damage - float nominalArmorThickness = finalThickness - remainingPenetration; - float finalDamage = 0.5 * damage * (1.0 - distanceFromSpacedArmor / explosionRadius) - 1.1 * nominalArmorThickness; - splashChance = finalDamage > 0.0 ? 1.0 : 0.0; // TODO: add randomization here? + penetrationChance = 0.0; + splashChance = finalDamage > 0.0 ? 1.0 : 0.0; } else { - splashChance = 0.0; + float remainingPenetration = penetration; + + if (useSpacedArmor && isUnderSpacedArmor) { + float spacedArmorThickness = spacedArmorBufferFragment.r * penetration; + remainingPenetration -= spacedArmorThickness; + + if (isExplosive && remainingPenetration > 0.0) { + remainingPenetration -= 0.5 * remainingPenetration * distanceFromSpacedArmor; + } + } + + remainingPenetration = max(0.0, remainingPenetration); + float delta = finalThickness - remainingPenetration; + float randomization = remainingPenetration * 0.05; + penetrationChance = clamp(1.0 - (delta + randomization) / (2.0 * randomization), 0.0, 1.0); + + if (canSplash) { + float splashDamage = 0.5 * damage - 1.1 * finalThickness; + splashChance = splashDamage > 0.0 ? 1.0 : 0.0; + } else { + splashChance = 0.0; + } } } diff --git a/src/components/Armor/components/CoreArmorSceneComponent/shaders/vertex.glsl b/src/components/Armor/components/CoreArmorSceneComponent/shaders/vertex.glsl index 82f94e255..0e4d1407f 100644 --- a/src/components/Armor/components/CoreArmorSceneComponent/shaders/vertex.glsl +++ b/src/components/Armor/components/CoreArmorSceneComponent/shaders/vertex.glsl @@ -1,10 +1,12 @@ varying vec3 vNormal; varying vec3 vViewPosition; +varying mat4 vProjectionMatrix; void main() { vec4 vViewPosition4 = modelViewMatrix * vec4(position, 1.0); vViewPosition = vViewPosition4.xyz; + vProjectionMatrix = projectionMatrix; vNormal = normalMatrix * normal; gl_Position = projectionMatrix * vViewPosition4;