public void UpdateVolume()
        {
            float3x3 localToWorld = new float3x3
            {
                c0 = transform.right,
                c1 = transform.up,
                c2 = transform.forward
            };
            float4x4 worldToLocal = inverse(new float4x4
            {
                c0 = float4(localToWorld.c0, 0),
                c1 = float4(localToWorld.c1, 0),
                c2 = float4(localToWorld.c2, 0),
                c3 = float4(transform.position, 1)
            });
            FogVolume volume = new FogVolume
            {
                extent        = transform.localScale * 0.5f,
                localToWorld  = localToWorld,
                position      = transform.position,
                worldToLocal  = worldToLocal,
                targetVolume  = this.volume,
                color         = float3(fogColor.r, fogColor.g, fogColor.b),
                emissionColor = float3(emissionColor.r, emissionColor.g, emissionColor.b)
            };

            allVolumes[index].volume = volume;
        }
        private void OnEnable()
        {
            if (!allVolumes.isCreated)
            {
                allVolumes = new NativeList <FogVolumeContainer>(30, Allocator.Persistent);
            }

            FogVolumeContainer currentcon;

            currentcon.light = MUnsafeUtility.GetManagedPtr(this);
            float3x3 localToWorld = new float3x3
            {
                c0 = transform.right,
                c1 = transform.up,
                c2 = transform.forward
            };
            float4x4  worldToLocal = transform.worldToLocalMatrix;
            FogVolume volume       = new FogVolume
            {
                extent        = transform.localScale * 0.5f,
                localToWorld  = localToWorld,
                position      = transform.position,
                worldToLocal  = float3x4(worldToLocal.c0.xyz, worldToLocal.c1.xyz, worldToLocal.c2.xyz, worldToLocal.c3.xyz),
                targetVolume  = this.volume,
                color         = float3(fogColor.r, fogColor.g, fogColor.b),
                emissionColor = float3(emissionColor.r, emissionColor.g, emissionColor.b)
            };

            currentcon.volume = volume;
            allVolumes.Add(currentcon);
            index = allVolumes.Length - 1;
        }
        public void UpdateVolume()
        {
            float3x3 localToWorld = new float3x3
            {
                c0 = transform.right,
                c1 = transform.up,
                c2 = transform.forward
            };
            float4x4  worldToLocal = transform.worldToLocalMatrix;
            FogVolume volume       = new FogVolume
            {
                extent        = transform.localScale * 0.5f,
                localToWorld  = localToWorld,
                position      = transform.position,
                worldToLocal  = float3x4(worldToLocal.c0.xyz, worldToLocal.c1.xyz, worldToLocal.c2.xyz, worldToLocal.c3.xyz),
                targetVolume  = this.volume,
                color         = float3(fogColor.r, fogColor.g, fogColor.b),
                emissionColor = float3(emissionColor.r, emissionColor.g, emissionColor.b)
            };

            allVolumes[index].volume = volume;
        }
Пример #4
0
        private void OnEnable()
        {
            if (!allVolumes.isCreated)
            {
                allVolumes = new NativeList <FogVolumeContainer>(30, Allocator.Persistent);
            }

            FogVolumeContainer currentcon;

            currentcon.light = MUnsafeUtility.GetManagedPtr(this);
            float3x3 localToWorld = new float3x3
            {
                c0 = transform.right,
                c1 = transform.up,
                c2 = transform.forward
            };
            float4x4 worldToLocal = inverse(new float4x4
            {
                c0 = float4(localToWorld.c0, 0),
                c1 = float4(localToWorld.c1, 0),
                c2 = float4(localToWorld.c2, 0),
                c3 = float4(transform.position, 1)
            });
            FogVolume volume = new FogVolume
            {
                extent       = transform.localScale * 0.5f,
                localToWorld = localToWorld,
                position     = transform.position,
                worldToLocal = worldToLocal,
                targetVolume = this.volume
            };

            currentcon.volume = volume;
            allVolumes.Add(currentcon);
            container = allVolumes.unsafePtr + allVolumes.Length - 1;
        }
Пример #5
0
            public static bool BoxUnderPlane(ref float4 plane, ref FogVolume fog, int i)
            {
                float3 absNormal = abs(normalize(mul(plane.xyz, fog.localToWorld)));

                return(dot(fog.position, plane.xyz) - dot(absNormal, fog.extent) < -plane.w);
            }