add water

This commit is contained in:
2023-12-06 23:08:22 +02:00
parent 58d0f79bd1
commit c5bf312689
308 changed files with 38062 additions and 42179 deletions
@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class Water_Settings : MonoBehaviour
{
Material waterVolume;
Material waterMaterial;
void Update()
{
if(waterVolume == null)
{
waterVolume = (Material)Resources.Load("Water_Volume");
}
if (waterMaterial == null)
{
waterMaterial = GetComponent<MeshRenderer>().sharedMaterial;
}
waterVolume.SetVector("pos", new Vector4(0, (waterVolume.GetVector("bounds").y / -2) + transform.position.y + (waterMaterial.GetFloat("_Displacement_Amount") / 3), 0, 0));
}
}
@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 10f7b96a1d2bd1f4db1c1016821e87ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 206909
packageName: WaterWorks - Simple water/ocean/river system for URP + reflection
+ refraction
packageVersion: 1.0
assetPath: Assets/WaterWorks/Scripts/Water_Settings.cs
uploadId: 476381
+97
View File
@@ -0,0 +1,97 @@
using UnityEngine;
using UnityEngine.Diagnostics;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using static Unity.Burst.Intrinsics.X86.Avx;
public class Water_Volume : ScriptableRendererFeature
{
class CustomRenderPass : ScriptableRenderPass
{
public RTHandle source;
private Material _material;
private RTHandle tempRenderTarget;
private RTHandle tempRenderTarget2;
public CustomRenderPass(Material mat)
{
_material = mat;
tempRenderTarget=RTHandles.Alloc("_TemporaryColourTexture");
tempRenderTarget2 = RTHandles.Alloc("_TemporaryDepthTexture");
}
// This method is called before executing the render pass.
// It can be used to configure render targets and their clear state. Also to create temporary render target textures.
// When empty this render pass will render to the active camera render target.
// You should never call CommandBuffer.SetRenderTarget. Instead call <c>ConfigureTarget</c> and <c>ConfigureClear</c>.
// The render pipeline will ensure target setup and clearing happens in an performance manner.
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
}
// Here you can implement the rendering logic.
// Use <c>ScriptableRenderContext</c> to issue drawing commands or execute command buffers
// https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.html
// You don't have to call ScriptableRenderContext.submit, the render pipeline will call it at specific points in the pipeline.
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
if(renderingData.cameraData.cameraType != CameraType.Reflection)
{
CommandBuffer commandBuffer = CommandBufferPool.Get();
commandBuffer.GetTemporaryRT(Shader.PropertyToID(tempRenderTarget.name), renderingData.cameraData.cameraTargetDescriptor);
Blitter.BlitCameraTexture(commandBuffer, source, tempRenderTarget, _material,0);
Blitter.BlitCameraTexture(commandBuffer, tempRenderTarget, source);
context.ExecuteCommandBuffer(commandBuffer);
CommandBufferPool.Release(commandBuffer);
}
}
/// Cleanup any allocated resources that were created during the execution of this render pass.
public override void FrameCleanup(CommandBuffer cmd)
{
}
}
[System.Serializable]
public class _Settings
{
//[HideInInspector]
public Material material = null;
public RenderPassEvent renderPass = RenderPassEvent.AfterRenderingSkybox;
}
public _Settings settings = new _Settings();
CustomRenderPass m_ScriptablePass;
public override void Create()
{
if(settings.material == null)
{
settings.material = (Material)Resources.Load("Water_Volume");
}
m_ScriptablePass = new CustomRenderPass(settings.material);
// Configures where the render pass should be injected.
//m_ScriptablePass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
m_ScriptablePass.renderPassEvent = settings.renderPass;
}
// Here you can inject one or multiple render passes in the renderer.
// This method is called when setting up the renderer once per-camera.
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
m_ScriptablePass.source = renderer.cameraColorTargetHandle;
renderer.EnqueuePass(m_ScriptablePass);
}
}
@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d1fc12ddd23443b47b1a51403adeb283
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 206909
packageName: WaterWorks - Simple water/ocean/river system for URP + reflection
+ refraction
packageVersion: 1.0
assetPath: Assets/WaterWorks/Scripts/Water_Volume.cs
uploadId: 476381