diff --git a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll index 3bf1b83..7fdab83 100644 Binary files a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll and b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll differ diff --git a/Source/ConformalDecals/ProjectionTarget.cs b/Source/ConformalDecals/ProjectionTarget.cs index 232f9cf..c4bb22e 100644 --- a/Source/ConformalDecals/ProjectionTarget.cs +++ b/Source/ConformalDecals/ProjectionTarget.cs @@ -22,37 +22,31 @@ namespace ConformalDecals { } public void Project(Matrix4x4 orthoMatrix, OrientedBounds projectorBounds, Transform projector, bool useBaseNormal) { - var targetBounds = _targetRenderer.bounds; - if (projectorBounds.Intersects(targetBounds)) { - _projectionEnabled = true; + _projectionEnabled = true; - var targetMaterial = _targetRenderer.sharedMaterial; - var projectorToTargetMatrix = target.worldToLocalMatrix * projector.localToWorldMatrix; + var targetMaterial = _targetRenderer.sharedMaterial; + var projectorToTargetMatrix = target.worldToLocalMatrix * projector.localToWorldMatrix; - var projectionMatrix = orthoMatrix * projectorToTargetMatrix.inverse; - var decalNormal = projectorToTargetMatrix.MultiplyVector(Vector3.back).normalized; - var decalTangent = projectorToTargetMatrix.MultiplyVector(Vector3.right).normalized; + var projectionMatrix = orthoMatrix * projectorToTargetMatrix.inverse; + var decalNormal = projectorToTargetMatrix.MultiplyVector(Vector3.back).normalized; + var decalTangent = projectorToTargetMatrix.MultiplyVector(Vector3.right).normalized; - _decalMPB.SetMatrix(DecalPropertyIDs._ProjectionMatrix, projectionMatrix); - _decalMPB.SetVector(DecalPropertyIDs._DecalNormal, decalNormal); - _decalMPB.SetVector(DecalPropertyIDs._DecalTangent, decalTangent); + _decalMPB.SetMatrix(DecalPropertyIDs._ProjectionMatrix, projectionMatrix); + _decalMPB.SetVector(DecalPropertyIDs._DecalNormal, decalNormal); + _decalMPB.SetVector(DecalPropertyIDs._DecalTangent, decalTangent); - if (useBaseNormal && targetMaterial.HasProperty(DecalPropertyIDs._BumpMap)) { - var normal = targetMaterial.GetTexture(DecalPropertyIDs._BumpMap); - if (normal != null) { + if (useBaseNormal && targetMaterial.HasProperty(DecalPropertyIDs._BumpMap)) { + var normal = targetMaterial.GetTexture(DecalPropertyIDs._BumpMap); + if (normal != null) { - _decalMPB.SetTexture(DecalPropertyIDs._BumpMap, targetMaterial.GetTexture(DecalPropertyIDs._BumpMap)); + _decalMPB.SetTexture(DecalPropertyIDs._BumpMap, targetMaterial.GetTexture(DecalPropertyIDs._BumpMap)); - var normalScale = targetMaterial.GetTextureScale(DecalPropertyIDs._BumpMap); - var normalOffset = targetMaterial.GetTextureOffset(DecalPropertyIDs._BumpMap); + var normalScale = targetMaterial.GetTextureScale(DecalPropertyIDs._BumpMap); + var normalOffset = targetMaterial.GetTextureOffset(DecalPropertyIDs._BumpMap); - _decalMPB.SetVector(DecalPropertyIDs._BumpMap_ST, new Vector4(normalScale.x, normalScale.y, normalOffset.x, normalOffset.y)); - } + _decalMPB.SetVector(DecalPropertyIDs._BumpMap_ST, new Vector4(normalScale.x, normalScale.y, normalOffset.x, normalOffset.y)); } } - else { - _projectionEnabled = false; - } } public bool Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera) {