Fix issues with lighting and occlusion

This commit is contained in:
Toomas Tamm
2021-04-06 20:33:49 +03:00
parent 9974f48261
commit 08d2cfbe0d
153 changed files with 10837 additions and 1592 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aa9aebac1fe24e7e80e8d3ef644b68c8
timeCreated: 1617730376

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 252613274c5003f46819eaeac896034e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b2992279da8f4554fbe218e55509eb3d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
{
"name": "package",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 66b8d48e540037044a90a6ae29c5a8d6
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
{
"name": "com.alexismorin.lightprobepopulator",
"displayName": "Light Probe Populator",
"version": "1.0.0",
"unity": "2018.2",
"description": "Filter through the scene and automatically generate Light Probes at the touch of a button.",
"keywords": [
"light",
"unity"
],
"category": "Open-Source"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 46c9f7ebd2abd65418b04b99725db123
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -17,6 +17,7 @@
"com.unity.ugui": "1.0.0",
"com.unity.xr.interaction.toolkit": "1.0.0-pre.1",
"com.unity.xr.management": "3.2.17",
"com.unity.xr.mock-hmd": "1.3.0-preview.1",
"com.unity.xr.oculus": "1.8.1",
"com.unity.xr.openxr": "1.0.3",
"com.unity.xr.windowsmr": "4.4.1",

View File

@@ -1,5 +1,11 @@
{
"dependencies": {
"com.alexismorin.lightprobepopulator": {
"version": "file:com.alexismorin.lightprobepopulator@1.0.0",
"depth": 0,
"source": "embedded",
"dependencies": {}
},
"com.unity.2d.sprite": {
"version": "1.0.0",
"depth": 0,
@@ -200,7 +206,7 @@
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.subsystemregistration": "1.0.6"
"com.unity.subsystemregistration": "1.0.5"
},
"url": "https://packages.unity.com"
},
@@ -227,6 +233,15 @@
},
"url": "https://packages.unity.com"
},
"com.unity.xr.mock-hmd": {
"version": "1.3.0-preview.1",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.xr.management": "4.0.1"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.oculus": {
"version": "1.8.1",
"depth": 0,