fix: use normal proj mat

This commit is contained in:
TrèsAbhi committed 2024-03-30 10:39:58 -05:00
1 parent 892434e28f
commit 9d62965fc3
3 files changed
+6 -10

No files matched your search

@@ -57,7 +57,7 @@ export function CoreArmorSceneComponent({
});
useEffect(() => {
function handleShellChange(shell: ShellDefinition) {
async function handleShellChange(shell: ShellDefinition) {
material.uniforms.caliber.value = shell.caliber;
material.uniforms.ricochet.value = degToRad(shell.ricochet ?? 90);
material.uniforms.normalization.value = degToRad(
@@ -68,10 +68,9 @@ export function CoreArmorSceneComponent({
material.uniforms.damage.value = shell.damage.armor;
material.uniforms.explosionRadius.value = shell.explosionRadius;
handleProtagonistEquipmentChange(
useDuel.getState().protagonist!.equipment,
);
handleAntagonistEquipmentChange(useDuel.getState().antagonist!.equipment);
const duel = useDuel.getState();
await handleProtagonistEquipmentChange(duel.protagonist!.equipment);
await handleAntagonistEquipmentChange(duel.antagonist!.equipment);
}
function handleVisualChange(
visual: TankopediaPersistent['model']['visual'],
@@ -93,6 +92,7 @@ export function CoreArmorSceneComponent({
const shell = useDuel.getState().antagonist!.shell;
const penetration = resolveNearPenetration(shell.penetration);
const hasCalibratedShells = await hasEquipment(103, true, equipment);
material.uniforms.penetration.value = hasCalibratedShells
? penetration * (isExplosive(shell.type) ? 1.1 : 1.05)
: penetration;
@@ -1,6 +1,5 @@
varying vec3 vNormal;
varying vec3 vViewPosition;
varying mat4 vProjectionMatrix;
uniform float thickness;
uniform float penetration;
@@ -15,14 +14,13 @@ uniform float explosionRadius;
uniform bool greenPenetration;
uniform bool opaque;
uniform bool useSpacedArmor;
uniform mat4 inverseViewProjectionMatrix;
uniform highp sampler2D spacedArmorBuffer;
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 = inverseViewProjectionMatrix * clipPosition;
vec4 eyePosition = viewMatrix * clipPosition;
return length(eyePosition.xyz / eyePosition.w);
}
@@ -1,12 +1,10 @@
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;