mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: green penetration mode
This commit is contained in:
1 parent
e37b91c2e3
commit
f5ac301c7e
4 files changed
+28
-1
No files matched your search
@@ -16,6 +16,9 @@ interface OptionsProps {
|
|||||||
|
|
||||||
export function Options({ isFullScreen, canvas }: OptionsProps) {
|
export function Options({ isFullScreen, canvas }: OptionsProps) {
|
||||||
const showGrid = useTankopedia((state) => state.model.visual.showGrid);
|
const showGrid = useTankopedia((state) => state.model.visual.showGrid);
|
||||||
|
const greenPenetration = useTankopedia(
|
||||||
|
(state) => state.model.visual.greenPenetration,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
@@ -44,6 +47,17 @@ export function Options({ isFullScreen, canvas }: OptionsProps) {
|
|||||||
>
|
>
|
||||||
Show grid
|
Show grid
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
|
|
||||||
|
<DropdownMenu.CheckboxItem
|
||||||
|
checked={greenPenetration}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
mutateTankopedia((draft) => {
|
||||||
|
draft.model.visual.greenPenetration = checked;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Greene penetration
|
||||||
|
</DropdownMenu.CheckboxItem>
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
</DropdownMenu.Root>
|
</DropdownMenu.Root>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Duel } from '../../../../app/tools/tankopedia/[id]/page';
|
|||||||
import { canSplash } from '../../../../core/blitz/canSplash';
|
import { canSplash } from '../../../../core/blitz/canSplash';
|
||||||
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
||||||
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
|
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
|
||||||
|
import { useTankopedia } from '../../../../stores/tankopedia';
|
||||||
import { externalModuleMaskRenderTarget } from '../ExternalModuleMask';
|
import { externalModuleMaskRenderTarget } from '../ExternalModuleMask';
|
||||||
import { spacedArmorDepthRenderTarget } from '../SpacedArmorDepth';
|
import { spacedArmorDepthRenderTarget } from '../SpacedArmorDepth';
|
||||||
import fragmentShader from './shaders/fragment.glsl';
|
import fragmentShader from './shaders/fragment.glsl';
|
||||||
@@ -28,6 +29,9 @@ export function ArmorMesh({
|
|||||||
duel,
|
duel,
|
||||||
...props
|
...props
|
||||||
}: ArmorMeshProps) {
|
}: ArmorMeshProps) {
|
||||||
|
const greenPenetration = useTankopedia(
|
||||||
|
(state) => state.model.visual.greenPenetration,
|
||||||
|
);
|
||||||
const camera = useThree((state) => state.camera);
|
const camera = useThree((state) => state.camera);
|
||||||
const { shell } = duel.antagonist;
|
const { shell } = duel.antagonist;
|
||||||
const material = useRef<ShaderMaterial>(null);
|
const material = useRef<ShaderMaterial>(null);
|
||||||
@@ -73,6 +77,7 @@ export function ArmorMesh({
|
|||||||
projectionMatrixInverse: { value: null },
|
projectionMatrixInverse: { value: null },
|
||||||
zNear: { value: camera.near },
|
zNear: { value: camera.near },
|
||||||
zFar: { value: camera.far },
|
zFar: { value: camera.far },
|
||||||
|
greenPenetration: { value: greenPenetration },
|
||||||
maxExternalModuleThickness: { value: maxExternalModuleThickness },
|
maxExternalModuleThickness: { value: maxExternalModuleThickness },
|
||||||
maxSpacedArmorThickness: { value: maxSpacedArmorThickness },
|
maxSpacedArmorThickness: { value: maxSpacedArmorThickness },
|
||||||
isExplosive: { value: isExplosive(shell.type) },
|
isExplosive: { value: isExplosive(shell.type) },
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ uniform vec2 resolution;
|
|||||||
varying mat4 vProjectionMatrix;
|
varying mat4 vProjectionMatrix;
|
||||||
uniform float maxExternalModuleThickness;
|
uniform float maxExternalModuleThickness;
|
||||||
uniform float maxSpacedArmorThickness;
|
uniform float maxSpacedArmorThickness;
|
||||||
|
uniform bool greenPenetration;
|
||||||
|
|
||||||
float depthToDistance(float depth) {
|
float depthToDistance(float depth) {
|
||||||
mat4 projectionMatrixInverse = inverse(vProjectionMatrix);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ interface Tankopedia {
|
|||||||
visual: {
|
visual: {
|
||||||
controlsEnabled: boolean;
|
controlsEnabled: boolean;
|
||||||
showGrid: boolean;
|
showGrid: boolean;
|
||||||
|
greenPenetration: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
mode: TankopediaMode;
|
mode: TankopediaMode;
|
||||||
@@ -66,6 +67,7 @@ export const useTankopedia = create<Tankopedia>()(
|
|||||||
visual: {
|
visual: {
|
||||||
controlsEnabled: true,
|
controlsEnabled: true,
|
||||||
showGrid: true,
|
showGrid: true,
|
||||||
|
greenPenetration: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
areTanksAssigned: false,
|
areTanksAssigned: false,
|
||||||
|
|||||||
Reference in new issue
Block a user