mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: ricochet incapable shells
This commit is contained in:
1 parent
28a9f9a849
commit
9ed2b79a4b
5 files changed
+71
-22
No files matched your search
@@ -9,10 +9,11 @@ import vertex from './shaders/vertex.glsl';
|
||||
interface ArmorMeshProps extends MeshProps {
|
||||
thickness: number;
|
||||
penetration: number;
|
||||
ricochet: number;
|
||||
caliber: number;
|
||||
normalization: number;
|
||||
spaced?: boolean;
|
||||
canRicochet: boolean;
|
||||
ricochet?: number;
|
||||
normalization?: number;
|
||||
}
|
||||
|
||||
// shader split: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial/issues/48
|
||||
@@ -21,6 +22,7 @@ export function ArmorMesh({
|
||||
thickness,
|
||||
penetration,
|
||||
caliber,
|
||||
canRicochet,
|
||||
ricochet,
|
||||
normalization,
|
||||
spaced = false,
|
||||
@@ -45,10 +47,18 @@ export function ArmorMesh({
|
||||
uniforms={{
|
||||
thickness: { value: thickness },
|
||||
penetration: { value: penetration },
|
||||
ricochet: { value: ricochet * (Math.PI / 180) },
|
||||
ricochet: {
|
||||
value: ricochet === undefined ? 0 : ricochet * (Math.PI / 180),
|
||||
},
|
||||
normalization: {
|
||||
value:
|
||||
normalization === undefined
|
||||
? 0
|
||||
: normalization * (Math.PI / 180),
|
||||
},
|
||||
caliber: { value: caliber },
|
||||
normalization: { value: normalization * (Math.PI / 180) },
|
||||
spaced: { value: spaced },
|
||||
spaced: { value: spaced ?? false },
|
||||
canRicochet: { value: canRicochet },
|
||||
}}
|
||||
vertexShader={vertex}
|
||||
fragmentShader={opaqueArmor && !spaced ? fragmentOpaque : fragment}
|
||||
|
||||
@@ -7,6 +7,7 @@ uniform float ricochet;
|
||||
uniform float caliber;
|
||||
uniform float normalization;
|
||||
uniform bool spaced;
|
||||
uniform bool canRichochet;
|
||||
|
||||
void main() {
|
||||
vec3 normalizedNormal = normalize(vNormal);
|
||||
@@ -17,7 +18,7 @@ void main() {
|
||||
float penetrationChance = -1.0;
|
||||
bool threeCaliberRule = caliber > 3.0 * thickness;
|
||||
|
||||
if (!threeCaliberRule && angle >= ricochet) {
|
||||
if (canRichochet && !threeCaliberRule && angle >= ricochet) {
|
||||
// auto ricochet angle and three caliber rule not met
|
||||
penetrationChance = 0.0;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user