mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: opaque amror
This commit is contained in:
1 parent
f6b4bb3923
commit
f9d0659bd4
8 files changed
+119
-28
No files matched your search
@@ -1,4 +1,6 @@
|
||||
varying vec3 vViewPosition;
|
||||
// split shaders due to https://github.com/FarazzShaikh/THREE-CustomShaderMaterial/issues/48
|
||||
|
||||
varying vec3 vCSMViewPosition;
|
||||
uniform float thickness;
|
||||
uniform float penetration;
|
||||
uniform float ricochet;
|
||||
@@ -7,7 +9,7 @@ uniform float normalization;
|
||||
|
||||
void main() {
|
||||
vec3 normalizedNormal = normalize(vNormal);
|
||||
vec3 normalizedViewPosition = normalize(vViewPosition);
|
||||
vec3 normalizedViewPosition = normalize(vCSMViewPosition);
|
||||
float cosAngle = dot(normalizedNormal, -normalizedViewPosition);
|
||||
float angle = acos(cosAngle);
|
||||
|
||||
@@ -18,18 +20,18 @@ void main() {
|
||||
float finalPenetration = penetration;
|
||||
float effectiveArmor = thickness / cos(angle - finalNormalization);
|
||||
|
||||
if(angle < ricochet) {
|
||||
if (angle < ricochet) {
|
||||
// no auto-ricochet, resume checks
|
||||
if(threeCaliberRule) {
|
||||
if (threeCaliberRule) {
|
||||
penetrationChance = 1.0;
|
||||
} else {
|
||||
float maxRandomPenetrationBuff = finalPenetration * 0.05;
|
||||
float penetrationDifference = effectiveArmor - finalPenetration;
|
||||
|
||||
if(penetrationDifference > maxRandomPenetrationBuff) {
|
||||
if (penetrationDifference > maxRandomPenetrationBuff) {
|
||||
// even with a +5% buff, can't penetrate
|
||||
penetrationChance = 0.0;
|
||||
} else if(penetrationDifference < -maxRandomPenetrationBuff) {
|
||||
} else if (penetrationDifference < -maxRandomPenetrationBuff) {
|
||||
// event with a -5% nerf, can penetrate
|
||||
penetrationChance = 1.0;
|
||||
} else {
|
||||
@@ -39,5 +41,5 @@ void main() {
|
||||
}
|
||||
}
|
||||
|
||||
csm_FragColor *= vec4(1.0, 0.0, 0.0, (1.0 - penetrationChance) * 0.5);
|
||||
csm_FragColor = vec4(1.0, 0.0, 0.0, (1.0 - penetrationChance) * 0.5);
|
||||
}
|
||||
Reference in new issue
Block a user