Bake final lightmaps

This commit is contained in:
Toomas Tamm
2021-04-07 02:00:00 +03:00
parent 8fc49e1840
commit 6e40533863
90 changed files with 52527 additions and 40426 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
public class GenerateLightProbes : MonoBehaviour
{
@@ -54,17 +55,12 @@ public class GenerateLightProbes : MonoBehaviour
GameObject[] objectsInScene = UnityEngine.Object.FindObjectsOfType<GameObject>() ;
foreach(GameObject obj in objectsInScene)
{
if(obj.isStatic){
if(obj.GetComponent<Renderer>() != null){
probeLocations.Add( obj.GetComponent<Renderer>().bounds.max);
probeLocations.Add( obj.GetComponent<Renderer>().bounds.min);
}
}
{
if (!obj.isStatic) continue;
if (obj.GetComponent<Renderer>() == null) continue;
probeLocations.Add( obj.GetComponent<Renderer>().bounds.max);
probeLocations.Add( obj.GetComponent<Renderer>().bounds.min);
}
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
@@ -87,20 +83,18 @@ public class GenerateLightProbes : MonoBehaviour
GameObject[] objectsInScene = UnityEngine.Object.FindObjectsOfType<GameObject>() ;
foreach(GameObject obj in objectsInScene)
{
if(obj.isStatic){
{
if (!obj.isStatic) continue;
if (obj.GetComponent<Renderer>() == null) continue;
if (obj.name.ToLower().Contains("light") || obj.name.ToLower().Contains("lamp")) continue;
if (obj.GetComponent<Renderer>().lightProbeUsage == LightProbeUsage.Off) continue;
if(obj.GetComponent<Renderer>() != null){
probeLocations.Add( obj.GetComponent<Renderer>().bounds.max);
probeLocations.Add( obj.GetComponent<Renderer>().bounds.min);
}
}
probeLocations.Add( obj.GetComponent<Renderer>().bounds.max);
probeLocations.Add( obj.GetComponent<Renderer>().bounds.min);
}
int boundProbes = probeLocations.Count *2;
for(int i = 0; i < boundProbes; i++)
for(var i = 0; i < boundProbes; i++)
{
probeLocations.Add(Vector3.Lerp(probeLocations[Random.Range(0,boundProbes/2)], probeLocations[Random.Range(0,boundProbes/2)], 0.5f));
@@ -126,16 +120,14 @@ public class GenerateLightProbes : MonoBehaviour
GameObject[] objectsInScene = UnityEngine.Object.FindObjectsOfType<GameObject>() ;
foreach(GameObject obj in objectsInScene)
{
if(obj.isStatic){
if(obj.GetComponent<Renderer>() != null){
probeLocations.Add( obj.GetComponent<Renderer>().bounds.max);
probeLocations.Add( obj.GetComponent<Renderer>().bounds.min);
}
}
{
if (!obj.isStatic) continue;
if (obj.GetComponent<Renderer>() == null) continue;
if (obj.name.ToLower().Contains("light") || obj.name.ToLower().Contains("lamp")) continue;
if (obj.GetComponent<Renderer>().lightProbeUsage == LightProbeUsage.Off) continue;
probeLocations.Add( obj.GetComponent<Renderer>().bounds.max);
probeLocations.Add( obj.GetComponent<Renderer>().bounds.min);
}
int boundProbes = probeLocations.Count *4;