add weather and time
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
Shader "Hidden/EnviroApplyShadows"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
//_CloudsTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
#if defined(ENVIROURP)
|
||||
o.vertex = float4(v.vertex.xyz,1.0);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.vertex.y *= -1;
|
||||
#endif
|
||||
#else
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#endif
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
float _Intensity;
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_CloudsTex);
|
||||
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 sceneColor = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex,i.uv);
|
||||
float4 cloudTex = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CloudsTex,i.uv);
|
||||
float shadowsClouds = saturate(1-(cloudTex.b * _Intensity));
|
||||
// shadowsClouds = shadowsClouds * ;
|
||||
|
||||
float4 final = float4(sceneColor.rgb * shadowsClouds, sceneColor.a);
|
||||
return final;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aac3497da77f54d45be34e36e73cd078
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroApplyShadows.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,108 @@
|
||||
Shader "Hidden/EnviroApplyShadowsHDRP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
//_CloudsTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile __ ENVIROHDRP
|
||||
|
||||
#if defined (ENVIROHDRP)
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = GetFullScreenTriangleVertexPosition(v.vertexID);
|
||||
o.uv = GetFullScreenTriangleTexCoord(v.vertexID);
|
||||
return o;
|
||||
}
|
||||
|
||||
float _Intensity;
|
||||
float4 _HandleScales;
|
||||
TEXTURE2D_X(_MainTex);
|
||||
TEXTURE2D_X(_CloudsTex);
|
||||
SAMPLER(sampler_CloudsTex);
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 sceneColor = SAMPLE_TEXTURE2D_X_LOD(_MainTex,s_trilinear_clamp_sampler, i.uv, 0);
|
||||
float4 cloudTex = SAMPLE_TEXTURE2D_X(_CloudsTex,sampler_CloudsTex, i.uv * _HandleScales.xy);
|
||||
|
||||
float shadowsClouds = saturate(1-(cloudTex.b * _Intensity));
|
||||
float4 final = float4(sceneColor.rgb * shadowsClouds, sceneColor.a);
|
||||
|
||||
return final;
|
||||
}
|
||||
#else
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd43fb7dba71169479da866d0aae5fa1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroApplyShadowsHDRP.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,110 @@
|
||||
Shader "Hidden/EnviroApplyShadowsURP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
//_CloudsTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
|
||||
#if defined (ENVIROURP)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertex : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(v.vertex);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(v.vertex);
|
||||
|
||||
o.vertex = pos;
|
||||
o.uv = DYNAMIC_SCALING_APPLY_SCALEBIAS(uv);
|
||||
return o;
|
||||
}
|
||||
|
||||
float _Intensity;
|
||||
TEXTURE2D_X(_MainTex);
|
||||
SAMPLER (sampler_MainTex);
|
||||
TEXTURE2D_X(_CloudsTex);
|
||||
SAMPLER (sampler_CloudsTex);
|
||||
|
||||
// UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
// UNITY_DECLARE_SCREENSPACE_TEXTURE(_CloudsTex);
|
||||
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 sceneColor = SAMPLE_TEXTURE2D_X(_MainTex,sampler_MainTex,i.uv);
|
||||
float4 cloudTex = SAMPLE_TEXTURE2D_X(_CloudsTex,sampler_CloudsTex,i.uv);
|
||||
float shadowsClouds = saturate(1-(cloudTex.b * _Intensity));
|
||||
// shadowsClouds = shadowsClouds * ;
|
||||
|
||||
float4 final = float4(sceneColor.rgb * shadowsClouds, sceneColor.a);
|
||||
return final;
|
||||
}
|
||||
#else
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd723b2af3633bb409d9ba4fa82ef5c7
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,200 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsBlend"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include_with_pragmas "../Includes/FogInclude.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
|
||||
#ifdef STEREO_INSTANCING_ON
|
||||
UNITY_DECLARE_TEX2DARRAY (_CloudTex);
|
||||
#else
|
||||
UNITY_DECLARE_TEX2D (_CloudTex);
|
||||
#endif
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_DownsampledDepth);
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
|
||||
float4 _CloudTex_TexelSize;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
SamplerState Point_Clamp_Sampler;
|
||||
|
||||
float4 _ProjectionExtents;
|
||||
float4 _ProjectionExtentsRight;
|
||||
|
||||
float4x4 _CamToWorld;
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 screenPos : TEXCOORD1;
|
||||
float2 vsray : TEXCOORD2;
|
||||
half3 pos : TEXCOORD3;
|
||||
//#ifdef ENVIRO_DEPTH_BLENDING
|
||||
float2 uv00 : TEXCOORD4;
|
||||
float2 uv10 : TEXCOORD5;
|
||||
float2 uv01 : TEXCOORD6;
|
||||
float2 uv11 : TEXCOORD7;
|
||||
//#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.pos = -v.vertex;
|
||||
|
||||
#if defined(ENVIROURP)
|
||||
o.vertex = float4(v.vertex.xyz,1.0);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.vertex.y *= -1;
|
||||
#endif
|
||||
#else
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#endif
|
||||
|
||||
o.uv = v.texcoord;
|
||||
|
||||
if(unity_StereoEyeIndex == 0)
|
||||
o.vsray = (2.0 * v.texcoord - 1.0) * _ProjectionExtents.xy + _ProjectionExtents.zw;
|
||||
else
|
||||
o.vsray = (2.0 * v.texcoord - 1.0) * _ProjectionExtentsRight.xy + _ProjectionExtentsRight.zw;
|
||||
|
||||
o.screenPos = ComputeScreenPos(o.vertex);
|
||||
|
||||
//#ifdef ENVIRO_DEPTH_BLENDING
|
||||
o.uv00 = v.texcoord - 0.5 * _CloudTex_TexelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(_CloudTex_TexelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _CloudTex_TexelSize.y);
|
||||
o.uv11 = o.uv00 + _CloudTex_TexelSize.xy;
|
||||
//#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
//#ifdef ENVIRO_DEPTH_BLENDING
|
||||
float4 Upsample(v2f i)
|
||||
{
|
||||
float4 lowResDepth = 0.0f;
|
||||
float highResDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture,UnityStereoTransformScreenSpaceTex(i.uv)));
|
||||
|
||||
lowResDepth.x = LinearEyeDepth(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DownsampledDepth,UnityStereoTransformScreenSpaceTex(i.uv00)).r);
|
||||
lowResDepth.y = LinearEyeDepth(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DownsampledDepth,UnityStereoTransformScreenSpaceTex(i.uv10)).r);
|
||||
lowResDepth.z = LinearEyeDepth(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DownsampledDepth,UnityStereoTransformScreenSpaceTex(i.uv01)).r);
|
||||
lowResDepth.w = LinearEyeDepth(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DownsampledDepth,UnityStereoTransformScreenSpaceTex(i.uv11)).r);
|
||||
|
||||
float4 depthDiff = abs(lowResDepth - highResDepth);
|
||||
float accumDiff = dot(depthDiff, float4(1, 1, 1, 1));
|
||||
|
||||
[branch]
|
||||
if (accumDiff < 1.5f)
|
||||
{
|
||||
#ifdef STEREO_INSTANCING_ON
|
||||
float3 uv = float3(UnityStereoTransformScreenSpaceTex(i.uv),unity_StereoEyeIndex);
|
||||
return _CloudTex.Sample(sampler_CloudTex, uv);
|
||||
#else
|
||||
return _CloudTex.Sample(sampler_CloudTex, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
float minDepthDiff = depthDiff[0];
|
||||
float2 nearestUv = i.uv00;
|
||||
|
||||
if (depthDiff[1] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv10;
|
||||
minDepthDiff = depthDiff[1];
|
||||
}
|
||||
|
||||
if (depthDiff[2] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv01;
|
||||
minDepthDiff = depthDiff[2];
|
||||
}
|
||||
|
||||
if (depthDiff[3] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv11;
|
||||
minDepthDiff = depthDiff[3];
|
||||
}
|
||||
|
||||
#ifdef STEREO_INSTANCING_ON
|
||||
float3 uv = float3(UnityStereoTransformScreenSpaceTex(nearestUv),unity_StereoEyeIndex);
|
||||
return _CloudTex.Sample(Point_Clamp_Sampler, uv);
|
||||
#else
|
||||
return _CloudTex.Sample(Point_Clamp_Sampler, UnityStereoTransformScreenSpaceTex(nearestUv));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 vspos = float4(i.vsray, 1.0,1.0);
|
||||
float4 worldPos = mul(_CamToWorld,vspos);
|
||||
float3 viewDir = normalize(worldPos.xyz - _WorldSpaceCameraPos);
|
||||
|
||||
float4 sourceColor = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex,UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float4 cloudsColor = Upsample(i);
|
||||
|
||||
float4 finalColor = GetCloudColor(cloudsColor,worldPos);
|
||||
|
||||
#if defined(UNITY_COLORSPACE_GAMMA)
|
||||
finalColor.rgb = LinearToGammaSpace(finalColor.rgb);
|
||||
#endif
|
||||
|
||||
#if ENVIRO_DEPTH_BLENDING
|
||||
float4 final = float4(sourceColor.rgb * (1 - finalColor.a) + lerp(sourceColor.rgb, finalColor.rgb, finalColor.a) * finalColor.a, 1);
|
||||
return final;
|
||||
#else
|
||||
float4 final = sourceColor;
|
||||
|
||||
float sceneDepth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.uv)));
|
||||
|
||||
if (sceneDepth >= 0.99f)
|
||||
final = float4(sourceColor.rgb * saturate(1 - finalColor.a) + lerp(sourceColor.rgb, finalColor.rgb, finalColor.a) * finalColor.a, 1);
|
||||
|
||||
return final;
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff01f3ead5b250a4f8337a15b15442ac
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsBlend.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,226 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsBlendHDRP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque"}
|
||||
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile __ ENVIROHDRP
|
||||
|
||||
#if defined (ENVIROHDRP)
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
|
||||
#include_with_pragmas "../Includes/FogIncludeHLSL.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
TEXTURE2D_X(_DownsampledDepth);
|
||||
|
||||
TEXTURE2D_X (_CloudTex);
|
||||
SAMPLER(sampler_CloudTex);
|
||||
|
||||
SamplerState Point_Clamp_Sampler;
|
||||
|
||||
float4 _CloudTex_TexelSize;
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _HandleScales;
|
||||
float4 _DepthHandleScale;
|
||||
float4 _ProjectionExtents;
|
||||
float4 _ProjectionExtentsRight;
|
||||
float4x4 _CamToWorld;
|
||||
float3 color;
|
||||
float3 opacity;
|
||||
float _EnviroSkyIntensity;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 vsray : TEXCOORD1;
|
||||
#ifdef ENVIRO_DEPTH_BLENDING
|
||||
float2 uv00 : TEXCOORD2;
|
||||
float2 uv10 : TEXCOORD3;
|
||||
float2 uv01 : TEXCOORD4;
|
||||
float2 uv11 : TEXCOORD5;
|
||||
#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = GetFullScreenTriangleVertexPosition(v.vertexID);
|
||||
o.uv = GetFullScreenTriangleTexCoord(v.vertexID);
|
||||
|
||||
if(unity_StereoEyeIndex == 0)
|
||||
o.vsray = (2.0 * o.uv * (1/_RTHandleScale.xy) - 1.0) * _ProjectionExtents.xy + _ProjectionExtents.zw;
|
||||
else
|
||||
o.vsray = (2.0 * o.uv * (1/_RTHandleScale.xy) - 1.0) * _ProjectionExtentsRight.xy + _ProjectionExtentsRight.zw;
|
||||
|
||||
|
||||
#ifdef ENVIRO_DEPTH_BLENDING
|
||||
o.uv00 = o.uv - 0.5 * _CloudTex_TexelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(_CloudTex_TexelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _CloudTex_TexelSize.y);
|
||||
o.uv11 = o.uv00 + _CloudTex_TexelSize.xy;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
#ifdef ENVIRO_DEPTH_BLENDING
|
||||
float4 Upsample(v2f i)
|
||||
{
|
||||
float4 lowResDepth = 0.0f;
|
||||
float highResDepth = Linear01Depth(LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture, i.uv * _ScreenSize.xy * (1/_RTHandleScale.xy), 0), _ZBufferParams);
|
||||
|
||||
lowResDepth.x = Linear01Depth(LOAD_TEXTURE2D_X(_DownsampledDepth,i.uv00 * _DepthHandleScale.zw * _DepthHandleScale.xy).r, _ZBufferParams);
|
||||
lowResDepth.y = Linear01Depth(LOAD_TEXTURE2D_X(_DownsampledDepth,i.uv10 * _DepthHandleScale.zw * _DepthHandleScale.xy).r, _ZBufferParams);
|
||||
lowResDepth.z = Linear01Depth(LOAD_TEXTURE2D_X(_DownsampledDepth,i.uv01 * _DepthHandleScale.zw * _DepthHandleScale.xy).r, _ZBufferParams);
|
||||
lowResDepth.w = Linear01Depth(LOAD_TEXTURE2D_X(_DownsampledDepth,i.uv11 * _DepthHandleScale.zw * _DepthHandleScale.xy).r, _ZBufferParams);
|
||||
|
||||
float4 depthDiff = abs(lowResDepth - highResDepth);
|
||||
float accumDiff = dot(depthDiff, float4(1, 1, 1, 1));
|
||||
|
||||
[branch]
|
||||
if (accumDiff < 1.5f)
|
||||
{
|
||||
//float3 uv = float3(i.uv * _HandleScales.xy,unity_StereoEyeIndex);
|
||||
//return _CloudTex.Sample(sampler_CloudTex, uv);
|
||||
return SAMPLE_TEXTURE2D_X_LOD(_CloudTex,sampler_CloudTex, i.uv * _HandleScales.xy, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
float minDepthDiff = depthDiff[0];
|
||||
float2 nearestUv = i.uv00;
|
||||
|
||||
if (depthDiff[1] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv10;
|
||||
minDepthDiff = depthDiff[1];
|
||||
}
|
||||
|
||||
if (depthDiff[2] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv01;
|
||||
minDepthDiff = depthDiff[2];
|
||||
}
|
||||
|
||||
if (depthDiff[3] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv11;
|
||||
minDepthDiff = depthDiff[3];
|
||||
}
|
||||
|
||||
//float3 uv = float3(nearestUv * _HandleScales.xy,unity_StereoEyeIndex);
|
||||
//return _CloudTex.Sample(Point_Clamp_Sampler, uv );
|
||||
return SAMPLE_TEXTURE2D_X_LOD(_CloudTex,Point_Clamp_Sampler, nearestUv * _HandleScales.xy, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 vspos = float4(i.vsray, 1.0, 1.0);
|
||||
|
||||
float4 worldPos = mul(_CamToWorld,vspos);
|
||||
float3 viewDir = normalize(worldPos.xyz - _WorldSpaceCameraPos);
|
||||
float4 sourceColor = SAMPLE_TEXTURE2D_X_LOD(_MainTex,s_trilinear_clamp_sampler, i.uv, 0);
|
||||
float4 cloudsColor = float4(0,0,0,0);
|
||||
#ifdef ENVIRO_DEPTH_BLENDING
|
||||
cloudsColor = Upsample(i);
|
||||
#else
|
||||
cloudsColor = SAMPLE_TEXTURE2D_X_LOD(_CloudTex,sampler_CloudTex, i.uv * _HandleScales.xy, 0);
|
||||
#endif
|
||||
|
||||
|
||||
float4 finalColor = GetCloudColor(cloudsColor,worldPos);
|
||||
finalColor.rgb *= _EnviroSkyIntensity * GetCurrentExposureMultiplier();
|
||||
float rawDepth = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture, i.uv * _ScreenSize.xy * (1/_RTHandleScale.xy), 0);
|
||||
float sceneDepth = Linear01Depth(rawDepth, _ZBufferParams);
|
||||
|
||||
#if ENVIRO_DEPTH_BLENDING
|
||||
float4 final = float4(sourceColor.rgb * (1 - finalColor.a) + lerp(sourceColor.rgb, finalColor.rgb, finalColor.a) * finalColor.a, 1);
|
||||
#else
|
||||
float4 final = sourceColor;
|
||||
|
||||
if (sceneDepth == 1.0f)
|
||||
final = half4(sourceColor.rgb * saturate(1 - finalColor.a) + lerp(sourceColor.rgb, finalColor.rgb, finalColor.a) * finalColor.a, 1);
|
||||
#endif
|
||||
// HDRP Fog
|
||||
/*if (sceneDepth == 1.0f)
|
||||
{
|
||||
PositionInputs posInput = GetPositionInput(i.vertex.xy, _ScreenSize.zw, rawDepth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
||||
float3 V = GetSkyViewDirWS(i.uv * _ScreenSize.xy * (1/_RTHandleScale.xy));
|
||||
posInput.positionWS = GetCurrentViewPosition() - V * _MaxFogDistance;
|
||||
EvaluateAtmosphericScattering(posInput, V, color, opacity);
|
||||
final.rgb = color + (1 - opacity) * final.rgb;
|
||||
}*/
|
||||
return final;
|
||||
|
||||
}
|
||||
#else
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07d27ac305a52804f8e9a42bd1cb2dc1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.2.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsBlendHDRP.shader
|
||||
uploadId: 766468
|
||||
@@ -0,0 +1,246 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsBlendURP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
#pragma multi_compile __ UNITY_COLORSPACE_GAMMA
|
||||
|
||||
#if defined (ENVIROURP)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
#include_with_pragmas "../Includes/FogIncludeHLSL.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
SAMPLER (sampler_MainTex);
|
||||
|
||||
TEXTURE2D_X(_CloudTex);
|
||||
SAMPLER (sampler_CloudTex);
|
||||
|
||||
TEXTURE2D_X_FLOAT(_DownsampledDepth);
|
||||
SAMPLER (sampler_DownsampledDepth);
|
||||
|
||||
TEXTURE2D_X_FLOAT(_CameraDepthTexture);
|
||||
SAMPLER (sampler_CameraDepthTexture);
|
||||
|
||||
float4 _CloudTex_TexelSize;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
SamplerState Point_Clamp_Sampler;
|
||||
|
||||
float4 _ProjectionExtents;
|
||||
float4 _ProjectionExtentsRight;
|
||||
|
||||
float4x4 _CamToWorld;
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertex : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
//float4 screenPos : TEXCOORD1;
|
||||
float2 vsray : TEXCOORD1;
|
||||
//half3 pos : TEXCOORD2;
|
||||
//#ifdef ENVIRO_DEPTH_BLENDING
|
||||
float2 uv00 : TEXCOORD2;
|
||||
float2 uv10 : TEXCOORD3;
|
||||
float2 uv01 : TEXCOORD4;
|
||||
float2 uv11 : TEXCOORD5;
|
||||
//#endif
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
//o.pos = -v.vertex;
|
||||
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(v.vertex);
|
||||
float2 uv = DYNAMIC_SCALING_APPLY_SCALEBIAS(GetFullScreenTriangleTexCoord(v.vertex));
|
||||
|
||||
o.vertex = pos;
|
||||
o.uv = uv;
|
||||
|
||||
|
||||
if(unity_StereoEyeIndex == 0)
|
||||
o.vsray = (2.0 * o.uv - 1.0) * _ProjectionExtents.xy + _ProjectionExtents.zw;
|
||||
else
|
||||
o.vsray = (2.0 * o.uv - 1.0) * _ProjectionExtentsRight.xy + _ProjectionExtentsRight.zw;
|
||||
|
||||
// o.screenPos = ComputeScreenPos(o.vertex);
|
||||
|
||||
//#ifdef ENVIRO_DEPTH_BLENDING
|
||||
o.uv00 = o.uv - 0.5 * _CloudTex_TexelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(_CloudTex_TexelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _CloudTex_TexelSize.y);
|
||||
o.uv11 = o.uv00 + _CloudTex_TexelSize.xy;
|
||||
//#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
//#ifdef ENVIRO_DEPTH_BLENDING
|
||||
float4 Upsample(v2f i)
|
||||
{
|
||||
float4 lowResDepth = 0.0f;
|
||||
float highResDepth = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_CameraDepthTexture,sampler_CameraDepthTexture,i.uv).r, _ZBufferParams);
|
||||
|
||||
lowResDepth.x = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth,i.uv00).r, _ZBufferParams );
|
||||
lowResDepth.y = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth,i.uv10).r, _ZBufferParams);
|
||||
lowResDepth.z = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth,i.uv01).r, _ZBufferParams);
|
||||
lowResDepth.w = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth,i.uv11).r, _ZBufferParams);
|
||||
|
||||
float4 depthDiff = abs(lowResDepth - highResDepth);
|
||||
float accumDiff = dot(depthDiff, float4(1, 1, 1, 1));
|
||||
|
||||
[branch]
|
||||
if (accumDiff < 1.5f)
|
||||
{
|
||||
|
||||
return SAMPLE_TEXTURE2D_X(_CloudTex,sampler_CloudTex,i.uv);
|
||||
|
||||
#ifdef STEREO_INSTANCING_ON
|
||||
//float3 uv = float3(i.uv,unity_StereoEyeIndex);
|
||||
//return _CloudTex.Sample(sampler_CloudTex, uv);
|
||||
#else
|
||||
//return _CloudTex.Sample(sampler_CloudTex, i.uv);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
float minDepthDiff = depthDiff[0];
|
||||
float2 nearestUv = i.uv00;
|
||||
|
||||
if (depthDiff[1] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv10;
|
||||
minDepthDiff = depthDiff[1];
|
||||
}
|
||||
|
||||
if (depthDiff[2] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv01;
|
||||
minDepthDiff = depthDiff[2];
|
||||
}
|
||||
|
||||
if (depthDiff[3] < minDepthDiff)
|
||||
{
|
||||
nearestUv = i.uv11;
|
||||
minDepthDiff = depthDiff[3];
|
||||
}
|
||||
|
||||
return SAMPLE_TEXTURE2D_X(_CloudTex,Point_Clamp_Sampler,nearestUv);
|
||||
|
||||
#ifdef STEREO_INSTANCING_ON
|
||||
// float3 uv = float3(UnityStereoTransformScreenSpaceTex(nearestUv),unity_StereoEyeIndex);
|
||||
// return _CloudTex.Sample(Point_Clamp_Sampler, uv);
|
||||
#else
|
||||
// return _CloudTex.Sample(Point_Clamp_Sampler, UnityStereoTransformScreenSpaceTex(nearestUv));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
half3 LinearToGammaSpace (half3 linRGB)
|
||||
{
|
||||
linRGB = max(linRGB, half3(0.h, 0.h, 0.h));
|
||||
return max(1.055h * pow(linRGB, 0.416666667h) - 0.055h, 0.h);
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 vspos = float4(i.vsray, 1.0, 1.0);
|
||||
|
||||
float4 worldPos = mul(_CamToWorld,vspos);
|
||||
|
||||
float3 viewDir = normalize(worldPos.xyz - _WorldSpaceCameraPos);
|
||||
|
||||
float4 sourceColor = SAMPLE_TEXTURE2D_X(_MainTex,sampler_MainTex,i.uv);
|
||||
|
||||
float4 cloudsColor = Upsample(i);
|
||||
|
||||
float4 finalColor = GetCloudColor(cloudsColor,worldPos);
|
||||
|
||||
#if defined(UNITY_COLORSPACE_GAMMA)
|
||||
finalColor.rgb = LinearToGammaSpace(finalColor.rgb);
|
||||
#endif
|
||||
|
||||
#if ENVIRO_DEPTH_BLENDING
|
||||
float4 final = float4(sourceColor.rgb * (1 - finalColor.a) + lerp(sourceColor.rgb, finalColor.rgb, finalColor.a) * finalColor.a, 1);
|
||||
return final;
|
||||
#else
|
||||
float4 final = sourceColor;
|
||||
|
||||
float sceneDepth = Linear01Depth(SAMPLE_TEXTURE2D_X(_CameraDepthTexture,sampler_CameraDepthTexture, i.uv).r, _ZBufferParams);
|
||||
|
||||
if (sceneDepth >= 0.99f)
|
||||
final = float4(sourceColor.rgb * saturate(1 - finalColor.a) + lerp(sourceColor.rgb, finalColor.rgb, finalColor.a) * finalColor.a, 1);
|
||||
|
||||
return final;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab2d55893002046489fbd7b38e564fcb
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.2.0
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsBlendURP.shader
|
||||
uploadId: 721859
|
||||
@@ -0,0 +1,152 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsDepth"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
//Pass 1 downsample
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
float4 _CameraDepthTexture_TexelSize;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv00 : TEXCOORD1;
|
||||
float2 uv10 : TEXCOORD2;
|
||||
float2 uv01 : TEXCOORD3;
|
||||
float2 uv11 : TEXCOORD4;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
#if defined(ENVIROURP)
|
||||
o.vertex = float4(v.vertex.xyz,1.0);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.vertex.y *= -1;
|
||||
#endif
|
||||
#else
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#endif
|
||||
|
||||
o.uv = v.uv;
|
||||
|
||||
o.uv00 = v.uv - 0.5 * _CameraDepthTexture_TexelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(_CameraDepthTexture_TexelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _CameraDepthTexture_TexelSize.y);
|
||||
o.uv11 = o.uv00 + _CameraDepthTexture_TexelSize.xy;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 depth;
|
||||
|
||||
depth[0] = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture,UnityStereoTransformScreenSpaceTex(i.uv00));
|
||||
depth[1] = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture,UnityStereoTransformScreenSpaceTex(i.uv10));
|
||||
depth[2] = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture,UnityStereoTransformScreenSpaceTex(i.uv01));
|
||||
depth[3] = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture,UnityStereoTransformScreenSpaceTex(i.uv11));
|
||||
return min(depth[0], min(depth[1], min(depth[2], depth[3])));
|
||||
|
||||
//float minDepth = min(min(depth[0], depth[1]), min(depth[2], depth[3]));
|
||||
//float maxDepth = max(max(depth[0], depth[1]), max(depth[2], depth[3]));
|
||||
|
||||
// chessboard pattern
|
||||
//int2 position = i.vertex.xy % 2;
|
||||
//int index = position.x + position.y;
|
||||
//return index == 1 ? minDepth : maxDepth;
|
||||
//return minDepth;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
//Pass 2 Copy
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
#if defined(ENVIROURP)
|
||||
o.vertex = float4(v.vertex.xyz,1.0);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.vertex.y *= -1;
|
||||
#endif
|
||||
#else
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#endif
|
||||
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
float frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
return SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture,UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71e0f599e0918df47984cb778c0f336d
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsDepth.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,207 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsDepthHDRP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// _CameraDepthTexture ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
//Pass 1 downsample
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROHDRP
|
||||
|
||||
#if defined (ENVIROHDRP)
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
|
||||
|
||||
|
||||
float4 _CameraDepthTexture_TexelSize;
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv00 : TEXCOORD1;
|
||||
float2 uv10 : TEXCOORD2;
|
||||
float2 uv01 : TEXCOORD3;
|
||||
float2 uv11 : TEXCOORD4;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = GetFullScreenTriangleVertexPosition(v.vertexID);
|
||||
o.uv = GetFullScreenTriangleTexCoord(v.vertexID);
|
||||
|
||||
o.uv00 = o.uv - 0.5 * _CameraDepthTexture_TexelSize.xy; //v.uv
|
||||
o.uv10 = o.uv00 + float2(_CameraDepthTexture_TexelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _CameraDepthTexture_TexelSize.y);
|
||||
o.uv11 = o.uv00 + _CameraDepthTexture_TexelSize.xy;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
uint2 positionSS = i.uv * _ScreenSize.xy;
|
||||
|
||||
float4 depth;
|
||||
|
||||
depth[0] = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture,i.uv00 * _ScreenSize.xy,0);
|
||||
depth[1] = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture,i.uv10 * _ScreenSize.xy,0);
|
||||
depth[2] = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture,i.uv01 * _ScreenSize.xy,0);
|
||||
depth[3] = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture,i.uv11 * _ScreenSize.xy,0);
|
||||
return min(depth[0], min(depth[1], min(depth[2], depth[3])));
|
||||
}
|
||||
#else
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
//Pass 2 Copy
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROHDRP
|
||||
|
||||
#if defined (ENVIROHDRP)
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = GetFullScreenTriangleVertexPosition(v.vertexID);
|
||||
o.uv = GetFullScreenTriangleTexCoord(v.vertexID);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
return LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture, i.uv * _ScreenSize.xy,0);
|
||||
|
||||
}
|
||||
#else
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6c0cbdf098c32c4180a97e54fb4e65f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsDepthHDRP.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,206 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsDepthURP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
//Pass 1 downsample
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
|
||||
#if defined (ENVIROURP)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
|
||||
|
||||
TEXTURE2D_X_FLOAT(_CameraDepthTexture);
|
||||
SAMPLER (sampler_CameraDepthTexture);
|
||||
float4 _CameraDepthTexture_TexelSize;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertex : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv00 : TEXCOORD1;
|
||||
float2 uv10 : TEXCOORD2;
|
||||
float2 uv01 : TEXCOORD3;
|
||||
float2 uv11 : TEXCOORD4;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(v.vertex);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(v.vertex);
|
||||
|
||||
o.vertex = pos;
|
||||
o.uv = DYNAMIC_SCALING_APPLY_SCALEBIAS(uv);
|
||||
|
||||
o.uv00 = DYNAMIC_SCALING_APPLY_SCALEBIAS(uv) - 0.5 * _CameraDepthTexture_TexelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(_CameraDepthTexture_TexelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _CameraDepthTexture_TexelSize.y);
|
||||
o.uv11 = o.uv00 + _CameraDepthTexture_TexelSize.xy;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 depth;
|
||||
|
||||
depth[0] = SAMPLE_TEXTURE2D_X(_CameraDepthTexture,sampler_CameraDepthTexture,i.uv00).r;
|
||||
depth[1] = SAMPLE_TEXTURE2D_X(_CameraDepthTexture,sampler_CameraDepthTexture,i.uv10).r;
|
||||
depth[2] = SAMPLE_TEXTURE2D_X(_CameraDepthTexture,sampler_CameraDepthTexture,i.uv01).r;
|
||||
depth[3] = SAMPLE_TEXTURE2D_X(_CameraDepthTexture,sampler_CameraDepthTexture,i.uv11).r;
|
||||
return min(depth[0], min(depth[1], min(depth[2], depth[3])));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
//Pass 2 Copy
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile __ ENVIROURP
|
||||
|
||||
#if defined (ENVIROURP)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
|
||||
|
||||
TEXTURE2D_X_FLOAT(_CameraDepthTexture);
|
||||
SAMPLER (sampler_CameraDepthTexture);
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertex : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(v.vertex);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(v.vertex);
|
||||
|
||||
o.vertex = pos;
|
||||
o.uv = DYNAMIC_SCALING_APPLY_SCALEBIAS(uv);
|
||||
return o;
|
||||
}
|
||||
|
||||
float frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
return SAMPLE_TEXTURE2D_X(_CameraDepthTexture,sampler_CameraDepthTexture,i.uv).r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1da04d3fc0c7564499831a8c8ad259ae
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
Shader "Hidden/EnviroCloudsRaymarch"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_local _ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile_local _ ENVIRO_CLOUD_SHADOWS
|
||||
#pragma multi_compile_local _ ENVIRO_LIGHTNING
|
||||
#pragma multi_compile_local _ ENVIRO_VARIABLE_BOTTOM
|
||||
#pragma multi_compile _ ENVIROURP
|
||||
#include "UnityCG.cginc"
|
||||
#include_with_pragmas "../Includes/VolumetricCloudsInclude.cginc"
|
||||
#include_with_pragmas "../Includes/VolumetricCloudsTexInclude.cginc"
|
||||
|
||||
int _Frame;
|
||||
uniform float _BlueNoiseIntensity;
|
||||
float4 _CameraDepthTexture_TexelSize;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv00 : TEXCOORD1;
|
||||
float2 uv10 : TEXCOORD2;
|
||||
float2 uv01 : TEXCOORD3;
|
||||
float2 uv11 : TEXCOORD4;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
v2f vert (appdata_img v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
#if defined(ENVIROURP)
|
||||
o.position = float4(v.vertex.xyz,1.0);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.position.y *= -1;
|
||||
#endif
|
||||
#else
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
#endif
|
||||
|
||||
o.uv = v.texcoord;
|
||||
o.uv00 = v.texcoord - 0.5 * _CameraDepthTexture_TexelSize.xy;
|
||||
o.uv10 = o.uv00 + float2(_CameraDepthTexture_TexelSize.x, 0.0);
|
||||
o.uv01 = o.uv00 + float2(0.0, _CameraDepthTexture_TexelSize.y);
|
||||
o.uv11 = o.uv00 + _CameraDepthTexture_TexelSize.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 cameraRay = float4(i.uv * 2.0 - 1.0, 1.0, 1.0);
|
||||
float3 EyePosition = _CameraPosition;
|
||||
float3 ray = 0;
|
||||
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
cameraRay = mul(_InverseProjection, cameraRay);
|
||||
cameraRay = cameraRay / cameraRay.w;
|
||||
ray = normalize(mul((float3x3)_InverseRotation, cameraRay.xyz));
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraRay = mul(_InverseProjectionRight, cameraRay);
|
||||
cameraRay = cameraRay / cameraRay.w;
|
||||
ray = normalize(mul((float3x3)_InverseRotationRight, cameraRay.xyz));
|
||||
}
|
||||
|
||||
float rayLength = length(ray);
|
||||
|
||||
float sceneDepth = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DownsampledDepth, UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
float3 cameraDirection = -1 * transpose(_InverseRotation)[2].xyz;
|
||||
float fwdFactor = dot(ray, cameraDirection);
|
||||
|
||||
float raymarchEnd = GetRaymarchEndFromSceneDepth(Linear01Depth(sceneDepth) / fwdFactor, 1000000);
|
||||
|
||||
float offset = tex2D(_BlueNoise, squareUV(i.uv + _Randomness.xy)).x * _BlueNoiseIntensity;
|
||||
|
||||
float3 pCent = float3(EyePosition.x, -_CloudsParameter.w, EyePosition.z);
|
||||
|
||||
float intensity, distance, alpha, shadow = 0.0f;
|
||||
|
||||
RaymarchParameters parameters;
|
||||
InitRaymarchParameters(parameters);
|
||||
float2 hitDistance = ResolveRay(EyePosition,ray,pCent,raymarchEnd,parameters);
|
||||
float3 result = Raymarch(EyePosition,ray,hitDistance,pCent,parameters,offset);
|
||||
#if ENVIRO_CLOUD_SHADOWS
|
||||
float3 wpos = CalculateWorldPosition(i.uv,sceneDepth) - _WorldOffset;
|
||||
shadow = RaymarchShadows(EyePosition,wpos,ray,pCent,parameters,offset,sceneDepth);
|
||||
#endif
|
||||
intensity = result.r;
|
||||
distance = result.g;
|
||||
alpha = result.b;
|
||||
|
||||
return float4(max(intensity,0.0),max(distance,1.0f),clamp(shadow,0.0,0.25),saturate(alpha));
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fcc6e1c98c66ff4684678733f05a424
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsRaymarch.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,148 @@
|
||||
Shader "Hidden/EnviroCloudsRaymarchHDRP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
//Tags { "RenderType"="Opaque" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_local _ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile_local _ ENVIRO_CLOUD_SHADOWS
|
||||
#pragma multi_compile_local _ ENVIRO_LIGHTNING
|
||||
#pragma multi_compile_local _ ENVIRO_VARIABLE_BOTTOM
|
||||
#pragma multi_compile __ ENVIROHDRP
|
||||
|
||||
#if defined (ENVIROHDRP)
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
|
||||
#include_with_pragmas "../Includes/VolumetricCloudsInclude.cginc"
|
||||
#include_with_pragmas "../Includes/VolumetricCloudsTexHDRPInclude.cginc"
|
||||
|
||||
|
||||
int _Frame;
|
||||
uniform float _BlueNoiseIntensity;
|
||||
uniform float4 _DepthHandleScale;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.position = GetFullScreenTriangleVertexPosition(v.vertexID);
|
||||
o.uv = GetFullScreenTriangleTexCoord(v.vertexID);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
// uint2 positionSS = i.uv * _ScreenSize.xy;
|
||||
|
||||
float4 cameraRay = float4(i.uv * 2.0 - 1.0, 1.0, 1.0);
|
||||
float3 EyePosition = _CameraPosition;
|
||||
float3 ray = 0;
|
||||
|
||||
//if (unity_StereoEyeIndex == 0)
|
||||
//{
|
||||
cameraRay = mul(_InverseProjection, cameraRay);
|
||||
cameraRay = cameraRay / cameraRay.w;
|
||||
ray = normalize(mul((float3x3)_InverseRotation, cameraRay.xyz));
|
||||
//}
|
||||
//else
|
||||
// {
|
||||
// cameraRay = mul(_InverseProjectionRight, cameraRay);
|
||||
// cameraRay = cameraRay / cameraRay.w;
|
||||
// ray = normalize(mul((float3x3)_InverseRotationRight, cameraRay.xyz));
|
||||
//}
|
||||
|
||||
float rayLength = length(ray);
|
||||
|
||||
float sceneDepth = LOAD_TEXTURE2D_X(_DownsampledDepth, i.uv * _DepthHandleScale.zw);
|
||||
//float sceneDepth = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture, i.uv * _ScreenSize.xy, 0);
|
||||
float raymarchEnd = GetRaymarchEndFromSceneDepth(Linear01Depth(sceneDepth, _ZBufferParams), 1000000); //* rayLenght
|
||||
|
||||
float offset = tex2D(_BlueNoise, squareUV(i.uv + _Randomness.xy)).x * _BlueNoiseIntensity;
|
||||
|
||||
float3 pCent = float3(EyePosition.x, -_CloudsParameter.w, EyePosition.z);
|
||||
|
||||
float intensity, distance, alpha, shadow = 0.0f;
|
||||
|
||||
RaymarchParameters parameters;
|
||||
InitRaymarchParameters(parameters);
|
||||
float2 hitDistance = ResolveRay(EyePosition,ray,pCent,raymarchEnd,parameters);
|
||||
float3 result = Raymarch(EyePosition,ray,hitDistance,pCent,parameters,offset);
|
||||
#if ENVIRO_CLOUD_SHADOWS
|
||||
float3 wpos = CalculateWorldPosition(i.uv,sceneDepth) - _WorldOffset;
|
||||
shadow = RaymarchShadows(EyePosition,wpos,ray,pCent,parameters,offset,sceneDepth);
|
||||
#endif
|
||||
intensity = result.r;
|
||||
distance = result.g;
|
||||
alpha = result.b;
|
||||
|
||||
return float4(max(intensity,0.0),max(distance,1.0f),clamp(shadow,0.0,0.25),saturate(alpha));
|
||||
}
|
||||
#else
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83cb7b07c4a4dd24c91671effd1a1b09
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsRaymarchHDRP.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,150 @@
|
||||
Shader "Hidden/EnviroCloudsRaymarchURP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_local _ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile_local _ ENVIRO_CLOUD_SHADOWS
|
||||
#pragma multi_compile_local _ ENVIRO_LIGHTNING
|
||||
#pragma multi_compile_local _ ENVIRO_VARIABLE_BOTTOM
|
||||
#pragma multi_compile _ ENVIROURP
|
||||
|
||||
#if defined (ENVIROURP)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
#include_with_pragmas "../Includes/VolumetricCloudsInclude.cginc"
|
||||
#include_with_pragmas "../Includes/VolumetricCloudsTexURPInclude.cginc"
|
||||
|
||||
|
||||
int _Frame;
|
||||
uniform float _BlueNoiseIntensity;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertex : SV_VertexID;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
// UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(v.vertex);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(v.vertex);
|
||||
|
||||
o.position = pos;
|
||||
o.uv = DYNAMIC_SCALING_APPLY_SCALEBIAS(uv);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float4 cameraRay = float4(i.uv * 2.0 - 1.0, 1.0, 1.0);
|
||||
float3 EyePosition = _CameraPosition;
|
||||
float3 ray = 0;
|
||||
|
||||
if (unity_StereoEyeIndex == 0)
|
||||
{
|
||||
cameraRay = mul(_InverseProjection, cameraRay);
|
||||
cameraRay = cameraRay / cameraRay.w;
|
||||
ray = normalize(mul((float3x3)_InverseRotation, cameraRay.xyz));
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraRay = mul(_InverseProjectionRight, cameraRay);
|
||||
cameraRay = cameraRay / cameraRay.w;
|
||||
ray = normalize(mul((float3x3)_InverseRotationRight, cameraRay.xyz));
|
||||
}
|
||||
|
||||
float rayLength = length(ray);
|
||||
float sceneDepth = SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth, i.uv);
|
||||
|
||||
float3 cameraDirection = -1 * transpose(_InverseRotation)[2].xyz;
|
||||
float fwdFactor = dot(ray, cameraDirection);
|
||||
float raymarchEnd = GetRaymarchEndFromSceneDepth(Linear01Depth(sceneDepth, _ZBufferParams) / fwdFactor, 1000000); //* rayLenght
|
||||
|
||||
|
||||
float offset = tex2D(_BlueNoise, squareUV(i.uv + _Randomness.xy)).x * _BlueNoiseIntensity;
|
||||
|
||||
float3 pCent = float3(EyePosition.x, -_CloudsParameter.w, EyePosition.z);
|
||||
|
||||
float intensity, distance, alpha, shadow = 0.0f;
|
||||
|
||||
RaymarchParameters parameters;
|
||||
InitRaymarchParameters(parameters);
|
||||
float2 hitDistance = ResolveRay(EyePosition,ray,pCent,raymarchEnd,parameters);
|
||||
float3 result = Raymarch(EyePosition,ray,hitDistance,pCent,parameters,offset);
|
||||
#if ENVIRO_CLOUD_SHADOWS
|
||||
float3 wpos = CalculateWorldPosition(i.uv,sceneDepth) - _WorldOffset;
|
||||
shadow = RaymarchShadows(EyePosition,wpos,ray,pCent,parameters,offset,sceneDepth);
|
||||
#endif
|
||||
intensity = result.r;
|
||||
distance = result.g;
|
||||
alpha = result.b;
|
||||
|
||||
return float4(max(intensity,0.0),max(distance,1.0f),clamp(shadow,0.0,0.25),saturate(alpha));
|
||||
}
|
||||
#else
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4455315341b379429a123aa5b2edd2a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,186 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsReproject"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile _ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile _ ENVIROURP
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_UndersampleCloudTex);
|
||||
float4 _UndersampleCloudTex_TexelSize;
|
||||
|
||||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_DownsampledDepth);
|
||||
|
||||
float4x4 _PrevVP;
|
||||
float4x4 _CamToWorld;
|
||||
//float4x4 _CamProjection;
|
||||
|
||||
float4 _ProjectionExtents;
|
||||
float4 _ProjectionExtentsRight;
|
||||
|
||||
float2 _TexelSize;
|
||||
float _BlendTime;
|
||||
float3 _WorldOffset;
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 ray : TEXCOORD1;
|
||||
// float4 screenPos : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
#if defined(ENVIROURP)
|
||||
o.vertex = float4(v.vertex.xyz,1.0);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.vertex.y *= -1;
|
||||
#endif
|
||||
#else
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#endif
|
||||
o.uv = v.uv;
|
||||
|
||||
if(unity_StereoEyeIndex == 0)
|
||||
o.ray = (2.0 * v.uv - 1.0) * _ProjectionExtents.xy + _ProjectionExtents.zw;
|
||||
else
|
||||
o.ray = (2.0 * v.uv - 1.0) * _ProjectionExtentsRight.xy + _ProjectionExtentsRight.zw;
|
||||
|
||||
// o.screenPos = ComputeScreenPos(o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float2 PrevUV(float4 wspos, out half outOfBound)
|
||||
{
|
||||
float4 prevClip = mul(_PrevVP, wspos);
|
||||
prevClip.xy /= prevClip.w;
|
||||
prevClip.xy = prevClip.xy * 0.5 + 0.5;
|
||||
|
||||
half oobmax = max(0.0 - prevClip.x, 0.0 - prevClip.y);
|
||||
half oobmin = max(prevClip.x - 1.0, prevClip.y - 1.0);
|
||||
|
||||
outOfBound = step(0, max(oobmin, oobmax));
|
||||
|
||||
return prevClip.xy;
|
||||
}
|
||||
|
||||
float4 ClipAABB(float4 aabbMin, float4 aabbMax, float4 prevSample)
|
||||
{
|
||||
float4 p_clip = 0.5 * (aabbMax + aabbMin);
|
||||
float4 e_clip = 0.5 * (aabbMax - aabbMin);
|
||||
|
||||
float4 v_clip = prevSample - p_clip;
|
||||
float4 v_unit = v_clip / e_clip;
|
||||
float4 a_unit = abs(v_unit);
|
||||
float ma_unit = max(max(a_unit.x, max(a_unit.y, a_unit.z)), a_unit.w);
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return p_clip + v_clip / ma_unit;
|
||||
else
|
||||
return prevSample;
|
||||
}
|
||||
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float3 vspos = float3(i.ray, 1.0);
|
||||
|
||||
float4 raymarchResult = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_UndersampleCloudTex,UnityStereoTransformScreenSpaceTex(i.uv));
|
||||
|
||||
float distance = raymarchResult.y;
|
||||
// float intensity = raymarchResult.x;
|
||||
half outOfBound;
|
||||
|
||||
float4 worldPos = mul(_CamToWorld, float4(normalize(vspos) * distance, 1.0));
|
||||
worldPos /= worldPos.w;
|
||||
//worldPos.xyz -= _WorldOffset;
|
||||
|
||||
float2 prevUV = PrevUV(worldPos, outOfBound);
|
||||
{
|
||||
float4 prevSample = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoTransformScreenSpaceTex(prevUV));
|
||||
|
||||
float4 m1 = float4(0.0f,0.0f,0.0f,0.0f);
|
||||
float4 m2 = float4(0.0f,0.0f,0.0f,0.0f);
|
||||
|
||||
float sampleCount = 1.0f;
|
||||
float originalPointDepth = LinearEyeDepth(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DownsampledDepth, UnityStereoTransformScreenSpaceTex(i.uv)));
|
||||
[unroll]
|
||||
for (int x = -1; x <= 1; x ++)
|
||||
{
|
||||
[unroll]
|
||||
for (int y = -1; y <= 1; y ++ )
|
||||
{
|
||||
float4 val;
|
||||
if (x == 0 && y == 0)
|
||||
{
|
||||
val = raymarchResult;
|
||||
m1 += val;
|
||||
m2 += val * val;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 uv = i.uv + float2(x * _UndersampleCloudTex_TexelSize.x, y * _UndersampleCloudTex_TexelSize.y);
|
||||
val = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_UndersampleCloudTex, UnityStereoTransformScreenSpaceTex(uv));
|
||||
float depth = LinearEyeDepth(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_DownsampledDepth,UnityStereoTransformScreenSpaceTex(uv)));
|
||||
|
||||
if (abs(originalPointDepth - depth) < (pow(max(1, depth), 1.5f) / 500.0f))
|
||||
{
|
||||
m1 += val;
|
||||
m2 += val * val;
|
||||
sampleCount += 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float gamma = _BlendTime;
|
||||
float4 mu = m1 / sampleCount;
|
||||
float4 sigma = sqrt(abs(m2 / sampleCount - mu * mu));
|
||||
float4 minc = mu - gamma * sigma;
|
||||
float4 maxc = mu + gamma * sigma;
|
||||
prevSample = ClipAABB(minc, maxc, prevSample);
|
||||
|
||||
//Blend.
|
||||
raymarchResult = lerp(prevSample, raymarchResult, max(0.001f, outOfBound));
|
||||
|
||||
}
|
||||
return raymarchResult;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83e3f6f2f3eed864ebae27ea7987d19b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsReproject.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,227 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsReprojectHDRP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
//_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile _ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile __ ENVIROHDRP
|
||||
#pragma target 4.5
|
||||
|
||||
#if defined (ENVIROHDRP)
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
TEXTURE2D_X(_UndersampleCloudTex);
|
||||
SAMPLER(sampler_UndersampleCloudTex);
|
||||
float4 _UndersampleCloudTex_TexelSize;
|
||||
|
||||
TEXTURE2D_X(_DownsampledDepth);
|
||||
SAMPLER(sampler_DownsampledDepth);
|
||||
|
||||
float4x4 _PrevVP;
|
||||
float4x4 _CamToWorld;
|
||||
|
||||
float4 _ProjectionExtents;
|
||||
float4 _ProjectionExtentsRight;
|
||||
|
||||
float2 _TexelSize;
|
||||
float _BlendTime;
|
||||
float3 _WorldOffset;
|
||||
|
||||
uniform float4 _DepthHandleScale;
|
||||
uniform float4 _UndersampleCloudTexScale;
|
||||
uniform float4 _MainTexHandleScale;
|
||||
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 ray : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = GetFullScreenTriangleVertexPosition(v.vertexID);
|
||||
o.uv = GetFullScreenTriangleTexCoord(v.vertexID);
|
||||
|
||||
if(unity_StereoEyeIndex == 0)
|
||||
o.ray = (2.0 * o.uv * _RTHandleScale.xy - 1.0) * _ProjectionExtents.xy + _ProjectionExtents.zw;
|
||||
else
|
||||
o.ray = (2.0 * o.uv * _RTHandleScale.xy - 1.0) * _ProjectionExtentsRight.xy + _ProjectionExtentsRight.zw;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float2 PrevUV(float4 wspos, out half outOfBound)
|
||||
{
|
||||
float4 prevClip = mul(_PrevVP, wspos);
|
||||
prevClip.xy /= prevClip.w;
|
||||
prevClip.xy = prevClip.xy * 0.5 + 0.5;
|
||||
|
||||
half oobmax = max(0.0 - prevClip.x, 0.0 - prevClip.y);
|
||||
half oobmin = max(prevClip.x - 1.0, prevClip.y - 1.0);
|
||||
|
||||
outOfBound = step(0, max(oobmin, oobmax));
|
||||
|
||||
return prevClip.xy;
|
||||
}
|
||||
|
||||
|
||||
float4 ClipAABB(float4 aabbMin, float4 aabbMax, float4 prevSample)
|
||||
{
|
||||
float4 p_clip = 0.5 * (aabbMax + aabbMin);
|
||||
float4 e_clip = 0.5 * (aabbMax - aabbMin);
|
||||
|
||||
float4 v_clip = prevSample - p_clip;
|
||||
float4 v_unit = v_clip / e_clip;
|
||||
float4 a_unit = abs(v_unit);
|
||||
float ma_unit = max(max(a_unit.x, max(a_unit.y, a_unit.z)), a_unit.w);
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return p_clip + v_clip / ma_unit;
|
||||
else
|
||||
return prevSample;
|
||||
}
|
||||
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float3 vspos = float3(i.ray, 1.0);
|
||||
|
||||
float4 raymarchResult = SAMPLE_TEXTURE2D_X(_UndersampleCloudTex,sampler_UndersampleCloudTex, i.uv);
|
||||
|
||||
float distance = raymarchResult.y;
|
||||
//float intensity = raymarchResult.x;
|
||||
half outOfBound;
|
||||
|
||||
float4 worldPos = mul(_CamToWorld, float4(normalize(vspos) * distance, 1.0));
|
||||
worldPos /= worldPos.w;
|
||||
//worldPos.xyz -= _WorldOffset;
|
||||
|
||||
float2 prevUV = PrevUV(worldPos, outOfBound);
|
||||
{
|
||||
float4 prevSample = SAMPLE_TEXTURE2D_X(_MainTex,sampler_MainTex, prevUV * _MainTexHandleScale.xy );
|
||||
|
||||
float4 m1 = float4(0.0f,0.0f,0.0f,0.0f);
|
||||
float4 m2 = float4(0.0f,0.0f,0.0f,0.0f);
|
||||
|
||||
float sampleCount = 1.0f;
|
||||
|
||||
float originalPointDepth = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth, i.uv * _DepthHandleScale.xy).r, _ZBufferParams);
|
||||
|
||||
[unroll]
|
||||
for (int x = -1; x <= 1; x ++)
|
||||
{
|
||||
[unroll]
|
||||
for (int y = -1; y <= 1; y ++ )
|
||||
{
|
||||
float4 val;
|
||||
if (x == 0 && y == 0)
|
||||
{
|
||||
val = raymarchResult;
|
||||
m1 += val;
|
||||
m2 += val * val;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 uv = i.uv + float2(x * _UndersampleCloudTex_TexelSize.x, y * _UndersampleCloudTex_TexelSize.y);
|
||||
val = SAMPLE_TEXTURE2D_X(_UndersampleCloudTex,sampler_UndersampleCloudTex, uv);
|
||||
float depth = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth,uv * _DepthHandleScale.xy).r, _ZBufferParams);
|
||||
|
||||
if (abs(originalPointDepth - depth) < (pow(max(1, depth), 1.5f) / 500.0f))
|
||||
{
|
||||
m1 += val;
|
||||
m2 += val * val;
|
||||
sampleCount += 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float gamma = _BlendTime;
|
||||
float4 mu = m1 / sampleCount;
|
||||
float4 sigma = sqrt(abs(m2 / sampleCount - mu * mu));
|
||||
float4 minc = mu - gamma * sigma;
|
||||
float4 maxc = mu + gamma * sigma;
|
||||
|
||||
|
||||
prevSample = ClipAABB(minc, maxc, prevSample);
|
||||
|
||||
//Blend
|
||||
raymarchResult = lerp(prevSample, raymarchResult, max(0.001f, outOfBound));
|
||||
|
||||
}
|
||||
return raymarchResult;
|
||||
}
|
||||
#else
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81afbae9e0be32648a45d6acd2db0f7b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroVolumetricCloudsReprojectHDRP.shader
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,222 @@
|
||||
Shader "Hidden/EnviroVolumetricCloudsReprojectURP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", any) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile _ ENVIRO_DEPTH_BLENDING
|
||||
#pragma multi_compile _ ENVIROURP
|
||||
|
||||
#if defined (ENVIROURP)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _UndersampleCloudTex_TexelSize;
|
||||
|
||||
TEXTURE2D_X(_MainTex);
|
||||
SAMPLER (sampler_MainTex);
|
||||
|
||||
TEXTURE2D_X(_UndersampleCloudTex);
|
||||
SAMPLER (sampler_UndersampleCloudTex);
|
||||
|
||||
TEXTURE2D_X_FLOAT(_DownsampledDepth);
|
||||
SAMPLER (sampler_DownsampledDepth);
|
||||
|
||||
float4x4 _PrevVP;
|
||||
float4x4 _CamToWorld;
|
||||
|
||||
float4 _ProjectionExtents;
|
||||
float4 _ProjectionExtentsRight;
|
||||
|
||||
float2 _TexelSize;
|
||||
float _BlendTime;
|
||||
float3 _WorldOffset;
|
||||
|
||||
|
||||
struct appdata
|
||||
{
|
||||
uint vertex : SV_VertexID;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 ray : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(v.vertex);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(v.vertex);
|
||||
|
||||
o.vertex = pos;
|
||||
o.uv = DYNAMIC_SCALING_APPLY_SCALEBIAS(uv);
|
||||
|
||||
if(unity_StereoEyeIndex == 0)
|
||||
o.ray = (2.0 * o.uv - 1.0) * _ProjectionExtents.xy + _ProjectionExtents.zw;
|
||||
else
|
||||
o.ray = (2.0 * o.uv - 1.0) * _ProjectionExtentsRight.xy + _ProjectionExtentsRight.zw;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
float2 PrevUV(float4 wspos, out half outOfBound)
|
||||
{
|
||||
float4 prevClip = mul(_PrevVP, wspos);
|
||||
prevClip.xy /= prevClip.w;
|
||||
prevClip.xy = prevClip.xy * 0.5 + 0.5;
|
||||
|
||||
half oobmax = max(0.0 - prevClip.x, 0.0 - prevClip.y);
|
||||
half oobmin = max(prevClip.x - 1.0, prevClip.y - 1.0);
|
||||
|
||||
outOfBound = step(0, max(oobmin, oobmax));
|
||||
|
||||
return prevClip.xy;
|
||||
}
|
||||
|
||||
float4 ClipAABB(float4 aabbMin, float4 aabbMax, float4 prevSample)
|
||||
{
|
||||
float4 p_clip = 0.5 * (aabbMax + aabbMin);
|
||||
float4 e_clip = 0.5 * (aabbMax - aabbMin);
|
||||
|
||||
float4 v_clip = prevSample - p_clip;
|
||||
float4 v_unit = v_clip / e_clip;
|
||||
float4 a_unit = abs(v_unit);
|
||||
float ma_unit = max(max(a_unit.x, max(a_unit.y, a_unit.z)), a_unit.w);
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return p_clip + v_clip / ma_unit;
|
||||
else
|
||||
return prevSample;
|
||||
}
|
||||
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
float3 vspos = float3(i.ray, 1.0);
|
||||
|
||||
float4 raymarchResult = SAMPLE_TEXTURE2D_X(_UndersampleCloudTex, sampler_UndersampleCloudTex, i.uv);
|
||||
|
||||
float distance = raymarchResult.y;
|
||||
// float intensity = raymarchResult.x;
|
||||
half outOfBound;
|
||||
|
||||
float4 worldPos = mul(_CamToWorld, float4(normalize(vspos) * distance, 1.0));
|
||||
worldPos /= worldPos.w;
|
||||
//worldPos.xyz -= _WorldOffset;
|
||||
|
||||
float2 prevUV = PrevUV(worldPos, outOfBound);
|
||||
{
|
||||
|
||||
float4 prevSample = SAMPLE_TEXTURE2D_X(_MainTex, sampler_MainTex, prevUV);
|
||||
|
||||
float4 m1 = float4(0.0f,0.0f,0.0f,0.0f);
|
||||
float4 m2 = float4(0.0f,0.0f,0.0f,0.0f);
|
||||
|
||||
float sampleCount = 1.0f;
|
||||
float originalPointDepth = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth, sampler_DownsampledDepth,i.uv).r, _ZBufferParams);
|
||||
[unroll]
|
||||
for (int x = -1; x <= 1; x ++)
|
||||
{
|
||||
[unroll]
|
||||
for (int y = -1; y <= 1; y ++ )
|
||||
{
|
||||
float4 val;
|
||||
if (x == 0 && y == 0)
|
||||
{
|
||||
val = raymarchResult;
|
||||
m1 += val;
|
||||
m2 += val * val;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 uv = i.uv + float2(x * _UndersampleCloudTex_TexelSize.x, y * _UndersampleCloudTex_TexelSize.y);
|
||||
val = SAMPLE_TEXTURE2D_X(_UndersampleCloudTex,sampler_UndersampleCloudTex, uv);
|
||||
float depth = LinearEyeDepth(SAMPLE_TEXTURE2D_X(_DownsampledDepth,sampler_DownsampledDepth,uv).r, _ZBufferParams);
|
||||
|
||||
if (abs(originalPointDepth - depth) < (pow(max(1, depth), 1.5f) / 500.0f))
|
||||
{
|
||||
m1 += val;
|
||||
m2 += val * val;
|
||||
sampleCount += 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float gamma = _BlendTime;
|
||||
float4 mu = m1 / sampleCount;
|
||||
float4 sigma = sqrt(abs(m2 / sampleCount - mu * mu));
|
||||
float4 minc = mu - gamma * sigma;
|
||||
float4 maxc = mu + gamma * sigma;
|
||||
prevSample = ClipAABB(minc, maxc, prevSample);
|
||||
|
||||
//Blend.
|
||||
raymarchResult = lerp(prevSample, raymarchResult, max(0.001f, outOfBound));
|
||||
|
||||
}
|
||||
return raymarchResult;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
float4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 col = tex2D(_MainTex, i.uv);
|
||||
// just invert the colors
|
||||
col.rgb = 1 - col.rgb;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c02e7540e49837249960828b7291a14e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _MainTex: {instanceID: 0}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
Shader "Enviro3/Standard/WeatherTexture"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Coverage ("Coverage", Range(0,1)) = 0.5
|
||||
_Tiling ("Tiling", Range(1,100)) = 10
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "../Includes/NoiseInclude.cginc"
|
||||
|
||||
#pragma target 3.0
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
half4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_img v)
|
||||
{
|
||||
VertexOutput o;
|
||||
o.position = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4x4 world_view_proj;
|
||||
|
||||
float _CoverageLayer1;
|
||||
float _CloudsTypeLayer1;
|
||||
float _WorleyFreq1Layer1;
|
||||
float _WorleyFreq2Layer1;
|
||||
float _DilateCoverageLayer1;
|
||||
float _DilateTypeLayer1;
|
||||
float _CloudsTypeModifierLayer1;
|
||||
float4 _LocationOffset;
|
||||
float3 _WindDirectionLayer1;
|
||||
|
||||
float4 frag(VertexInput input) : SV_Target
|
||||
{
|
||||
float2 uv = input.uv;
|
||||
|
||||
float2 windOffsetLayer1 = _WindDirectionLayer1.xy;
|
||||
|
||||
//float2 fillerUV = uv.xy + windOffsetLayer1 + _LocationOffset.xy;
|
||||
//float covFiller = WorleyFBM2D(fillerUV,2,0.75) * 0.8;
|
||||
|
||||
int freq1 = _WorleyFreq1Layer1;
|
||||
int freq2 = _WorleyFreq2Layer1;
|
||||
|
||||
//Worley Noise
|
||||
float worley1Layer1 = WorleyFBM2D((windOffsetLayer1 + _LocationOffset.xy + uv.xy), freq1, 1.4);
|
||||
float worley2Layer1 = WorleyFBM2D((windOffsetLayer1 + _LocationOffset.xy + uv.xy), freq2, 2.2);
|
||||
|
||||
float dilateCoverageLayer1 = lerp(worley1Layer1,worley2Layer1,_DilateCoverageLayer1);
|
||||
|
||||
//Coverage Layer
|
||||
float coverageLayer1 = saturate(dilateCoverageLayer1 + ((1-dilateCoverageLayer1) * _CoverageLayer1));
|
||||
float dilateTypeLayer1 = (pow(lerp(worley1Layer1,worley2Layer1,_DilateTypeLayer1),0.5) - 0.1) * 0.65;
|
||||
float typeLayer1 = saturate(dilateTypeLayer1 * _CloudsTypeModifierLayer1);
|
||||
|
||||
|
||||
float topClouds = saturate(pow((worley2Layer1) * worley1Layer1,1.5) + pow(worley1Layer1,_CoverageLayer1 * 2));
|
||||
|
||||
|
||||
return float4(coverageLayer1,typeLayer1,topClouds,pow(topClouds,0.5));
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 934edb0dc23e1614da34f81363ce736c
|
||||
timeCreated: 1507124107
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Resources/Shader/Clouds/EnviroWeatherMap.shader
|
||||
uploadId: 660896
|
||||
Reference in New Issue
Block a user