Added Fog and other fixes
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirza.AERO
|
||||
{
|
||||
// May require domain reloading to be enabled.
|
||||
// Scene mode can apparently mess it up, otherwise.
|
||||
|
||||
// So at least hiding scene views and then playing
|
||||
// will fix the updater and it will work as normal.
|
||||
|
||||
[ExecuteAlways]
|
||||
public class CustomRenderTextureUpdater : MonoBehaviour
|
||||
{
|
||||
public CustomRenderTexture texture;
|
||||
|
||||
void Update()
|
||||
{
|
||||
texture.Update(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53b4bd9e79af7f44fb825085162db998
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277702
|
||||
packageName: AERO - Volumetric Fog and Mist
|
||||
packageVersion: 1.8.0
|
||||
assetPath: Assets/Mirza/AERO - Volumetric Fog and Mist/Scripts/CustomRenderTextureUpdater.cs
|
||||
uploadId: 933120
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.RenderGraphModule;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Mirza.AERO
|
||||
{
|
||||
// Send lighting data/information to material.
|
||||
// Useful for custom fullscreen shaders that need lighting data, such as volumetric fog/mist.
|
||||
|
||||
public class FullscreenCustomLightingFeature : ScriptableRendererFeature
|
||||
{
|
||||
// 'AfterRenderingTransparents' is the default.
|
||||
// After that, light count may not be accurate/correct.
|
||||
|
||||
public RenderPassEvent renderPassEvent = RenderPassEvent.AfterRenderingTransparents;
|
||||
public Material material;
|
||||
|
||||
CustomPass countPass;
|
||||
|
||||
public override void Create()
|
||||
{
|
||||
countPass = new CustomPass();
|
||||
}
|
||||
|
||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
{
|
||||
if (material == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
countPass.renderPassEvent = renderPassEvent;
|
||||
countPass.material = material;
|
||||
|
||||
renderer.EnqueuePass(countPass);
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
class CustomPass : ScriptableRenderPass
|
||||
{
|
||||
static readonly int additionalLightCountId = Shader.PropertyToID("_AdditionalLightCount");
|
||||
static readonly int ambientLightingId = Shader.PropertyToID("_AmbientLighting");
|
||||
|
||||
public Material material;
|
||||
|
||||
// Material value is CPU-side, so it is written during recording, not render func.
|
||||
|
||||
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
|
||||
{
|
||||
// Ambient lighting is global render setting, so it needs no per-camera data.
|
||||
|
||||
Color ambientLighting = RenderSettings.ambientLight * RenderSettings.ambientIntensity;
|
||||
|
||||
material.SetColor(ambientLightingId, ambientLighting);
|
||||
|
||||
// Additional light count is the visible set for this camera.
|
||||
|
||||
if (!frameData.Contains<UniversalLightData>())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UniversalLightData lightData = frameData.Get<UniversalLightData>();
|
||||
material.SetInteger(additionalLightCountId, lightData.additionalLightsCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cc70a8037c1b70499f4123cdac0f2fa
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277702
|
||||
packageName: AERO - Volumetric Fog and Mist
|
||||
packageVersion: 1.8.0
|
||||
assetPath: Assets/Mirza/AERO - Volumetric Fog and Mist/Scripts/FullscreenCustomLightingFeature.cs
|
||||
uploadId: 933120
|
||||
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirza.AERO
|
||||
{
|
||||
// This script updates the volumetric fog material with information about
|
||||
// the number of additional lights in the scene and ambient lighting.
|
||||
|
||||
// This is old. Use FullscreenCustomLightingFeature instead.
|
||||
|
||||
[ExecuteAlways]
|
||||
public class VolumetricFogController : MonoBehaviour
|
||||
{
|
||||
public Material material;
|
||||
public int additionalLightCountBase;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
int additionalLightCount = additionalLightCountBase;
|
||||
Light[] lights = FindObjectsByType<Light>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
|
||||
|
||||
for (int i = 0; i < lights.Length; i++)
|
||||
{
|
||||
if (lights[i].type != LightType.Directional)
|
||||
{
|
||||
additionalLightCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Need to loop framecount, else interleaved gradient noise becomes erratic.
|
||||
|
||||
material.SetInteger("_FrameCount", Time.renderedFrameCount % 60);
|
||||
material.SetInteger("_AdditionalLightCount", additionalLightCount);
|
||||
|
||||
Color ambientLighting = RenderSettings.ambientLight * RenderSettings.ambientIntensity;
|
||||
|
||||
material.SetColor("_AmbientLighting", ambientLighting);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4e4b5b3996032e4681cda701e89f62f
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277702
|
||||
packageName: AERO - Volumetric Fog and Mist
|
||||
packageVersion: 1.8.0
|
||||
assetPath: Assets/Mirza/AERO - Volumetric Fog and Mist/Scripts/VolumetricFogController.cs
|
||||
uploadId: 933120
|
||||
Reference in New Issue
Block a user