init 1.7.1
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 142d711dc89ddcd4db3b6e9e5bbcbef4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 927d742da58a9bc4a8bec66af60ab51b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a010e30617a28442913834307afd27f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4706ba5538961634cba6c7a65901f001
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,194 @@
|
||||
//
|
||||
// Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader
|
||||
//
|
||||
// Original work (webgl-noise) Copyright (C) 2011 Stefan Gustavson
|
||||
// Translation and modification was made by Keijiro Takahashi.
|
||||
//
|
||||
// This shader is based on the webgl-noise GLSL shader. For further details
|
||||
// of the original shader, please see the following description from the
|
||||
// original source code.
|
||||
//
|
||||
|
||||
//
|
||||
// GLSL textureless classic 3D noise "cnoise",
|
||||
// with an RSL-style periodic variant "pnoise".
|
||||
// Author: Stefan Gustavson (stefan.gustavson@liu.se)
|
||||
// Version: 2011-10-11
|
||||
//
|
||||
// Many thanks to Ian McEwan of Ashima Arts for the
|
||||
// ideas for permutation and gradient selection.
|
||||
//
|
||||
// Copyright (c) 2011 Stefan Gustavson. All rights reserved.
|
||||
// Distributed under the MIT license. See LICENSE file.
|
||||
// https://github.com/ashima/webgl-noise
|
||||
//
|
||||
|
||||
float3 mod(float3 x, float3 y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float3 mod289(float3 x)
|
||||
{
|
||||
return x - floor(x / 289.0) * 289.0;
|
||||
}
|
||||
|
||||
float4 mod289(float4 x)
|
||||
{
|
||||
return x - floor(x / 289.0) * 289.0;
|
||||
}
|
||||
|
||||
float4 permute(float4 x)
|
||||
{
|
||||
return mod289(((x*34.0)+1.0)*x);
|
||||
}
|
||||
|
||||
float4 taylorInvSqrt(float4 r)
|
||||
{
|
||||
return (float4)1.79284291400159 - r * 0.85373472095314;
|
||||
}
|
||||
|
||||
float3 fade(float3 t) {
|
||||
return t*t*t*(t*(t*6.0-15.0)+10.0);
|
||||
}
|
||||
|
||||
// Classic Perlin noise
|
||||
float cnoise(float3 P)
|
||||
{
|
||||
float3 Pi0 = floor(P); // Integer part for indexing
|
||||
float3 Pi1 = Pi0 + (float3)1.0; // Integer part + 1
|
||||
Pi0 = mod289(Pi0);
|
||||
Pi1 = mod289(Pi1);
|
||||
float3 Pf0 = frac(P); // Fractional part for interpolation
|
||||
float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0
|
||||
float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
|
||||
float4 iz0 = (float4)Pi0.z;
|
||||
float4 iz1 = (float4)Pi1.z;
|
||||
|
||||
float4 ixy = permute(permute(ix) + iy);
|
||||
float4 ixy0 = permute(ixy + iz0);
|
||||
float4 ixy1 = permute(ixy + iz1);
|
||||
|
||||
float4 gx0 = ixy0 / 7.0;
|
||||
float4 gy0 = frac(floor(gx0) / 7.0) - 0.5;
|
||||
gx0 = frac(gx0);
|
||||
float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0);
|
||||
float4 sz0 = step(gz0, (float4)0.0);
|
||||
gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5);
|
||||
gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5);
|
||||
|
||||
float4 gx1 = ixy1 / 7.0;
|
||||
float4 gy1 = frac(floor(gx1) / 7.0) - 0.5;
|
||||
gx1 = frac(gx1);
|
||||
float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1);
|
||||
float4 sz1 = step(gz1, (float4)0.0);
|
||||
gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5);
|
||||
gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5);
|
||||
|
||||
float3 g000 = float3(gx0.x,gy0.x,gz0.x);
|
||||
float3 g100 = float3(gx0.y,gy0.y,gz0.y);
|
||||
float3 g010 = float3(gx0.z,gy0.z,gz0.z);
|
||||
float3 g110 = float3(gx0.w,gy0.w,gz0.w);
|
||||
float3 g001 = float3(gx1.x,gy1.x,gz1.x);
|
||||
float3 g101 = float3(gx1.y,gy1.y,gz1.y);
|
||||
float3 g011 = float3(gx1.z,gy1.z,gz1.z);
|
||||
float3 g111 = float3(gx1.w,gy1.w,gz1.w);
|
||||
|
||||
float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
|
||||
g000 *= norm0.x;
|
||||
g010 *= norm0.y;
|
||||
g100 *= norm0.z;
|
||||
g110 *= norm0.w;
|
||||
|
||||
float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
|
||||
g001 *= norm1.x;
|
||||
g011 *= norm1.y;
|
||||
g101 *= norm1.z;
|
||||
g111 *= norm1.w;
|
||||
|
||||
float n000 = dot(g000, Pf0);
|
||||
float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z));
|
||||
float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z));
|
||||
float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z));
|
||||
float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z));
|
||||
float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z));
|
||||
float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z));
|
||||
float n111 = dot(g111, Pf1);
|
||||
|
||||
float3 fade_xyz = fade(Pf0);
|
||||
float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z);
|
||||
float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y);
|
||||
float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x);
|
||||
return 2.2 * n_xyz;
|
||||
}
|
||||
|
||||
// Classic Perlin noise, periodic variant
|
||||
float pnoise(float3 P, float3 rep)
|
||||
{
|
||||
float3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
|
||||
float3 Pi1 = mod(Pi0 + (float3)1.0, rep); // Integer part + 1, mod period
|
||||
Pi0 = mod289(Pi0);
|
||||
Pi1 = mod289(Pi1);
|
||||
float3 Pf0 = frac(P); // Fractional part for interpolation
|
||||
float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0
|
||||
float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
|
||||
float4 iz0 = (float4)Pi0.z;
|
||||
float4 iz1 = (float4)Pi1.z;
|
||||
|
||||
float4 ixy = permute(permute(ix) + iy);
|
||||
float4 ixy0 = permute(ixy + iz0);
|
||||
float4 ixy1 = permute(ixy + iz1);
|
||||
|
||||
float4 gx0 = ixy0 / 7.0;
|
||||
float4 gy0 = frac(floor(gx0) / 7.0) - 0.5;
|
||||
gx0 = frac(gx0);
|
||||
float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0);
|
||||
float4 sz0 = step(gz0, (float4)0.0);
|
||||
gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5);
|
||||
gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5);
|
||||
|
||||
float4 gx1 = ixy1 / 7.0;
|
||||
float4 gy1 = frac(floor(gx1) / 7.0) - 0.5;
|
||||
gx1 = frac(gx1);
|
||||
float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1);
|
||||
float4 sz1 = step(gz1, (float4)0.0);
|
||||
gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5);
|
||||
gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5);
|
||||
|
||||
float3 g000 = float3(gx0.x,gy0.x,gz0.x);
|
||||
float3 g100 = float3(gx0.y,gy0.y,gz0.y);
|
||||
float3 g010 = float3(gx0.z,gy0.z,gz0.z);
|
||||
float3 g110 = float3(gx0.w,gy0.w,gz0.w);
|
||||
float3 g001 = float3(gx1.x,gy1.x,gz1.x);
|
||||
float3 g101 = float3(gx1.y,gy1.y,gz1.y);
|
||||
float3 g011 = float3(gx1.z,gy1.z,gz1.z);
|
||||
float3 g111 = float3(gx1.w,gy1.w,gz1.w);
|
||||
|
||||
float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
|
||||
g000 *= norm0.x;
|
||||
g010 *= norm0.y;
|
||||
g100 *= norm0.z;
|
||||
g110 *= norm0.w;
|
||||
float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
|
||||
g001 *= norm1.x;
|
||||
g011 *= norm1.y;
|
||||
g101 *= norm1.z;
|
||||
g111 *= norm1.w;
|
||||
|
||||
float n000 = dot(g000, Pf0);
|
||||
float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z));
|
||||
float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z));
|
||||
float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z));
|
||||
float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z));
|
||||
float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z));
|
||||
float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z));
|
||||
float n111 = dot(g111, Pf1);
|
||||
|
||||
float3 fade_xyz = fade(Pf0);
|
||||
float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z);
|
||||
float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y);
|
||||
float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x);
|
||||
return 2.2 * n_xyz;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 123f0a31ab8e2bb40b9dabc9d22eceb1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,493 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
using System;
|
||||
|
||||
namespace Artngame.SKYMASTER
|
||||
{
|
||||
[Serializable, VolumeComponentMenu("Post-processing/Custom/SunShaftsSM_HDRP")]
|
||||
public sealed class SunShaftsSM_HDRP : CustomPostProcessVolumeComponent, IPostProcessComponent
|
||||
{
|
||||
|
||||
|
||||
[Tooltip("Controls the intensity of the effect.")]
|
||||
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
|
||||
|
||||
public BoolParameter shaftsFollowCamera = new BoolParameter(false);
|
||||
|
||||
|
||||
//v1.2
|
||||
public BoolParameter useWaterAirMask = new BoolParameter(true);
|
||||
public BoolParameter resetScaling = new BoolParameter(false);
|
||||
|
||||
//v1.2
|
||||
public BoolParameter useVolumeMaskRenderer = new BoolParameter(false);
|
||||
//public WaterMaskRendererSM_HDRP_VOLUME volumeRendererMASK;
|
||||
//public int passID = 2;
|
||||
public RenderTextureParameter MaskMap = new RenderTextureParameter(null);
|
||||
|
||||
//SHAFTS
|
||||
public enum SunShaftsResolution
|
||||
{
|
||||
Low = 0,
|
||||
Normal = 1,
|
||||
High = 2,
|
||||
}
|
||||
public enum ShaftsScreenBlendMode
|
||||
{
|
||||
Screen = 0,
|
||||
Add = 1,
|
||||
}
|
||||
public SunShaftsResolution resolution = SunShaftsResolution.Normal;
|
||||
public ShaftsScreenBlendMode screenBlendMode = ShaftsScreenBlendMode.Screen;
|
||||
public Vector3Parameter sunTransform = new Vector3Parameter(new Vector3(0f, 0f, 0f)); //public Vector3 sunTransform = new Vector3(0f, 0f, 0f);
|
||||
public IntParameter radialBlurIterations = new IntParameter(2); //public int radialBlurIterations = 2;
|
||||
public ColorParameter sunColor = new ColorParameter(Color.white);
|
||||
public ColorParameter sunThreshold = new ColorParameter(new Color(0.87f, 0.74f, 0.65f));
|
||||
public FloatParameter sunShaftBlurRadius = new FloatParameter(2.5f);
|
||||
public FloatParameter sunShaftIntensity = new FloatParameter(1.15f);
|
||||
public FloatParameter maxRadius = new FloatParameter(0.75f);
|
||||
public BoolParameter useDepthTexture = new BoolParameter(true);
|
||||
|
||||
//MASK
|
||||
public FloatParameter waterHeight = new FloatParameter(0);
|
||||
|
||||
|
||||
/////REFRACT LINE
|
||||
public TextureParameter BumpMap = new TextureParameter(null);
|
||||
public FloatParameter underwaterDepthFade = new FloatParameter(1.1f); //put above 1 to fade faster towards the surface - TO DO: Regulate based on player distance to surface as well
|
||||
public FloatParameter BumpIntensity = new FloatParameter(0.02f);
|
||||
public Vector4Parameter BumpVelocity = new Vector4Parameter(new Vector4(0.15f, 0.10f, 0.2f, 0.3f));
|
||||
public FloatParameter BumpScale = new FloatParameter(0.1f);
|
||||
//v4.6
|
||||
public ColorParameter underWaterTint = new ColorParameter(Color.cyan);
|
||||
public FloatParameter BumpIntensityRL = new FloatParameter(0.17f);
|
||||
public FloatParameter BumpScaleRL = new FloatParameter(0.4f);
|
||||
public FloatParameter BumpLineHeight = new FloatParameter(0.1f);
|
||||
public FloatParameter refractLineWidth = new FloatParameter(1); //v4.6
|
||||
public FloatParameter refractLineXDisp = new FloatParameter(1); //v4.6
|
||||
public FloatParameter refractLineXDispA = new FloatParameter(1); //v4.6
|
||||
public Vector4Parameter refractLineFade = new Vector4Parameter(new Vector4(1, 1, 1, 1));
|
||||
/////END REFRACT LINE
|
||||
|
||||
Material sheetSHAFTS;
|
||||
public bool IsActive() => sheetSHAFTS != null && intensity.value > 0f;
|
||||
public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.BeforePostProcess;// AfterPostProcess;
|
||||
|
||||
public override void Setup()
|
||||
{
|
||||
if (Shader.Find("Hidden/Shader/SunShaftsSM_HDRP") != null)
|
||||
{
|
||||
sheetSHAFTS = new Material(Shader.Find("Hidden/Shader/SunShaftsSM_HDRP"));
|
||||
}
|
||||
|
||||
var hdrpAsset = (GraphicsSettings.defaultRenderPipeline as HDRenderPipelineAsset);
|
||||
var colorBufferFormat = hdrpAsset.currentPlatformRenderPipelineSettings.colorBufferFormat;
|
||||
|
||||
if (lrDepthBuffer == null)
|
||||
{
|
||||
lrDepthBuffer = RTHandles.Alloc(
|
||||
Vector2.one, TextureXR.slices, dimension: TextureXR.dimension,
|
||||
colorFormat: (UnityEngine.Experimental.Rendering.GraphicsFormat)colorBufferFormat, // We don't need alpha in the blur
|
||||
useDynamicScale: true, name: "lrDepthBuffer"
|
||||
);
|
||||
}
|
||||
if (m_TemporaryColorTexture == null)
|
||||
{
|
||||
m_TemporaryColorTexture = RTHandles.Alloc(
|
||||
Vector2.one, TextureXR.slices, dimension: TextureXR.dimension,
|
||||
colorFormat: (UnityEngine.Experimental.Rendering.GraphicsFormat)colorBufferFormat, // We don't need alpha in the blur
|
||||
useDynamicScale: true, name: "m_TemporaryColorTexture"
|
||||
);
|
||||
}
|
||||
|
||||
if (m_TemporaryColorTextureScaled == null || resetScaling.value)
|
||||
{
|
||||
if (m_TemporaryColorTextureScaled != null)
|
||||
{
|
||||
m_TemporaryColorTextureScaled.Release();
|
||||
}
|
||||
m_TemporaryColorTextureScaled = RTHandles.Alloc(
|
||||
Vector2.one * scalerMask.value, TextureXR.slices, dimension: TextureXR.dimension, filterMode: FilterMode.Trilinear,
|
||||
colorFormat: (UnityEngine.Experimental.Rendering.GraphicsFormat)colorBufferFormat, // We don't need alpha in the blur
|
||||
useDynamicScale: true, name: "m_TemporaryColorTextureScaled"
|
||||
);
|
||||
//Debug.Log("Mask Texture reset " + " Scaler = " + scalerMask.value + " Width=" + m_TemporaryColorTextureScaled.rt.width);
|
||||
resetScaling.value = false;
|
||||
}
|
||||
|
||||
if (lrColorB == null)
|
||||
{
|
||||
lrColorB = RTHandles.Alloc(
|
||||
Vector2.one, TextureXR.slices, dimension: TextureXR.dimension,
|
||||
colorFormat: (UnityEngine.Experimental.Rendering.GraphicsFormat)colorBufferFormat, // We don't need alpha in the blur
|
||||
useDynamicScale: true, name: "lrColorB"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//SHAFTS
|
||||
//UnityEngine.Rendering.HighDefinition.rendert lrDepthBuffer;
|
||||
//UnityEngine.Rendering.Universal.RenderTargetHandle lrDepthBuffer;
|
||||
//RenderTexture lrDepthBuffer;
|
||||
// RenderTargetIdentifier lrDepthBuffer;
|
||||
// RenderTexture lrColorB;
|
||||
//rendertarg lrDepthBuffer;
|
||||
|
||||
RTHandle lrDepthBuffer;
|
||||
RTHandle m_TemporaryColorTexture;
|
||||
public RTHandle m_TemporaryColorTextureScaled;
|
||||
RTHandle lrColorB;
|
||||
|
||||
|
||||
//ACCESS MASK
|
||||
//WaterAirMaskSM waterAirMask;
|
||||
public FloatParameter scalerMask = new FloatParameter(0.2f);
|
||||
|
||||
public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
|
||||
{
|
||||
if (sheetSHAFTS == null)
|
||||
return;
|
||||
sheetSHAFTS.SetFloat("_Intensity", intensity.value);
|
||||
sheetSHAFTS.SetTexture("_InputTexture", source);
|
||||
|
||||
//ACCESS MASK
|
||||
if (useWaterAirMask.value)
|
||||
{
|
||||
if (Camera.main != null)
|
||||
{
|
||||
float camXRot = Camera.main.transform.eulerAngles.x;
|
||||
if (camXRot > 180)
|
||||
{
|
||||
camXRot = -(360 - camXRot);
|
||||
}
|
||||
sheetSHAFTS.SetFloat("_CamXRot", camXRot);
|
||||
}
|
||||
var downsampleProperties = new MaterialPropertyBlock();
|
||||
downsampleProperties.SetTexture("_InputTexture", source);
|
||||
downsampleProperties.SetFloat("waterHeight", waterHeight.value);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, m_TemporaryColorTextureScaled, downsampleProperties, 7);
|
||||
|
||||
//Debug.Log(m_TemporaryColorTextureScaled.rt.width);
|
||||
|
||||
// var UPsampleProperties = new MaterialPropertyBlock();
|
||||
//UPsampleProperties.SetTexture("_InputTexture", m_TemporaryColorTextureScaled);
|
||||
//UPsampleProperties.SetFloat("scalerMask", scalerMask.value); //SCALE RESULT
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, UPsampleProperties, 6);
|
||||
//return;
|
||||
}
|
||||
else if (useVolumeMaskRenderer.value)
|
||||
{
|
||||
//Debug.Log("111a");
|
||||
//volumeRendererMASK.targetTexture = m_TemporaryColorTextureScaled;
|
||||
//volumeRendererMASK.bakingCamera = Camera.main;
|
||||
//var downsampleProperties = new MaterialPropertyBlock();
|
||||
//downsampleProperties.SetTexture("_InputTexture", MaskMap.value);
|
||||
////downsampleProperties.SetFloat("waterHeight", waterHeight.value);
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, m_TemporaryColorTextureScaled, downsampleProperties, 11);
|
||||
|
||||
var downsampleProperties = new MaterialPropertyBlock();
|
||||
downsampleProperties.SetTexture("_InputTextureA", MaskMap.value);
|
||||
//downsampleProperties.SetFloat("waterHeight", waterHeight.value);
|
||||
//v1.2a
|
||||
downsampleProperties.SetFloat("_Height", Camera.main.transform.position.y);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, m_TemporaryColorTextureScaled, downsampleProperties, 11);
|
||||
|
||||
//var downsamplePropertiesA1 = new MaterialPropertyBlock();
|
||||
//downsamplePropertiesA1.SetTexture("_InputTextureA", MaskMap.value);
|
||||
//downsamplePropertiesA1.SetFloat("scalerMask", scalerMask.value);
|
||||
////downsampleProperties.SetFloat("waterHeight", waterHeight.value);
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, downsamplePropertiesA1, 11);
|
||||
}
|
||||
else
|
||||
{
|
||||
var downsampleProperties = new MaterialPropertyBlock();
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, m_TemporaryColorTextureScaled, downsampleProperties, 10);
|
||||
|
||||
//Debug.Log(m_TemporaryColorTextureScaled.rt.width);
|
||||
}
|
||||
|
||||
// Debug.Log("useVolumeMaskRenderer=" + useVolumeMaskRenderer.value);
|
||||
|
||||
//Volume volume = this.m_TemporaryColorTexture;// GetComponent<Volume>();
|
||||
//DepthOfField tempDof;
|
||||
|
||||
//if (volume.profile.TryGet<DepthOfField>(out tempDof))
|
||||
//{
|
||||
// depthOfField = tempDof;
|
||||
//}
|
||||
|
||||
//depthOfField.focusDistance.value = 42f;
|
||||
//if (this.m_TemporaryColorTexture != null)
|
||||
//{
|
||||
// Debug.Log(this.m_TemporaryColorTexture.rt.width);
|
||||
//}
|
||||
|
||||
//sheetSHAFTS.SetTexture("_MainTexA", source);
|
||||
|
||||
//SHAFTS
|
||||
//opaqueDesc.depthBufferBits = 0;
|
||||
|
||||
// Material sheetSHAFTS = blitMaterial;
|
||||
//sheetSHAFTS.SetFloat("_Blend", blend);
|
||||
|
||||
Camera cameraA = Camera.main;
|
||||
// we actually need to check this every frame
|
||||
if (useDepthTexture.value)
|
||||
{
|
||||
cameraA.depthTextureMode |= DepthTextureMode.Depth;
|
||||
}
|
||||
|
||||
Vector3 v = Vector3.one * 0.5f;
|
||||
if (sunTransform != Vector3.zero)
|
||||
{
|
||||
v = Camera.main.WorldToViewportPoint(sunTransform.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
v = new Vector3(0.5f, 0.5f, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
/////// UNDERWATER ONLY, always face camera
|
||||
if (shaftsFollowCamera.value == true)
|
||||
{
|
||||
v = Camera.main.WorldToViewportPoint(Camera.main.transform.position
|
||||
+ (new Vector3(Camera.main.transform.forward.x, 0, Camera.main.transform.forward.z) * 1000 + Vector3.up * 500));
|
||||
}
|
||||
|
||||
//v0.1
|
||||
int rtW = source.referenceSize.x; // opaqueDesc.width;
|
||||
int rtH = source.referenceSize.y; // opaqueDesc.height;
|
||||
// Debug.Log(rtW + ", " + rtH);
|
||||
|
||||
//cmd.GetTemporaryRT(lrDepthBuffer.id, opaqueDesc, filterMode);
|
||||
//int lrDepthBufferID = Shader.PropertyToID("lrDepthBuffer");
|
||||
//cmd.GetTemporaryRT(lrDepthBufferID, rtW, rtH, 0, FilterMode.Bilinear);
|
||||
|
||||
var format = cameraA.allowHDR ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default; //v3.4.9
|
||||
//RenderTextureFormat format = RenderTextureFormat.ARGB32;
|
||||
//RenderTexture lrDepthBuffer = RenderTexture.GetTemporary(rtW, rtH, 0, format);
|
||||
//RenderTexture lrColorB = RenderTexture.GetTemporary(rtW, rtH, 0, format);
|
||||
//RenderTexture m_TemporaryColorTexture = RenderTexture.GetTemporary(rtW, rtH, 0, format);
|
||||
//int lrDepthBufferID = Shader.PropertyToID("lrDepthBuffer");
|
||||
//cmd.GetTemporaryRT(lrDepthBufferID, rtW, rtH, 0, FilterMode.Bilinear);
|
||||
//RenderTargetIdentifier lrDepthBuffer;
|
||||
//RTHandle lrDepthBufferIDA = RenderTexture.GetTemporary(rtW, rtH, 0, format).GetInstanceID;
|
||||
//lrDepthBufferIDA.rt = lrDepthBuffer;
|
||||
|
||||
|
||||
|
||||
// mask out everything except the skybox
|
||||
sheetSHAFTS.SetVector("_BlurRadius4", new Vector4(1.0f, 1.0f, 0.0f, 0.0f) * sunShaftBlurRadius.value);
|
||||
sheetSHAFTS.SetVector("_SunThreshold", sunThreshold.value);
|
||||
|
||||
if (!useDepthTexture.value)
|
||||
{
|
||||
RenderTexture tmpBuffer = RenderTexture.GetTemporary(rtW, rtH, 0, format);
|
||||
RenderTexture.active = tmpBuffer;
|
||||
GL.ClearWithSkybox(false, cameraA);
|
||||
|
||||
var UPsampleProperties01 = new MaterialPropertyBlock();
|
||||
|
||||
|
||||
UPsampleProperties01.SetTexture("_Skybox", tmpBuffer);
|
||||
//UnityEngine.Rendering.HighDefinition.
|
||||
//cmd.Blit(source, lrDepthBufferID, sheetSHAFTS, 3);
|
||||
UPsampleProperties01.SetTexture("_MainTexA", source);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, lrDepthBuffer, UPsampleProperties01, 3);
|
||||
//Blit(cmd, source, lrDepthBufferID, sheetSHAFTS, 3);//Blit(cmd, source, lrDepthBuffer.Identifier(), sheetSHAFTS, 3);
|
||||
RenderTexture.ReleaseTemporary(tmpBuffer);
|
||||
// Debug.Log("pass 3");
|
||||
}
|
||||
else
|
||||
{
|
||||
var UPsampleProperties02 = new MaterialPropertyBlock();
|
||||
UPsampleProperties02.SetTexture("_MainTexA", source);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, lrDepthBuffer, UPsampleProperties02, 2);
|
||||
//cmd.Blit(source, lrDepthBufferID, sheetSHAFTS, 2);
|
||||
//Blit(cmd, source, lrDepthBuffer.Identifier(), sheetSHAFTS, 2);
|
||||
//Debug.Log("pass 2");
|
||||
}
|
||||
|
||||
// radial blur:
|
||||
|
||||
//int m_TemporaryColorTextureID = Shader.PropertyToID("m_TemporaryColorTexture");
|
||||
//cmd.Blit(source, m_TemporaryColorTextureID);
|
||||
// Blit(cmd, source, m_TemporaryColorTexture.Identifier()); //KEEP BACKGROUND
|
||||
var UPsampleProperties03 = new MaterialPropertyBlock();
|
||||
UPsampleProperties03.SetTexture("_MainTexA", source);
|
||||
UPsampleProperties03.SetFloat("scalerMask", 1);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, m_TemporaryColorTexture, UPsampleProperties03, 6);
|
||||
|
||||
radialBlurIterations.value = Mathf.Clamp(radialBlurIterations.value, 1, 4);
|
||||
|
||||
float ofs = sunShaftBlurRadius.value * (1.0f / 768.0f);
|
||||
|
||||
sheetSHAFTS.SetVector("_BlurRadius4", new Vector4(ofs, ofs, 0.0f, 0.0f));
|
||||
|
||||
float adjustX = 0.5f;
|
||||
if (v.x < 0.5f)
|
||||
{
|
||||
float diff = 0.5f - v.x;
|
||||
adjustX = adjustX - 0.5f * diff;
|
||||
}
|
||||
float adjustY = 0.5f;
|
||||
if (v.y > 1.25f)
|
||||
{
|
||||
float diff2 = v.y - 1.25f;
|
||||
adjustY = adjustY - 0.3f * diff2;
|
||||
}
|
||||
if (v.y > 1.8f)
|
||||
{
|
||||
v.y = 1.8f;
|
||||
float diff3 = v.y - 1.25f;
|
||||
adjustY = 0.5f - 0.3f * diff3;
|
||||
}
|
||||
|
||||
sheetSHAFTS.SetVector("_SunPosition", new Vector4(v.x * 0.5f + adjustX, v.y * 0.5f + adjustY, v.z, maxRadius.value));
|
||||
|
||||
for (int it2 = 0; it2 < radialBlurIterations.value; it2++)
|
||||
{
|
||||
// each iteration takes 2 * 6 samples
|
||||
// we update _BlurRadius each time to cheaply get a very smooth look
|
||||
//lrColorB = RenderTexture.GetTemporary(rtW, rtH, 0);
|
||||
//cmd.Blit(lrDepthBufferID, lrColorB, sheetSHAFTS, 1);
|
||||
|
||||
var UPsampleProperties04 = new MaterialPropertyBlock();
|
||||
UPsampleProperties04.SetTexture("_MainTexA", lrDepthBuffer);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, lrColorB, UPsampleProperties04, 1);
|
||||
|
||||
//Blit(cmd, lrDepthBuffer.Identifier(), lrColorB, sheetSHAFTS, 1);
|
||||
//cmd.ReleaseTemporaryRT(lrDepthBuffer); //cmd.ReleaseTemporaryRT(lrDepthBuffer.id);
|
||||
ofs = sunShaftBlurRadius.value * (((it2 * 2.0f + 1.0f) * 6.0f)) / 768.0f;
|
||||
sheetSHAFTS.SetVector("_BlurRadius4", new Vector4(ofs, ofs, 0.0f, 0.0f));
|
||||
|
||||
//cmd.GetTemporaryRT(lrDepthBuffer.id, opaqueDesc, filterMode);
|
||||
//Blit(cmd, lrColorB, lrDepthBuffer.Identifier(), sheetSHAFTS, 1);
|
||||
|
||||
//cmd.GetTemporaryRT(lrDepthBufferID, rtW, rtH, 0, FilterMode.Bilinear);
|
||||
// cmd.Blit(lrColorB, lrDepthBufferID, sheetSHAFTS, 1);
|
||||
|
||||
UPsampleProperties04.SetTexture("_MainTexA", lrColorB);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, lrDepthBuffer, UPsampleProperties04, 1);
|
||||
|
||||
//RenderTexture.ReleaseTemporary(lrColorB);
|
||||
ofs = sunShaftBlurRadius.value * (((it2 * 2.0f + 2.0f) * 6.0f)) / 768.0f;
|
||||
sheetSHAFTS.SetVector("_BlurRadius4", new Vector4(ofs, ofs, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
// put together:
|
||||
if (v.z >= 0.0f)
|
||||
{
|
||||
sheetSHAFTS.SetVector("_SunColor", new Vector4(sunColor.value.r, sunColor.value.g, sunColor.value.b, sunColor.value.a) * sunShaftIntensity.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
sheetSHAFTS.SetVector("_SunColor", Vector4.zero); // no backprojection !
|
||||
}
|
||||
|
||||
//cmd.SetGlobalTexture("_ColorBuffer", lrDepthBuffer.Identifier());
|
||||
cmd.SetGlobalTexture("_ColorBuffer", lrDepthBuffer);
|
||||
|
||||
// Blit(cmd, m_TemporaryColorTexture.Identifier(), source, sheetSHAFTS, (screenBlendMode == BlitSunShaftsSRP.BlitSettings.ShaftsScreenBlendMode.Screen) ? 0 : 4);
|
||||
//cmd.Blit(m_TemporaryColorTextureID, source, sheetSHAFTS, (screenBlendMode == ShaftsScreenBlendMode.Screen) ? 0 : 4);
|
||||
|
||||
//sheetSHAFTS.SetTexture("_MainTexA", m_TemporaryColorTexture);
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, null, (screenBlendMode == ShaftsScreenBlendMode.Screen) ? 0 : 4);
|
||||
// return;
|
||||
|
||||
//MASK RESULT
|
||||
var UPsampleProperties05 = new MaterialPropertyBlock();
|
||||
UPsampleProperties05.SetTexture("_MainTexA", m_TemporaryColorTexture);
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, lrColorB, UPsampleProperties05, (screenBlendMode == ShaftsScreenBlendMode.Screen) ? 0 : 4);
|
||||
|
||||
//var UPsampleProperties1 = new MaterialPropertyBlock();
|
||||
//UPsampleProperties1.SetTexture("_InputTexture", lrColorB);
|
||||
//UPsampleProperties1.SetFloat("scalerMask", 1.0f);
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, UPsampleProperties1, 6);
|
||||
//return;
|
||||
|
||||
var UPsampleProperties1 = new MaterialPropertyBlock();
|
||||
//UPsampleProperties.SetTexture("_InputTexture", m_TemporaryColorTextureScaled);
|
||||
//if (useWaterAirMask.value) //v1.2
|
||||
//{
|
||||
UPsampleProperties1.SetTexture("_WaterInterfaceTex", m_TemporaryColorTextureScaled);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// UPsampleProperties1.SetTexture("_WaterInterfaceTex", lrColorB.rt);
|
||||
//}
|
||||
UPsampleProperties1.SetTexture("_MainTexA", lrColorB.rt);
|
||||
UPsampleProperties1.SetTexture("_SourceTex", source);
|
||||
UPsampleProperties1.SetFloat("scalerMask", scalerMask.value);
|
||||
|
||||
////////////////// REFRACT LINE
|
||||
if (BumpMap.value != null)
|
||||
{
|
||||
UPsampleProperties1.SetTexture("_BumpTex", BumpMap.value);
|
||||
//Debug.Log(BumpMap.value.width);
|
||||
}
|
||||
UPsampleProperties1.SetFloat("_BumpMagnitude", BumpIntensity.value);
|
||||
UPsampleProperties1.SetFloat("_BumpScale", BumpScale.value);
|
||||
//v4.6
|
||||
UPsampleProperties1.SetFloat("_BumpMagnitudeRL", BumpIntensityRL.value);
|
||||
UPsampleProperties1.SetFloat("_BumpScaleRL", BumpScaleRL.value);
|
||||
UPsampleProperties1.SetFloat("_BumpLineHeight", BumpLineHeight.value);
|
||||
UPsampleProperties1.SetVector("_BumpVelocity", BumpVelocity.value);
|
||||
UPsampleProperties1.SetVector("_underWaterTint", underWaterTint.value);
|
||||
UPsampleProperties1.SetFloat("_underwaterDepthFade", underwaterDepthFade.value);
|
||||
UPsampleProperties1.SetFloat("_refractLineWidth", refractLineWidth.value); //v4.6
|
||||
UPsampleProperties1.SetFloat("_refractLineXDisp", refractLineXDisp.value); //v4.6
|
||||
UPsampleProperties1.SetFloat("_refractLineXDispA", refractLineXDispA.value); //v4.6
|
||||
UPsampleProperties1.SetVector("_refractLineFade", refractLineFade.value); //v4.6
|
||||
////////////////// END REFRACT LINE
|
||||
///
|
||||
|
||||
//v1.2
|
||||
//var downsamplePropertiesA1 = new MaterialPropertyBlock();
|
||||
//downsamplePropertiesA1.SetTexture("_InputTextureA", MaskMap.value);
|
||||
//downsamplePropertiesA1.SetFloat("scalerMask", scalerMask.value);
|
||||
////downsampleProperties.SetFloat("waterHeight", waterHeight.value);
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, downsamplePropertiesA1, 11);
|
||||
|
||||
|
||||
|
||||
HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, UPsampleProperties1, 8);
|
||||
//Graphics.Blit(currentDestination, destination, sunShaftsMaterial, 8);
|
||||
//sheetSHAFTS.SetTexture("_MainTexA", lrColorB);
|
||||
//sheetSHAFTS.SetTexture("_MainTexA", m_TemporaryColorTexture);
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, null, (screenBlendMode == ShaftsScreenBlendMode.Screen) ? 0 : 4);
|
||||
|
||||
// cmd.ReleaseTemporaryRT(lrDepthBuffer.id);
|
||||
// cmd.ReleaseTemporaryRT(m_TemporaryColorTexture.id);
|
||||
// cmd.ReleaseTemporaryRT(lrDepthBufferID);
|
||||
// cmd.ReleaseTemporaryRT(m_TemporaryColorTextureID);
|
||||
|
||||
//execute
|
||||
//sheetSHAFTS.SetTexture("_MainTexA", source);
|
||||
//HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, null, 6);
|
||||
//context.ExecuteCommandBuffer(cmd);
|
||||
// CommandBufferPool.Release(cmd);
|
||||
//RenderTexture.ReleaseTemporary(lrColorB);
|
||||
//RenderTexture.ReleaseTemporary(lrDepthBuffer);
|
||||
//RenderTexture.ReleaseTemporary(m_TemporaryColorTexture);
|
||||
|
||||
|
||||
// HDUtils.DrawFullScreen(cmd, sheetSHAFTS, destination, null, 0);
|
||||
}
|
||||
//public override void Cleanup() => CoreUtils.Destroy(sheetSHAFTS);
|
||||
|
||||
|
||||
public override void Cleanup()//protected override void Cleanup()
|
||||
{
|
||||
CoreUtils.Destroy(sheetSHAFTS);
|
||||
m_TemporaryColorTexture.Release();
|
||||
lrDepthBuffer.Release();
|
||||
lrColorB.Release();
|
||||
m_TemporaryColorTextureScaled.Release();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 986ee0364ac89b847a50bbb86a897bf3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02c05c48573d1b2428ef8b6135295000
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user