Exemple #1
0
        public static PackedLightData ToPackedLightData(DirectionalLightData data)
        {
            PackedLightData outData = default(PackedLightData);

            outData.packedData1   = data.positionRWS;
            outData.packedData1.w = (float)data.lightLayers + Epsilon; //防止1,转换为float变成0.999999999998;

            outData.packedData2   = data.forward;
            outData.packedData2.w = data.lightDimmer;

            outData.packedData3   = data.right;
            outData.packedData3.w = data.volumetricLightDimmer;

            outData.packedData4   = data.up;
            outData.packedData4.w = data.angleScale;

            outData.packedData5   = data.color;
            outData.packedData5.w = data.angleOffset;

            outData.packedData6 = data.shadowMaskSelector;

            outData.packedData7.x = (float)data.cookieIndex + Epsilon;        //防止1,转换为float变成0.999999999998;
            outData.packedData7.y = (float)data.tileCookie + Epsilon;         //防止1,转换为float变成0.999999999998;
            outData.packedData7.z = (float)data.shadowIndex + Epsilon;        //防止1,转换为float变成0.999999999998;
            outData.packedData7.w = (float)data.contactShadowIndex + Epsilon; //防止1,转换为float变成0.999999999998;

            outData.packedData8.x = data.shadowDimmer;
            outData.packedData8.y = data.volumetricShadowDimmer;
            outData.packedData8.z = (float)data.nonLightMappedOnly + Epsilon; //防止1,转换为float变成0.999999999998;
            outData.packedData8.w = data.minRoughness;

            outData.packedData9.x = data.diffuseDimmer;
            outData.packedData9.y = data.specularDimmer;
            outData.packedData9.z = 0;
            outData.packedData9.w = 0;

            //not use
            outData.packedData10 = Vector4.zero;
            outData.packedData11 = Vector4.zero;
            outData.packedData12 = Vector4.zero;
            outData.packedData13 = Vector4.zero;
            outData.packedData14 = Vector4.zero;

            return(outData);
        }
Exemple #2
0
        public static DirectionalLightData UnPackedLightDataToDirectionalLightData(PackedLightData data)
        {
            DirectionalLightData outData = default(DirectionalLightData);

            outData.positionRWS = data.packedData1;
            outData.lightLayers = (uint)data.packedData1.w;

            outData.forward     = data.packedData2;
            outData.lightDimmer = data.packedData2.w;

            outData.right = data.packedData3;
            outData.volumetricLightDimmer = data.packedData3.w;

            outData.up         = data.packedData4;
            outData.angleScale = data.packedData4.w;

            outData.color       = data.packedData5;
            outData.angleOffset = data.packedData5.w;

            outData.shadowMaskSelector = data.packedData6;

            outData.cookieIndex        = (int)data.packedData7.x;
            outData.tileCookie         = (int)data.packedData7.y;
            outData.shadowIndex        = (int)data.packedData7.z;
            outData.contactShadowIndex = (int)data.packedData7.w;

            outData.shadowDimmer           = data.packedData8.x;
            outData.volumetricShadowDimmer = data.packedData8.y;
            outData.nonLightMappedOnly     = (int)data.packedData8.z;
            outData.minRoughness           = data.packedData8.w;

            outData.diffuseDimmer  = data.packedData9.x;
            outData.specularDimmer = data.packedData9.y;

            return(outData);
        }