feat: green penetration mode

This commit is contained in:
TrèsAbhi committed 2024-01-16 12:22:17 -06:00
1 parent e37b91c2e3
commit f5ac301c7e
4 files changed
+28 -1

No files matched your search

@@ -7,6 +7,7 @@ import { Duel } from '../../../../app/tools/tankopedia/[id]/page';
import { canSplash } from '../../../../core/blitz/canSplash';
import { isExplosive } from '../../../../core/blitz/isExplosive';
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
import { useTankopedia } from '../../../../stores/tankopedia';
import { externalModuleMaskRenderTarget } from '../ExternalModuleMask';
import { spacedArmorDepthRenderTarget } from '../SpacedArmorDepth';
import fragmentShader from './shaders/fragment.glsl';
@@ -28,6 +29,9 @@ export function ArmorMesh({
duel,
...props
}: ArmorMeshProps) {
const greenPenetration = useTankopedia(
(state) => state.model.visual.greenPenetration,
);
const camera = useThree((state) => state.camera);
const { shell } = duel.antagonist;
const material = useRef<ShaderMaterial>(null);
@@ -73,6 +77,7 @@ export function ArmorMesh({
projectionMatrixInverse: { value: null },
zNear: { value: camera.near },
zFar: { value: camera.far },
greenPenetration: { value: greenPenetration },
maxExternalModuleThickness: { value: maxExternalModuleThickness },
maxSpacedArmorThickness: { value: maxSpacedArmorThickness },
isExplosive: { value: isExplosive(shell.type) },
@@ -14,6 +14,7 @@ uniform vec2 resolution;
varying mat4 vProjectionMatrix;
uniform float maxExternalModuleThickness;
uniform float maxSpacedArmorThickness;
uniform bool greenPenetration;
float depthToDistance(float depth) {
mat4 projectionMatrixInverse = inverse(vProjectionMatrix);
@@ -101,5 +102,10 @@ void main() {
}
}
csm_FragColor = vec4(1.0, splashChance * 0.392, 0.0, (1.0 - penetrationChance) * 0.5);
vec3 color = vec3(1.0, splashChance * 0.392, 0.0);
if (greenPenetration) {
csm_FragColor = vec4(mix(color, vec3(0.0, 1.0, 0.0), penetrationChance), 0.5);
} else {
csm_FragColor = vec4(color, (1.0 - penetrationChance) * 0.5);
}
}