Initial commit

This commit is contained in:
gunnbr committed 2021-01-11 22:20:43 -08:00
1 parent ee9615239e
commit 16feac691f
4093 files changed
+1030491

No files matched your search

@@ -0,0 +1,96 @@
Shader "Hidden/Gaia/CombineCollisionMasks" {
Properties{
//The input texture
_InputTex("Input Texture", any) = "" {}
//The image mask texture
_ImageMaskTex("Image Mask Texture", any) = "" {}
//V4 to store width & height dimensions of textures: x,y=_InputTex z,w=_ImageMaskText
_Dimensions("Texture Dimensions", Vector) = (1,1,1,1)
//Flag to determine whether the Mask is inverted or not
_Invert("Invert Distance Mask", Int) = 0
//Strength from 0 to 1 to determine how "strong" the image mask effect is applied
_Strength("Strength", Float) = 0
}
SubShader{
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
sampler2D _ImageMaskTex;
int _Invert;
float _Strength;
float4 _Dimensions;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
ENDCG
Pass // 1 Filter Image Greater Than
{
Name "Filter Image Greater Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment FilterImageGreaterThan
float4 FilterImageGreaterThan(v2f i) : SV_Target
{
float col = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
//scale the UV input according to the size difference so that the image mask tex
float2 relativeUV = i.pcUV;
relativeUV.x = i.pcUV.x * 1.0f;// (_Dimensions.z / _Dimensions.x);
relativeUV.y = i.pcUV.y * 1.0f; // (_Dimensions.w / _Dimensions.y);
float col2 = UnpackHeightmap(tex2D(_ImageMaskTex, relativeUV));
if (_Invert > 0)
{
col2 = (1.0f - col2);
}
float result = col;
if (col2 < col)
{
result = col2;
}
return PackHeightmap(result);
//return PackHeightmap(lerp(col,result,_Strength));
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: eb5e09230c0a64046bcab09fa3440f9c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,192 @@
Shader "Hidden/Gaia/FilterDistanceMask" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
//1-pixel high distance mask texture representing an animation curve
_DistanceMaskTex ("Distance Mask Texture", any) = "" {}
//Int to determine the axis mode, 0 = XZ, 1= X, 2=Z
_AxisMode("Axis Mode", Int) = 0
//X-Offset on the terrain for the center of this distance mask
_XOffset("X Offset", Float) = 0
//Z-Offset on the terrain for the center of this distance mask
_ZOffset("Z Offset", Float) = 0
//1-pixel height transform texture representing an animation curve
_HeightTransformTex ("Height Transform Texture", any) = "" {}
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
sampler2D _DistanceMaskTex;
sampler2D _HeightTransformTex;
int _AxisMode;
float _XOffset;
float _ZOffset;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
float GetFilter(v2f i)
{
float2 UVOffset = i.pcUV;
UVOffset.x += _XOffset;
UVOffset.y += _ZOffset;
float filter = 0.0f;
if (_AxisMode == 0)
{
filter = UnpackHeightmap(tex2D(_DistanceMaskTex, smoothstep(0, sqrt(1) / 2, distance(UVOffset, float2(0.5f, 0.5f)))));
}
else if (_AxisMode == 1)
{
filter = UnpackHeightmap(tex2D(_DistanceMaskTex, float2(i.pcUV.x, 0)));
}
else
{
filter = UnpackHeightmap(tex2D(_DistanceMaskTex, float2(i.pcUV.y, 0)));
}
return filter;
}
ENDCG
Pass // 0 Multiply
{
Name "Distance Mask Multiply"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskMultiply
float4 DistanceMaskMultiply(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height * transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 1 Distance Mask Greater Than
{
Name "Distance Mask Greater Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskGreaterThan
float4 DistanceMaskGreaterThan(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height;
if (transformedHeight > height)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 2 Distance Mask Smaller Than
{
Name "Distance Mask Smaller Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskSmallerThan
float4 DistanceMaskSmallerThan(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height;
if (transformedHeight < height)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 3 Distance Mask Add
{
Name "Distance Mask Add"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskAdd
float4 DistanceMaskAdd(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight =UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height + transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 4 Distance Mask Subtract
{
Name "Distance Mask Subtract"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskSubtract
float4 DistanceMaskSubtract(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight =UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height - transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6aa9d8e335ede724f97b2cb2ed3fe052
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
Shader "Hidden/Gaia/FlipY" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
ENDCG
Pass //0 - Pass with strength transform
{
Name "FlipY"
CGPROGRAM
#pragma vertex vert
#pragma fragment FlipY
float4 FlipY(v2f i) : SV_Target
{
float4 flippedInput = tex2D(_InputTex, float2(i.pcUV.x,1-i.pcUV.y));
return flippedInput;
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: bee27c26d1454e64b8bb784f12e29261
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,120 @@
Shader "Hidden/Gaia/GrowShrink" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
//Grow / Shrink radius distance to be applied (scalar to the terrain size)
_Distance("Distance", Float) = 1
//scalar size of one pixel
_TexelSize("Texel Size", Float) = 0.001
//1-pixel height transform texture representing an animation curve
_HeightTransformTex ("Height Transform Texture", any) = "" {}
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
float _Distance;
float _TexelSize;
sampler2D _HeightTransformTex;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
float GetGrowShrink(v2f i)
{
float input = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
//float shiftedInput = (tex2D(_InputTex, float2(i.pcUV.x + 0.1f,i.pcUV.y +0.1f)));
if(_Distance!=0)
{
float absDistance = abs(_Distance);
for (float x = -absDistance; x <=absDistance; x+=_TexelSize)
{
for (float y = -absDistance; y <=absDistance; y+=_TexelSize)
{
float shiftedInput = (tex2D(_InputTex, float2(i.pcUV.x + x,i.pcUV.y +y)));
float interpolated = lerp(shiftedInput,input,smoothstep(0,distance(float2(0,0),float2(absDistance,absDistance)),distance(float2(0,0),float2(x,y))));
if(_Distance>0)
{
if(interpolated>input)
{
input = interpolated;
}
}
else
{
if(interpolated<input)
{
input = interpolated;
}
}
}
}
}
return input;
}
ENDCG
Pass //0 - Pass with strength transform
{
Name "GrowShrinkStrengthTransform"
CGPROGRAM
#pragma vertex vert
#pragma fragment GrowShrinkStrengthTransform
float4 GrowShrinkStrengthTransform(v2f i) : SV_Target
{
float input = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetGrowShrink(i);
float strengthTransform = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
return PackHeightmap(strengthTransform);
}
ENDCG
}
Pass //1 - Pass without strength transform
{
Name "GrowShrinkWithoutStrengthTransform"
CGPROGRAM
#pragma vertex vert
#pragma fragment GrowShrinkWithoutStrengthTransform
float4 GrowShrinkWithoutStrengthTransform(v2f i) : SV_Target
{
float input = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetGrowShrink(i);
return PackHeightmap(filter);
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4221c7ceeb7313b4cbe227e261cf63c0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,177 @@
Shader "Hidden/Gaia/FilterHeightMask" {
Properties {
//The main texture (existing heightmap)
_HeightMapTex ("Heightmap Texture", any) = "" {}
//The input texture
_InputTex ("Input Texture", any) = "" {}
//1-pixel high distance mask texture representing an animation curve
_HeightMaskTex ("Height Mask Texture", any) = "" {}
//Lower height bound where the height mask will be applied
_MinHeight ("Minimum Height", Float) = 0
//Upper height bound where the height mask will be applied
_MaxHeight ("Maximum Height", Float) = 0
//1-pixel height transform texture representing an animation curve
_HeightTransformTex ("Height Transform Texture", any) = "" {}
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _HeightMapTex;
sampler2D _InputTex;
sampler2D _HeightMaskTex;
sampler2D _HeightTransformTex;
float _MinHeight;
float _MaxHeight;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
sampler2D _BrushTex;
float4 _BrushParams;
#define BRUSH_STRENGTH (_BrushParams[0])
#define BRUSH_TARGETHEIGHT (_BrushParams[1])
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
float GetFilteredHeight(v2f i)
{
float height = UnpackHeightmap(tex2D(_HeightMapTex, i.pcUV));
float filteredHeight = UnpackHeightmap(tex2D(_HeightMaskTex, smoothstep(_MinHeight, _MaxHeight, height)));
return filteredHeight;
}
ENDCG
Pass // 0 Height Mask Multiply
{
Name "Height Mask Multiply"
CGPROGRAM
#pragma vertex vert
#pragma fragment HeightMaskMultiply
float4 HeightMaskMultiply(v2f i) : SV_Target
{
float inputTexHeight = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filteredHeight = GetFilteredHeight(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filteredHeight));
float result = transformedHeight*inputTexHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 1 Height Mask Greater Than
{
Name "Height Mask Greater Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment HeightMaskGreaterThan
float4 HeightMaskGreaterThan(v2f i) : SV_Target
{
float inputTexHeight = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filteredHeight = GetFilteredHeight(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filteredHeight));
float result = inputTexHeight;
if (transformedHeight > inputTexHeight)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 2 Height Mask Smaller Than
{
Name "Height Mask Smaller Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment HeightMaskSmallerThan
float4 HeightMaskSmallerThan(v2f i) : SV_Target
{
float inputTexHeight = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filteredHeight = GetFilteredHeight(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filteredHeight));
float result = inputTexHeight;
if (transformedHeight < inputTexHeight)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 3 Height Mask Add
{
Name "Height Mask Add"
CGPROGRAM
#pragma vertex vert
#pragma fragment HeightMaskAdd
float4 HeightMaskAdd(v2f i) : SV_Target
{
float inputTexHeight = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filteredHeight = GetFilteredHeight(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filteredHeight));
float result= inputTexHeight + transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 4 Height Mask Subtract
{
Name "Height Mask Subtract"
CGPROGRAM
#pragma vertex vert
#pragma fragment HeightMaskSubtract
float4 HeightMaskSubtract(v2f i) : SV_Target
{
float inputTexHeight = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filteredHeight = GetFilteredHeight(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filteredHeight));
float result= inputTexHeight - transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3bdafaa8b846f294db3fc85ebc20ab45
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,85 @@
Shader "Hidden/GaiaPro/HeightTransform" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
//The brush texture
_BrushTex("Brush Texture", any) = "" {}
//1-pixel high distance mask texture representing an animation curve
_HeightTransformTex ("Height Transform Texture", any) = "" {}
//Flag to determine whether the Distance mask is inverted or not
_InvertImageMask("Invert Image Mask", Float) = 0
//Scalar Max World Height value to normalize transform curve against
_MaxWorldHeight ("Scalar Max World Height", Float) = 0.8
//Scalar Min World Height value to normalize transform curve against
_MinWorldHeight ("Scalar Min World Height", Float) = 0.2
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
sampler2D _BrushTex;
sampler2D _HeightTransformTex;
float _InvertImageMask;
float _MaxWorldHeight;
float _MinWorldHeight;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
ENDCG
Pass // 0 Height Transform
{
Name "Height Transform"
CGPROGRAM
#pragma vertex vert
#pragma fragment HeightTransform
float4 HeightTransform(v2f i) : SV_Target
{
float inputHeight = tex2D(_InputTex, i.pcUV);
float2 brushUV = PaintContextUVToBrushUV(i.pcUV);
float oob = all(saturate(brushUV) == brushUV) ? 1.0f : 0.0f;
if(!oob)
{
return inputHeight;
}
float normalizedHeight = smoothstep(_MinWorldHeight,_MaxWorldHeight, inputHeight);
float transformedHeight = (_MaxWorldHeight - _MinWorldHeight) * UnpackHeightmap(tex2D(_HeightTransformTex, normalizedHeight));
float brushStrength = UnpackHeightmap(tex2D(_BrushTex, i.pcUV));
return PackHeightmap(lerp(inputHeight, transformedHeight, brushStrength));
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 820bb500563a2a74bae713bc5b5c5d69
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,345 @@
Shader "Hidden/Gaia/FilterImageMask" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
//The image mask texture
_ImageMaskTex ("Image Mask Texture", any) = "" {}
//Flag to determine which Filter Mode to use (grayscale, color selection, RGBA channel)
_FilterMode("FilterMode", Int) = 0
//The selected color (if in color selection filter mode)
_Color("Selected Color", Color) = (1, 1, 1, 1)
//The selection accuracy (if in color selection filter mode)
_ColorAccuracy("Color Accuracy", Float) = 0
//1-pixel height transform texture representing an animation curve
_HeightTransformTex ("Height Transform Texture", any) = "" {}
//X-Offset on the terrain for the center of this image mask
_XOffset("X Offset", Float) = 0
//Z-Offset on the terrain for the center of this image mask
_ZOffset("Z Offset", Float) = 0
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
sampler2D _ImageMaskTex;
int _FilterMode;
float4 _Color;
float _ColorAccuracy;
sampler2D _HeightTransformTex;
float _XOffset;
float _ZOffset;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
/// <summary>
/// Return true if the values are approximately equal
/// </summary>
/// <param name="a">Parameter A</param>
/// <param name="b">Parameter B</param>
/// <returns>True if approximately equal</returns>
bool ApproximatelyEqual(float a, float b, float delta)
{
if (a == b || abs(a - b) < delta)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// Convert XYZ colour to LAB colour, where resulting x = L, y = a, z = b
/// </summary>
/// <param name="c">Source xyz colour</param>
/// <returns>LAB colour where x = L, y = a, z = b</returns>
float3 XYZtoLAB(float3 c)
{
// Based on http://www.easyrgb.com/index.php?X=MATH&H=07
float ref_Y = 100.0f;
float ref_Z = 108.883f;
float ref_X = 95.047f; // Observer= 2°, Illuminant= D65
float Y = c.y / ref_Y;
float Z = c.z / ref_Z;
float X = c.x / ref_X;
if (X > 0.008856f)
X = pow(X, 1.0f / 3.0f);
else
X = (7.787f * X) + (16.0f / 116.0f);
if (Y > 0.008856f)
Y = pow(Y, 1.0f / 3.0f);
else
Y = (7.787f * Y) + (16.0f / 116.0f);
if (Z > 0.008856f)
Z = pow(Z, 1.0f / 3.0f);
else
Z = (7.787f * Z) + (16.0f / 116.0f);
float L = (116.0f * Y) - 16.0f;
float a = 500.0f * (X - Y);
float b = 200.0f * (Y - Z);
return float3(L, a, b);
}
/// <summary>
/// Convert RGB to XYZ colour
/// </summary>
/// <param name="c">Source colour to convert</param>
/// <returns>Source colour as xyz colour</returns>
float3 RGBtoXYZ(float4 c)
{
// Based on http://www.easyrgb.com/index.php?X=MATH&H=02
float R = c.r;
float G = c.g;
float B = c.b;
if (R > 0.04045f)
R = pow(((R + 0.055f) / 1.055f), 2.4f);
else
R = R / 12.92f;
if (G > 0.04045f)
G = pow(((G + 0.055f) / 1.055f), 2.4f);
else
G = G / 12.92f;
if (B > 0.04045f)
B = pow(((B + 0.055f) / 1.055f), 2.4f);
else
B = B / 12.92f;
R *= 100.0f;
G *= 100.0f;
B *= 100.0f;
// Observer. = 2°, Illuminant = D65
float X = R * 0.4124f + G * 0.3576f + B * 0.1805f;
float Y = R * 0.2126f + G * 0.7152f + B * 0.0722f;
float Z = R * 0.0193f + G * 0.1192f + B * 0.9505f;
return float3(X, Y, Z);
}
/// <summary>
/// Convert rgb to lab colour
/// </summary>
/// <param name="c">Source colour to convert</param>
/// <returns>Lab colour x = L, y = a, z = b</returns>
float3 RGBtoLAB(float4 c)
{
return XYZtoLAB(RGBtoXYZ(c));
}
/// <summary>
/// Calculate the CIE76 difference between two colours
/// </summary>
/// <param name="c1"></param>
/// <param name="c2"></param>
/// <returns></returns>
float RGBDifference(float4 c1, float4 c2, float epsilon)
{
if (ApproximatelyEqual(c1.r, c2.r, epsilon) && ApproximatelyEqual(c1.g, c2.g, epsilon) && ApproximatelyEqual(c1.b, c2.b, epsilon))
{
return 0.0f;
}
float3 l1 = RGBtoLAB(c1);
float3 l2 = RGBtoLAB(c2);
float sum = 0.0f;
sum += pow(l1.x - l2.x, 2.0f);
sum += pow(l1.y - l2.y, 2.0f);
sum += pow(l1.z - l2.z, 2.0f);
return max(min(sqrt(sum), 100.0f), 0.0f);
}
//Gets the "second color" that represents the fitness from the image
float GetCol2(v2f i)
{
float2 UVOffset = i.pcUV;
UVOffset.x += _XOffset;
UVOffset.y += _ZOffset;
if(UVOffset.x > 1.0f || UVOffset.x < 0.0f || UVOffset.y > 1.0f || UVOffset.y < 0.0f)
{
return 0.0f;
}
float col2 = 0;
float4 imageMaskColor = tex2D(_ImageMaskTex, UVOffset);//smoothstep(0, sqrt(1) / 2, distance(UVOffset, float2(0.5f, 0.5f))));
switch (_FilterMode)
{
case 0:
col2 = max(imageMaskColor.r, max(imageMaskColor.g ,imageMaskColor.b));
break;
case 1:
const float epsilon = 0.00001;
float difference = RGBDifference(imageMaskColor, _Color, epsilon);
if (difference < (1.0f - _ColorAccuracy) * 100.0f)
{
col2 = 1.0f - (difference / 100.0f) * _ColorAccuracy;
}
break;
case 2:
col2 = imageMaskColor.r;
break;
case 3:
col2 = imageMaskColor.g;
break;
case 4:
col2 = imageMaskColor.b;
break;
case 5:
col2 = imageMaskColor.a;
break;
}
return col2;
}
ENDCG
Pass // 0 Filter Image Multiply
{
Name "Filter Image Multiply"
CGPROGRAM
#pragma vertex vert
#pragma fragment FilterImageMultiply
float4 FilterImageMultiply(v2f i) : SV_Target
{
float col = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float col2 = GetCol2(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, col2));
float result = col * transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 1 Filter Image Greater Than
{
Name "Filter Image Greater Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment FilterImageGreaterThan
float4 FilterImageGreaterThan(v2f i) : SV_Target
{
float col = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float col2 = GetCol2(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, col2));
float result = col;
if(transformedHeight>col)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 2 Filter Image Smaller Than
{
Name "Filter Image Smaller Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment FilterImageSmallerThan
float4 FilterImageSmallerThan(v2f i) : SV_Target
{
float col = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float col2 = GetCol2(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, col2));
float result = col;
if(transformedHeight<col)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 3 Filter Image Add
{
Name "Filter Image Add"
CGPROGRAM
#pragma vertex vert
#pragma fragment FilterImageAdd
float4 FilterImageAdd(v2f i) : SV_Target
{
float col = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float col2 = GetCol2(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, col2));
float result = col + transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 4 Filter Image Subtract
{
Name "Filter Image Subtract"
CGPROGRAM
#pragma vertex vert
#pragma fragment FilterImageSubtract
float4 FilterImageSubtract(v2f i) : SV_Target
{
float col = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float col2 = GetCol2(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, col2));
float result = col - transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1672638d49cff3047b98a66189aba616
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,92 @@
Shader "Hidden/Gaia/MixHeight" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
//The brush texture
_BrushTex("Brush Texture", any) = "" {}
//The stamp texture we want to mix in
StampTex("Stamp Texture", any) =""{}
//The level at which the mixing with the brush value takes place
//0=at the bottom level of the Brush
//1=at the top level of the Brush
_MixMidPoint("Mix Mid Point", Float) = 0.5
//Strength from 0 to 1 to determine how "strong" the effect is applied
_Strength ("Strength", Float) = 0
//The minimum scalar (0....1) height from the exisiting terrain
_WorldHeightMin("WorldHeightMin", Float) = 0
//The maximum scalar (0....1) height from the exisiting terrain
_WorldHeightMax("WorldHeightMax", Float) = 1
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
sampler2D _BrushTex;
sampler2D _StampTex;
float _MixMidPoint;
float _Strength;
float _WorldHeightMin;
float _WorldHeightMax;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
ENDCG
Pass // 0 Height Mix
{
Name "Height Mix"
CGPROGRAM
#pragma vertex vert
#pragma fragment HeightMix
float4 HeightMix(v2f i) : SV_Target
{
float2 brushUV = PaintContextUVToBrushUV(i.pcUV);
float2 heightmapUV = PaintContextUVToHeightmapUV(i.pcUV);
float oob = all(saturate(brushUV) == brushUV) ? 1.0f : 0.0f;
float inputHeight = tex2D(_InputTex, heightmapUV);
float brushStrength = oob * UnpackHeightmap(tex2D(_BrushTex, brushUV));
float stampHeight = oob * UnpackHeightmap(tex2D(_StampTex, brushUV));
float target = inputHeight + ((stampHeight - _MixMidPoint) * (_WorldHeightMax - _WorldHeightMin) * _Strength) ;
return PackHeightmap(lerp(inputHeight, target, brushStrength));
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a7aa318884e13e64abd25145c153d7a1
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,183 @@
Shader "Hidden/Gaia/FilterSlopeMask" {
Properties {
//The main texture (existing heightmap)
_NormalMapTex("Normalmap Texture", any) = "" {}
//The input texture
_InputTex ("Input Texture", any) = "" {}
//1-pixel high distance mask texture representing an animation curve
_SlopeMaskTex ("Slope Mask Texture", any) = "" {}
//Lower height bound where the height mask will be applied
_MinSlope ("Minimum Slope", Float) = 0
//Upper height bound where the height mask will be applied
_MaxSlope ("Maximum Slope", Float) = 0
//1-pixel height transform texture representing an animation curve
_HeightTransformTex ("Height Transform Texture", any) = "" {}
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _NormalMapTex;
sampler2D _InputTex;
sampler2D _SlopeMaskTex;
sampler2D _HeightTransformTex;
float _MinSlope;
float _MaxSlope;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
sampler2D _BrushTex;
float4 _BrushParams;
#define BRUSH_STRENGTH (_BrushParams[0])
#define BRUSH_TARGETHEIGHT (_BrushParams[1])
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
float GetFilter(v2f i)
{
float3 normal = tex2D(_NormalMapTex, i.pcUV);
//float slope = 1.0f - normal.y;
float3 upwardsVector = { 0.0f, 1.0f, 0.0f };
float slope = clamp(1.0f - dot(upwardsVector, normal), 0.0f, 1.0f);
float filter = UnpackHeightmap(tex2D(_SlopeMaskTex, smoothstep(_MinSlope, _MaxSlope, slope)));
return filter;
}
ENDCG
Pass // 0 Slope Mask Multiply
{
Name "Slope Mask Multiply"
CGPROGRAM
#pragma vertex vert
#pragma fragment SlopeMaskMultiply
float4 SlopeMaskMultiply(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height*transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 1 Slope Mask Greater Than
{
Name "Slope Mask Greater Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment SlopeMaskGreaterThan
float4 SlopeMaskGreaterThan(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height;
if (transformedHeight > height)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 2 Slope Mask Smaller Than
{
Name "Slope Mask Smaller Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment SlopeMaskSmallerThan
float4 SlopeMaskSmallerThan(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height;
if (transformedHeight < height)
{
result = transformedHeight;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 3 Slope Mask Add
{
Name "Slope Mask Add"
CGPROGRAM
#pragma vertex vert
#pragma fragment SlopeMaskAdd
float4 SlopeMaskAdd(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height + transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
Pass // 4 Slope Mask Subtract
{
Name "Slope Mask Subtract"
CGPROGRAM
#pragma vertex vert
#pragma fragment SlopeMaskSubtract
float4 SlopeMaskSubtract(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float transformedHeight = UnpackHeightmap(tex2D(_HeightTransformTex, filter));
float result = height - transformedHeight;
return PackHeightmap(result);
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f98659d79b914044684af74de42a1e1e
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,193 @@
Shader "Hidden/GaiaPro/StrengthTransform" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
//The brush texture
_BrushTex("Brush Texture", any) = "" {}
//1-pixel high distance mask texture representing an animation curve
_HeightTransformTex ("Height Transform Texture", any) = "" {}
//Flag to determine whether the Distance mask is inverted or not
_Invert("Invert Image Mask", Float) = 0
//Strength from 0 to 1 to determine how "strong" the distance mask effect is applied
_Strength ("Strength", Float) = 0
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
sampler2D _BrushTex;
sampler2D _HeightTransformTex;
float _Invert;
float _Strength;
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
ENDCG
Pass // 0 Strength Transform Multiply
{
Name "Strength Transform Multiply"
CGPROGRAM
#pragma vertex vert
#pragma fragment StrengthTransformMultiply
float4 StrengthTransformMultiply(v2f i) : SV_Target
{
float inputHeight = tex2D(_InputTex, i.pcUV);
float test = UnpackHeightmap(tex2D(_HeightTransformTex, i.pcUV));
float transformedHeight = lerp(0.0f,1.0f,UnpackHeightmap(tex2D(_HeightTransformTex, inputHeight)));
if (_Invert > 0)
{
transformedHeight = (1.0f - transformedHeight);
}
//return PackHeightmap(transformedHeight * brushStrength);
return PackHeightmap(lerp(inputHeight, transformedHeight, _Strength));
}
ENDCG
}
Pass // 1 Strength Transform Greater Than
{
Name "Strength Transform Greater Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment StrengthTransformGreaterThan
float4 StrengthTransformGreaterThan(v2f i) : SV_Target
{
float inputHeight = tex2D(_InputTex, i.pcUV);
float test = UnpackHeightmap(tex2D(_HeightTransformTex, i.pcUV));
float transformedHeight = lerp(0.0f,1.0f,UnpackHeightmap(tex2D(_HeightTransformTex, inputHeight)));
if (_Invert > 0)
{
transformedHeight = (1.0f - transformedHeight);
}
float result = inputHeight;
if (transformedHeight > inputHeight)
{
result = transformedHeight;
}
//return PackHeightmap(transformedHeight * brushStrength);
return PackHeightmap(lerp(inputHeight, result, _Strength));
}
ENDCG
}
Pass // 2 Strength Transform Smaller Than
{
Name "Strength Transform Smaller Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment StrengthTransformSmallerThan
float4 StrengthTransformSmallerThan(v2f i) : SV_Target
{
float inputHeight = tex2D(_InputTex, i.pcUV);
float test = UnpackHeightmap(tex2D(_HeightTransformTex, i.pcUV));
float transformedHeight = lerp(0.0f,1.0f,UnpackHeightmap(tex2D(_HeightTransformTex, inputHeight)));
if (_Invert > 0)
{
transformedHeight = (1.0f - transformedHeight);
}
float result = inputHeight;
if (transformedHeight < inputHeight)
{
result = transformedHeight;
}
//return PackHeightmap(transformedHeight * brushStrength);
return PackHeightmap(lerp(inputHeight, result, _Strength));
}
ENDCG
}
Pass // 3 Strength Transform Add
{
Name "Strength Transform Add"
CGPROGRAM
#pragma vertex vert
#pragma fragment StrengthTransformAdd
float4 StrengthTransformAdd(v2f i) : SV_Target
{
float inputHeight = tex2D(_InputTex, i.pcUV);
float test = UnpackHeightmap(tex2D(_HeightTransformTex, i.pcUV));
float transformedHeight = lerp(0.0f,1.0f,UnpackHeightmap(tex2D(_HeightTransformTex, inputHeight)));
if (_Invert > 0)
{
transformedHeight = (1.0f - transformedHeight);
}
//return PackHeightmap(transformedHeight * brushStrength);
return PackHeightmap(lerp(inputHeight, inputHeight + transformedHeight, _Strength));
}
ENDCG
}
Pass // 4 Strength Transform Subtract
{
Name "Strength Transform Subtract"
CGPROGRAM
#pragma vertex vert
#pragma fragment StrengthTransformSubtract
float4 StrengthTransformSubtract(v2f i) : SV_Target
{
float inputHeight = tex2D(_InputTex, i.pcUV);
float test = UnpackHeightmap(tex2D(_HeightTransformTex, i.pcUV));
float transformedHeight = lerp(0.0f,1.0f,UnpackHeightmap(tex2D(_HeightTransformTex, inputHeight)));
if (_Invert > 0)
{
transformedHeight = (1.0f - transformedHeight);
}
//return PackHeightmap(transformedHeight * brushStrength);
return PackHeightmap(lerp(inputHeight, inputHeight - transformedHeight, _Strength));
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e6188ef1ec6f634468728d8e9f8f7c8b
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
struct TerrainMinMax
{
float minHeight;
float maxHeight;
};
Texture2D<float4> Input;
RWStructuredBuffer<TerrainMinMax>outputBuffer;
[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
if(Input[id.xy].r>outputBuffer[0].maxHeight)
{
outputBuffer[0].maxHeight = Input[id.xy].r;
}
else if(Input[id.xy].r<outputBuffer[0].minHeight)
{
outputBuffer[0].minHeight = Input[id.xy].r;
}
}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e1b6904a2218ef847b819dcd8744c599
ComputeShaderImporter:
externalObjects: {}
currentAPIMask: 4
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,39 @@
// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
struct TerrainPosition
{
int terrainID;
uint2 min;
uint2 max;
int affected;
};
Texture2D<float4> Input;
RWStructuredBuffer<TerrainPosition>outputBuffer;
float fitnessThreshold;
int testInt;
int numberOfTerrains = 0;
[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
if(Input[id.xy].r>fitnessThreshold)
{
for(int i=0;i<numberOfTerrains;i++)
{
TerrainPosition currentPos = outputBuffer[i];
if( id.x >= currentPos.min.x &&
id.y >= currentPos.min.y &&
id.x <= currentPos.max.x &&
id.y <= currentPos.max.y )
{
outputBuffer[i].affected = 1;
}
}
}
}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ab31bdb5aecea3744951fb814c0d268b
ComputeShaderImporter:
externalObjects: {}
currentAPIMask: 4
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,168 @@
Shader "Hidden/Gaia/TreeCollisionMaskBaking" {
Properties {
//The input texture
_InputTex ("Input Texture", any) = "" {}
//number of positions to process
_PositionsCount("Position Count", int) = 0
}
SubShader {
ZTest Always Cull Off ZWrite Off
CGINCLUDE
#include "UnityCG.cginc"
#include "TerrainTool.cginc"
sampler2D _InputTex;
int _PositionsCount = 0;
float4 _TargetPosition[1000];
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
struct appdata_t {
float4 vertex : POSITION;
float2 pcUV : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 pcUV : TEXCOORD0;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.pcUV = v.pcUV;
return o;
}
float GetFilter(v2f i)
{
float filter = 1.0f;
for (int k = 0; k < _PositionsCount; k++) {
float currentFilter = smoothstep(0, _TargetPosition[k].w, distance(i.pcUV, float2(_TargetPosition[k].x, _TargetPosition[k].z)));
if(currentFilter<filter)
{
filter = currentFilter;
}
}
return filter;
}
ENDCG
Pass // 0 Multiply
{
Name "Distance Mask Multiply"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskMultiply
float4 DistanceMaskMultiply(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
return PackHeightmap(filter);
}
ENDCG
}
Pass // 1 Distance Mask Greater Than
{
Name "Distance Mask Greater Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskGreaterThan
float4 DistanceMaskGreaterThan(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float result = height;
if (filter > height)
{
result = filter;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 2 Distance Mask Smaller Than
{
Name "Distance Mask Smaller Than"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskSmallerThan
float4 DistanceMaskSmallerThan(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float result = height;
if (filter < height)
{
result = filter;
}
return PackHeightmap(result);
}
ENDCG
}
Pass // 3 Distance Mask Add
{
Name "Distance Mask Add"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskAdd
float4 DistanceMaskAdd(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float result = height + filter;
return PackHeightmap(result);
}
ENDCG
}
Pass // 4 Distance Mask Subtract
{
Name "Distance Mask Subtract"
CGPROGRAM
#pragma vertex vert
#pragma fragment DistanceMaskSubtract
float4 DistanceMaskSubtract(v2f i) : SV_Target
{
float height = UnpackHeightmap(tex2D(_InputTex, i.pcUV));
float filter = GetFilter(i);
float result = height - filter;
return PackHeightmap(result);
}
ENDCG
}
}
Fallback Off
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 35b87b87d74efc047a938cd1a3acbb08
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: