Fix issues with lighting and occlusion
This commit is contained in:
152
Packages/com.alexismorin.lightprobepopulator@1.0.0/Editor/GenerateLightProbes.cs
vendored
Normal file
152
Packages/com.alexismorin.lightprobepopulator@1.0.0/Editor/GenerateLightProbes.cs
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class GenerateLightProbes : MonoBehaviour
|
||||
{
|
||||
[MenuItem("Tools/Generate Light Probe Groups - Low Resolution")]
|
||||
static void generateLow()
|
||||
{
|
||||
|
||||
GameObject lightProbes;
|
||||
List<Vector3> probeLocations = new List<Vector3>();
|
||||
|
||||
if(GameObject.Find("Light Probe Group") != null){
|
||||
DestroyImmediate(GameObject.Find("Light Probe Group"));
|
||||
}
|
||||
|
||||
lightProbes = new GameObject("Light Probe Group");
|
||||
lightProbes.AddComponent<LightProbeGroup>();
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Generate Light Probe Groups - Medium Resolution")]
|
||||
static void generateMedium()
|
||||
{
|
||||
|
||||
GameObject lightProbes;
|
||||
List<Vector3> probeLocations = new List<Vector3>();
|
||||
|
||||
if(GameObject.Find("Light Probe Group") != null){
|
||||
DestroyImmediate(GameObject.Find("Light Probe Group"));
|
||||
}
|
||||
|
||||
lightProbes = new GameObject("Light Probe Group");
|
||||
lightProbes.AddComponent<LightProbeGroup>();
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Generate Light Probe Groups - High Resolution")]
|
||||
static void generateHigh()
|
||||
{
|
||||
|
||||
GameObject lightProbes;
|
||||
List<Vector3> probeLocations = new List<Vector3>();
|
||||
|
||||
if(GameObject.Find("Light Probe Group") != null){
|
||||
DestroyImmediate(GameObject.Find("Light Probe Group"));
|
||||
}
|
||||
|
||||
lightProbes = new GameObject("Light Probe Group");
|
||||
lightProbes.AddComponent<LightProbeGroup>();
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int boundProbes = probeLocations.Count *2;
|
||||
for(int i = 0; i < boundProbes; i++)
|
||||
{
|
||||
probeLocations.Add(Vector3.Lerp(probeLocations[Random.Range(0,boundProbes/2)], probeLocations[Random.Range(0,boundProbes/2)], 0.5f));
|
||||
|
||||
}
|
||||
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Generate Light Probe Groups - Very High Resolution")]
|
||||
static void generateVeryHigh()
|
||||
{
|
||||
|
||||
GameObject lightProbes;
|
||||
List<Vector3> probeLocations = new List<Vector3>();
|
||||
|
||||
if(GameObject.Find("Light Probe Group") != null){
|
||||
DestroyImmediate(GameObject.Find("Light Probe Group"));
|
||||
}
|
||||
|
||||
lightProbes = new GameObject("Light Probe Group");
|
||||
lightProbes.AddComponent<LightProbeGroup>();
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int boundProbes = probeLocations.Count *4;
|
||||
for(int i = 0; i < boundProbes; i++)
|
||||
{
|
||||
probeLocations.Add(Vector3.Lerp(probeLocations[Random.Range(0,boundProbes/4)], probeLocations[Random.Range(0,boundProbes/4)], 0.5f));
|
||||
|
||||
}
|
||||
|
||||
lightProbes.GetComponent<LightProbeGroup>().probePositions = probeLocations.ToArray();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Packages/com.alexismorin.lightprobepopulator@1.0.0/Editor/GenerateLightProbes.cs.meta
vendored
Normal file
11
Packages/com.alexismorin.lightprobepopulator@1.0.0/Editor/GenerateLightProbes.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2992279da8f4554fbe218e55509eb3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Packages/com.alexismorin.lightprobepopulator@1.0.0/Editor/com.alexism.lightprobepopulator.asmdef
vendored
Normal file
14
Packages/com.alexismorin.lightprobepopulator@1.0.0/Editor/com.alexism.lightprobepopulator.asmdef
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "package",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66b8d48e540037044a90a6ae29c5a8d6
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user