using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; #if UNITY_EDITOR using UnityEditor; #endif [ExecuteInEditMode] public class ftLightmapsStorage : MonoBehaviour{ #if UNITY_EDITOR [System.Serializable] public class LightData { public Matrix4x4 tform; public Color color; public float intensity, range, radius; public int samples, samples2; public int bitmask; public bool bakeToIndirect; public bool selfShadow = false; public bool realisticFalloff = false; public int projMode; public Object cookie; public float angle = 30.0f; } public class ImplicitLightmapData { public Dictionary implicitGroupMap = null; } // Saved render settings public int renderSettingsBounces = 5; public int renderSettingsGISamples = 16; public float renderSettingsGIBackFaceWeight = 0; public int renderSettingsTileSize = 512; public float renderSettingsPriority = 2; public float renderSettingsTexelsPerUnit = 20; public bool renderSettingsForceRefresh = true; public bool renderSettingsForceRebuildGeometry = true; public bool renderSettingsPerformRendering = true; public int renderSettingsUserRenderMode = 0; public bool renderSettingsDistanceShadowmask = false; public int renderSettingsSettingsMode = 0; public bool renderSettingsFixSeams = true; public bool renderSettingsDenoise = true; public bool renderSettingsDenoise2x = false; public bool renderSettingsEncode = true; public int renderSettingsEncodeMode = 0; public bool renderSettingsOverwriteWarning = false; public bool renderSettingsAutoAtlas = true; public bool renderSettingsUnwrapUVs = true; public bool renderSettingsForceDisableUnwrapUVs = false; public int renderSettingsMaxAutoResolution = 4096; public int renderSettingsMinAutoResolution = 16; public bool renderSettingsUnloadScenes = true; public bool renderSettingsAdjustSamples = true; public int renderSettingsGILODMode = 0; public bool renderSettingsGILODModeEnabled = true; public bool renderSettingsCheckOverlaps = false; public bool renderSettingsSkipOutOfBoundsUVs = true; public float renderSettingsHackEmissiveBoost = 1; public float renderSettingsHackIndirectBoost = 1; public string renderSettingsTempPath = ""; public string renderSettingsOutPath = ""; public bool renderSettingsUseScenePath = false; public float renderSettingsHackAOIntensity = 0; public int renderSettingsHackAOSamples = 16; public float renderSettingsHackAORadius = 1; public bool renderSettingsShowAOSettings = false; public bool renderSettingsShowTasks = true; public bool renderSettingsShowTasks2 = false; public bool renderSettingsShowPaths = true; public bool renderSettingsShowNet = true; public bool renderSettingsOcclusionProbes = false; public bool renderSettingsTexelsPerMap = false; public float renderSettingsTexelsColor = 1; public float renderSettingsTexelsMask = 1; public float renderSettingsTexelsDir = 1; public bool renderSettingsShowDirWarning = true; public int renderSettingsRenderDirMode = 0; public bool renderSettingsShowCheckerSettings = false; public bool renderSettingsSamplesWarning = true; public bool renderSettingsPrefabWarning = true; public bool renderSettingsSplitByScene = false; public bool renderSettingsUVPaddingMax = false; public bool renderSettingsPostPacking = true; public bool renderSettingsHoleFilling = false; public bool renderSettingsBeepOnFinish = false; public bool renderSettingsExportTerrainAsHeightmap = true; public bool renderSettingsRTXMode = false; public int renderSettingsLightProbeMode = 1; public bool renderSettingsClientMode = false; public string renderSettingsServerAddress = "127.0.0.1"; public int renderSettingsUnwrapper = 0; public int renderSettingsDenoiserType = (int)ftGlobalStorage.DenoiserType.OpenImageDenoise; public bool renderSettingsExportTerrainTrees = false; public bool renderSettingsShowPerf = true; public int renderSettingsSampleDiv = 1; public ftGlobalStorage.AtlasPacker renderSettingsAtlasPacker = ftGlobalStorage.AtlasPacker.xatlas; public bool renderSettingsBatchPoints = true; public bool renderSettingsRTPVExport = true; public bool renderSettingsRTPVSceneView = false; public int renderSettingsRTPVWidth = 640; public int renderSettingsRTPVHeight = 360; public int lastBakeTime = 0; public bool enlightenWarningShown = false; public bool enlightenWarningShown2 = false; // Light settings from the last bake public List lightUIDs = new List(); public List lights = new List(); public Dictionary lightsDict; // List of implicit groups //public List implicitGroups = new List(); public List implicitGroups = new List(); public List implicitGroupedObjects; //public List previouslyBakedGroups = new List(); // List of baked lightmap world-space bounds public List bounds = new List(); // Per-lightmap flags public List hasEmissive = new List(); //public float[][] uvSrc; //public float[][] uvDest; //public int[][] lmrIndices; public int[] uvBuffOffsets; public int[] uvBuffLengths; public float[] uvSrcBuff; public float[] uvDestBuff; public int[] lmrIndicesOffsets; public int[] lmrIndicesLengths; public int[] lmrIndicesBuff; public int[] lmGroupLODResFlags; // bits which lods are needed for which LMGroups public int[] lmGroupMinLOD; // minimum possible resolution for given LMGroup given UV island count public int[] lmGroupLODMatrix; // Reuired for network bakes public List serverGetFileList = new List(); public List lightmapHasColor = new List(); public List lightmapHasMask = new List(); public List lightmapHasDir = new List(); public List lightmapHasRNM = new List(); // Partial copy of GlobalStorage to recover UV padding if needed public List modifiedAssetPathList = new List(); public List modifiedAssets = new List(); public Texture2D debugTex; public RenderTexture debugRT; public void Init() { lightsDict = new Dictionary(); for(int i=0; i maps = new List(); public List masks = new List(); public List dirMaps = new List(); public List rnmMaps0 = new List(); public List rnmMaps1 = new List(); public List rnmMaps2 = new List(); public List mapsMode = new List(); // new props public List bakedRenderers = new List(); public List bakedIDs = new List(); public List bakedScaleOffset = new List(); #if UNITY_EDITOR public List bakedVertexOffset = new List(); #endif public List bakedVertexColorMesh = new List(); public List nonBakedRenderers = new List(); public List bakedLights = new List(); public List bakedLightChannels = new List(); public List bakedRenderersTerrain = new List(); public List bakedIDsTerrain = new List(); public List bakedScaleOffsetTerrain = new List(); public List assetList = new List(); public List uvOverlapAssetList = new List(); // -1 = no UV1, 0 = no overlap, 1 = overlap public int[] idremap; public bool usesRealtimeGI; public Texture2D emptyDirectionTex; void Awake() { ftLightmaps.RefreshScene(gameObject.scene, this); } void Start() { // Unity can for some reason alter lightmapIndex after the scene is loaded in a multi-scene setup, so fix that ftLightmaps.RefreshScene2(gameObject.scene, this);//, appendOffset); } void OnDestroy() { ftLightmaps.UnloadScene(this); } }