private void OnEnable() { RenderCamera = GetComponent <Camera>(); if (RenderCamera == Camera.main) { Current = this; CameraNear = RenderCamera.nearClipPlane; CameraFar = RenderCamera.farClipPlane - CameraNear; } _camTr = RenderCamera.transform; _Decals = new Dictionary <Material, HashSet <OzoneDecal> >(); _DecalsAlbedo = new List <OzoneDecal>(64); _DecalsTarmacs = new HashSet <OzoneDecal>(); _DecalsTarmacsNormals = new HashSet <OzoneDecal>(); //_decalComponent = new List<OzoneDecal>(); _DecalsNormal = new List <OzoneDecal>(64); //_meshFilterComponent = new List<MeshFilter>(); _matrices = new Matrix4x4[1023]; _CutOffLODValues = new float[1023]; _NearCutOffLODValues = new float[1023]; _instancedBlock = new MaterialPropertyBlock(); _directBlock = new MaterialPropertyBlock(); //_cubeMesh = cubeMesh; _cubeMesh = Resources.Load <Mesh>("DecalCubeProject"); _normalRenderTarget = new RenderTargetIdentifier[] { BuiltinRenderTextureType.GBuffer1, BuiltinRenderTextureType.GBuffer2 }; _albedoRenderTarget = new RenderTargetIdentifier[] { BuiltinRenderTextureType.GBuffer0, BuiltinRenderTextureType.GBuffer1 }; // , }
void Awake() { if (GetComponent <Camera>() == Camera.main) { Current = this; } }
private void OnBecameInvisible() { if (_Dec != null && _Dec.Shared != null) { OzoneDecalRenderer.RemoveDecal(this); //, Camera.current } }
private void OnBecameInvisible() { IsVisible = false; if (IsRendered && _Dec != null && _Dec.Shared != null) { OzoneDecalRenderer.RemoveDecal(this); //, Camera.current IsRendered = false; } }
/*public void RefreshSortingArray(int index) * { * Index = index; * tr.SetSiblingIndex(index); * OnBecameInvisible(); * OnBecameVisible(); * }*/ private void OnBecameVisible() { IsVisible = true; if (!IsRendered && _Dec != null && _Dec.Shared != null) { OzoneDecalRenderer.AddDecal(this); //, Camera.current IsRendered = true; } }
void OnWillRenderObject() { OzoneDecalRenderer.AddDecal(this, Camera.current); }