アセット選定
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c2c465f1271dae43ada16626363373b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
## Known Issuse
|
||||
|
||||
# Billboard shadows may flicker in builds
|
||||
Using Unity 2022.x textures may not be properly bound during the shadow caster passes when it comes to the billboards.
|
||||
This only occurs in builds (testen on Windows 11 using DX11 and Vulkan)!
|
||||
|
||||
-> The only solution i have found so far: Duplicate the billboard shader multiple times and assign the different shaders to the different billboards (small, medium, bare, large).
|
||||
|
||||
-> This is fixed at least in Unity 2022.3.20f1
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d770cab170fa2824980238b801245be2
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: effc258b23b39b144a5f89d7aa9a7979
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &120680
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 438060}
|
||||
- component: {fileID: 18220932}
|
||||
- component: {fileID: 5882393046080109602}
|
||||
m_Layer: 0
|
||||
m_Name: CTI Windzone URP
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &438060
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 120680}
|
||||
m_LocalRotation: {x: 0, y: -0.70269245, z: 0, w: 0.71149373}
|
||||
m_LocalPosition: {x: 163, y: 9.21, z: 175.5}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!182 &18220932
|
||||
WindZone:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 120680}
|
||||
m_Enabled: 1
|
||||
m_Mode: 0
|
||||
m_Radius: 20
|
||||
m_WindMain: 1
|
||||
m_WindTurbulence: 0.5
|
||||
m_WindPulseMagnitude: 0.5
|
||||
m_WindPulseFrequency: 0.01
|
||||
--- !u!114 &5882393046080109602
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 120680}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 897a09e95f3c16049a601ce6e13e5caa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
WindMultiplier: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec2aa1014a797c54eb478896b8a82d02
|
||||
timeCreated: 1453985392
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e2e75c4c80c42444aa7165cfaf1ea81
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,139 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ead43cc16b37764fbb12a8114e43ae9
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 2
|
||||
mipBias: -100
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Windows Store Apps
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9de53094ab67f7142903dddbdbdad6d2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace CTI {
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent (typeof (WindZone))]
|
||||
public class CTI_URP_CustomWind : MonoBehaviour {
|
||||
|
||||
private WindZone m_WindZone;
|
||||
|
||||
private Vector3 WindDirection;
|
||||
private float WindStrength;
|
||||
private float WindTurbulence;
|
||||
|
||||
public float WindMultiplier = 1.0f;
|
||||
|
||||
private bool init = false;
|
||||
private int CTIWindPID;
|
||||
private int CTITurbulencedPID;
|
||||
|
||||
private Transform trans;
|
||||
|
||||
void Init () {
|
||||
m_WindZone = GetComponent<WindZone>();
|
||||
CTIWindPID = Shader.PropertyToID("_CTI_SRP_Wind");
|
||||
CTITurbulencedPID = Shader.PropertyToID("_CTI_SRP_Turbulence");
|
||||
trans = this.transform;
|
||||
}
|
||||
|
||||
void OnValidate () {
|
||||
Update ();
|
||||
}
|
||||
|
||||
void Update () {
|
||||
if (!init) {
|
||||
Init ();
|
||||
}
|
||||
WindDirection = trans.forward;
|
||||
|
||||
WindStrength = m_WindZone.windMain;
|
||||
WindStrength += m_WindZone.windPulseMagnitude * (1.0f + Mathf.Sin(Time.time * m_WindZone.windPulseFrequency) + 1.0f + Mathf.Sin(Time.time * m_WindZone.windPulseFrequency * 3.0f) ) * 0.5f;
|
||||
WindStrength *= WindMultiplier;
|
||||
WindTurbulence = m_WindZone.windTurbulence * m_WindZone.windMain * WindMultiplier;
|
||||
|
||||
Shader.SetGlobalVector(CTIWindPID, new Vector4(WindDirection.x, WindDirection.y, WindDirection.z, WindStrength) );
|
||||
Shader.SetGlobalFloat(CTITurbulencedPID, WindTurbulence);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897a09e95f3c16049a601ce6e13e5caa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c927fbacbd0f2d41a179848b10de1f2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
|
||||
namespace CTI {
|
||||
|
||||
public class CTI_URPTransDrawer : MaterialPropertyDrawer {
|
||||
|
||||
public override void OnGUI (Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
|
||||
|
||||
// Needed since Unity 2019
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
|
||||
Vector4 vec4value = prop.vectorValue;
|
||||
|
||||
GUILayout.Space(-18);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.BeginVertical();
|
||||
vec4value.x = EditorGUILayout.Slider("Strength", vec4value.x, 0.0f, 10.0f);
|
||||
vec4value.y = EditorGUILayout.Slider("Power", vec4value.y, 0.0f, 10.0f);
|
||||
EditorGUILayout.EndVertical();
|
||||
if (EditorGUI.EndChangeCheck ()) {
|
||||
prop.vectorValue = vec4value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44905e65e363a6a419889f4a78adebd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
|
||||
namespace CTI {
|
||||
|
||||
public class CTI_URPWindDrawer : MaterialPropertyDrawer {
|
||||
|
||||
public override void OnGUI (Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
|
||||
|
||||
// Needed since Unity 2019
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
|
||||
Vector4 vec4value = prop.vectorValue;
|
||||
|
||||
GUILayout.Space(-18);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.BeginVertical();
|
||||
vec4value.x = EditorGUILayout.Slider("Primary Strength", vec4value.x, 0.0f, 10.0f);
|
||||
vec4value.y = EditorGUILayout.Slider("Scondary Strength", vec4value.y, 0.0f, 10.0f);
|
||||
vec4value.z = EditorGUILayout.Slider("Edge Flutter", vec4value.z, 0.0f, 4.0f);
|
||||
EditorGUILayout.EndVertical();
|
||||
if (EditorGUI.EndChangeCheck ()) {
|
||||
prop.vectorValue = vec4value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f42df5657a0798b43bbc873e443c636d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class CTI_URP_ShaderGUI : ShaderGUI {
|
||||
|
||||
protected Color avrgCol = Color.gray;
|
||||
|
||||
public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
|
||||
base.OnGUI (materialEditor, properties);
|
||||
Material targetMat = materialEditor.target as Material;
|
||||
|
||||
// Bark texture2D
|
||||
if (targetMat.HasProperty("_BumpOcclusionMap")) {
|
||||
if ( targetMat.GetTexture("_BumpOcclusionMap") == null) {
|
||||
targetMat.SetTexture("_BumpOcclusionMap", Resources.Load("CTI_Default_NST") as Texture2D );
|
||||
}
|
||||
}
|
||||
|
||||
// Leaves
|
||||
if (targetMat.HasProperty("_BumpSpecMap")){
|
||||
if (targetMat.GetTexture("_BumpSpecMap") == null) {
|
||||
targetMat.SetTexture("_BumpSpecMap", Resources.Load("CTI_Default_NST") as Texture2D );
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(8);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 453e1b0bc24ec68468e6655e08e28b09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca75dee1e1c3f604a953ef7560eb71a1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b04305346960a4d43b15392fde8e26e5
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59b526d69ac994c4bad0edbac50b6685
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21d7dc78afae6da45a145e73098e628a
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9687c08fa2bba864ba8950c7a039274c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd5346f32d7fd23488eda10b183acc31
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac91899539dff654b86b33f7175c5dd8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
// URP uses _half
|
||||
|
||||
void CTIBillboardFragment_half (
|
||||
in float4 UV,
|
||||
in real2 BlendCv,
|
||||
in float4 ScreenPosRaw,
|
||||
|
||||
out real3 o_Albedo,
|
||||
out real o_Alpha,
|
||||
out real3 o_NormalTS,
|
||||
out real o_Smoothness,
|
||||
out real o_Occlusion,
|
||||
out real o_Thickness
|
||||
) {
|
||||
|
||||
|
||||
real4 sampleA = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, UV.xy);
|
||||
real4 n_sampleA = SAMPLE_TEXTURE2D(_BumpSpecMap, sampler_BumpSpecMap, UV.xy);
|
||||
|
||||
real blend = saturate(1.0 - BlendCv.x);
|
||||
|
||||
if (_BlendBB)
|
||||
{
|
||||
real4 sampleB = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, UV.zw);
|
||||
real4 n_sampleB = SAMPLE_TEXTURE2D(_BumpSpecMap, sampler_BumpSpecMap, UV.zw);
|
||||
|
||||
// Dither
|
||||
if (_BlendBBDithering)
|
||||
{
|
||||
float2 screenPos = floor( (ScreenPosRaw.xy / ScreenPosRaw.w) * _ScreenParams.xy);
|
||||
real alphaClip = InterleavedGradientNoise(float4(screenPos, ScreenPosRaw.zw), (real)0.0);
|
||||
// real alphaClip = GenerateHashedRandomFloat( asuint((int2)screenPos.xy) );
|
||||
|
||||
real blend = BlendCv.x;
|
||||
blend = saturate( ((real)1.0 - blend - alphaClip) * (real)1000.0);
|
||||
}
|
||||
|
||||
sampleA.a = sampleA.a * blend;
|
||||
sampleB.a = sampleB.a * (1.0 - blend);
|
||||
|
||||
sampleA.rgb = sampleA.rgb * blend;
|
||||
sampleA.rgb += sampleB.rgb * (1.0 - blend);
|
||||
|
||||
//n_sampleA = n_sampleA * blend + n_sampleB * (1.0 - blend); // Needs dithering!
|
||||
n_sampleA = lerp(n_sampleA, n_sampleB, sampleB.aaaa);
|
||||
|
||||
sampleA.a += sampleB.a;
|
||||
}
|
||||
|
||||
// Up is flipped!
|
||||
n_sampleA.g = 1.0 - n_sampleA.g;
|
||||
real3 normalTS = UnpackNormalAG(n_sampleA, _BumpScale);
|
||||
|
||||
// Alpha Leak
|
||||
o_Occlusion = (sampleA.a <= _AlphaLeak) ? (real)1.0 : sampleA.a; // Eliminate alpha leaking into ao
|
||||
|
||||
// Add Color Variation
|
||||
o_Albedo = lerp(sampleA.rgb, (sampleA.rgb + _HueVariation.rgb) * (real)0.5, (BlendCv.y * _HueVariation.a).xxx );
|
||||
o_Alpha = sampleA.a;
|
||||
o_NormalTS = normalTS;
|
||||
o_Smoothness = n_sampleA.b * _Smoothness;
|
||||
o_Thickness = n_sampleA.r * _ThicknessRemap;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 068055334d98c4f488fc319e9ee2ed4f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,148 @@
|
||||
// Not needed as we use our own calculation for eyevec!
|
||||
|
||||
// CBUFFER_START(UnityBillboardPerCamera)
|
||||
// float3 unity_BillboardNormal;
|
||||
// float3 unity_BillboardTangent;
|
||||
// float4 unity_BillboardCameraParams;
|
||||
// #define unity_BillboardCameraPosition (unity_BillboardCameraParams.xyz)
|
||||
// #define unity_BillboardCameraXZAngle (unity_BillboardCameraParams.w)
|
||||
// CBUFFER_END
|
||||
|
||||
CBUFFER_START(UnityBillboardPerBatch)
|
||||
float3 unity_BillboardSize;
|
||||
CBUFFER_END
|
||||
|
||||
float4 _CTI_SRP_Wind;
|
||||
float _CTI_SRP_Turbulence;
|
||||
|
||||
#if defined(_PARALLAXMAP)
|
||||
float2 _CTI_TransFade;
|
||||
#endif
|
||||
|
||||
|
||||
float4 SmoothCurve(float4 x) {
|
||||
return x * x * (3.0 - 2.0 * x);
|
||||
}
|
||||
|
||||
float4 TriangleWave(float4 x) {
|
||||
return abs(frac(x + 0.5) * 2.0 - 1.0);
|
||||
}
|
||||
|
||||
float4 SmoothTriangleWave(float4 x) {
|
||||
return (SmoothCurve(TriangleWave(x)) - 0.5) * 2.0;
|
||||
}
|
||||
|
||||
// Billboard Vertex Function
|
||||
void CTI_BillboardVert_float (
|
||||
float3 positionOS,
|
||||
float2 texcoord,
|
||||
float3 texcoord1,
|
||||
|
||||
// float3 lightDir,
|
||||
|
||||
out float3 o_positionOS,
|
||||
out real3 o_normalOS,
|
||||
out real3 o_tangentOS,
|
||||
out float4 o_uv,
|
||||
out real2 o_cv
|
||||
)
|
||||
{
|
||||
|
||||
float3 position = positionOS;
|
||||
float3 positionWS = positionOS + UNITY_MATRIX_M._m03_m13_m23;
|
||||
|
||||
// Store Color Variation
|
||||
//float3 TreeWorldPos = abs(positionWS.xyz * 0.125f);
|
||||
o_cv.y = saturate((frac(positionWS.x + positionWS.y + positionWS.z) + frac((positionWS.x + positionWS.y + positionWS.z) * 3.3)) * 0.5);
|
||||
|
||||
// ////////////////////////////////////
|
||||
// Set vertex position
|
||||
// #if (SHADERPASS == SHADERPASS_SHADOWCASTER)
|
||||
// float3 eyeVec = -lightDir; //normalize(GetCurrentViewPosition() - positionWS);
|
||||
// #else
|
||||
// float3 eyeVec = normalize(_WorldSpaceCameraPos - positionWS);
|
||||
// #endif
|
||||
// Shadows go nuts:
|
||||
// float3 eyeVec = normalize(unity_BillboardCameraPosition - positionWS);
|
||||
|
||||
// So we do it manually
|
||||
// We do not have access to _LightDirection or _LightPosition as these are defined later in code...
|
||||
#if (SHADERPASS == SHADERPASS_SHADOWCASTER)
|
||||
#define cameraForward UNITY_MATRIX_V[2].xyz
|
||||
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
// Matches HDRP GetCurrentViewPosition()
|
||||
float3 eyeVec = normalize(UNITY_MATRIX_I_V._14_24_34 - positionWS); // normalize(_LightPosition - worldPos);
|
||||
#else
|
||||
float3 eyeVec = cameraForward; // _LightDirection;
|
||||
#endif
|
||||
#else
|
||||
float3 eyeVec = GetWorldSpaceNormalizeViewDir(positionWS);
|
||||
#endif
|
||||
|
||||
// NOTE: We have incorrect triangle winding...
|
||||
float3 billboardTangent = normalize(float3(-eyeVec.z, 0, eyeVec.x));
|
||||
real3 billboardNormal = real3(billboardTangent.z, 0, -billboardTangent.x);
|
||||
float2 percent = texcoord.xy;
|
||||
float3 billboardPos = (percent.x - 0.5) * unity_BillboardSize.x * texcoord1.x * billboardTangent;
|
||||
billboardPos.y += (percent.y * unity_BillboardSize.y + unity_BillboardSize.z) * texcoord1.y;
|
||||
|
||||
// Wind - make sure we apply it in "object space" (use billboardPos)
|
||||
if (_WindStrength > 0)
|
||||
{
|
||||
float origLength = length(billboardPos);
|
||||
float sinuswave = _SinTime.z;
|
||||
float4 vOscillations = SmoothTriangleWave(float4(positionWS.x + sinuswave, positionWS.z + sinuswave * 0.8, 0.0, 0.0));
|
||||
float fOsc = vOscillations.x + (vOscillations.y * vOscillations.y);
|
||||
fOsc = 0.75 + (fOsc + 3.33) * 0.33;
|
||||
// saturate added to stop warning on dx11...
|
||||
float percentage = pow(saturate(percent.y), _WindPower); // pow(y,1.5) matches the wind baked to the mesh trees
|
||||
billboardPos.xyz += _CTI_SRP_Wind.xyz * ( _CTI_SRP_Wind.w * _WindStrength * fOsc * percentage );
|
||||
billboardPos = normalize(billboardPos) * origLength;
|
||||
}
|
||||
|
||||
// Now bring it to the proper position
|
||||
position.xyz += billboardPos;
|
||||
o_positionOS.xyz = position.xyz;
|
||||
|
||||
// ////////////////////////////////////
|
||||
// Get billboard texture coords
|
||||
o_uv = 0.0;
|
||||
o_cv.x = 0.0;
|
||||
|
||||
float angle = atan2(billboardNormal.z, billboardNormal.x); // signed angle between billboardNormal to {0,0,1}
|
||||
angle += angle < 0 ? 2 * PI : 0;
|
||||
// Set Rotation
|
||||
angle += texcoord1.z;
|
||||
// Write final billboard texture coords
|
||||
const float invDelta = 1.0 / (45.0 * ((PI * 2.0) / 360.0));
|
||||
float imageIndex = fmod(floor(angle * invDelta + 0.5f), 8.0);
|
||||
float2 column_row;
|
||||
column_row.x = imageIndex * 0.25;
|
||||
column_row.y = saturate(4.0 - imageIndex) * 0.5;
|
||||
o_uv.xy = column_row + texcoord.xy * float2(0.25, 0.5);
|
||||
|
||||
// /////////////////////////
|
||||
if (_BlendBB)
|
||||
{
|
||||
float percentage = frac(angle / (PI / 4));
|
||||
// So percentage 0 - 1: 0 - 0.5 = next texture / 0.5 - 1 prev texture
|
||||
imageIndex = (percentage < 0.5) ? imageIndex + 1.0 : imageIndex - 1.0;
|
||||
// Needed!
|
||||
imageIndex = (imageIndex < 0.0) ? 7.0 : imageIndex;
|
||||
imageIndex = (imageIndex > 7.0) ? 0.0 : imageIndex;
|
||||
|
||||
column_row.x = imageIndex * 0.25; // we do not care about the horizontal coord that much as our billboard texture tiles
|
||||
column_row.y = saturate(4.0 - imageIndex) * 0.5;
|
||||
o_uv.zw = column_row + texcoord.xy * float2(0.25, 0.5);
|
||||
|
||||
// Set Blend value
|
||||
o_cv.x = (percentage < 0.5) ? (percentage * 2.0) : (1.0 - percentage * 2.0);
|
||||
//o_cv.x = smoothstep (0, 1, o_cv.x); // Nope
|
||||
}
|
||||
|
||||
// ////////////////////////////////////
|
||||
// Set Normal and Tangent
|
||||
o_normalOS = billboardNormal.xyz;
|
||||
// We have to fix normalTS in pixel shader as up is flipped!?
|
||||
o_tangentOS = billboardTangent.xyz;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 135f75a97ae2e2e43b2cc94a2ee0898d
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
// Not needed as we use our own calculation for eyevec!
|
||||
|
||||
// CBUFFER_START(UnityBillboardPerCamera)
|
||||
// float3 unity_BillboardNormal;
|
||||
// float3 unity_BillboardTangent;
|
||||
// float4 unity_BillboardCameraParams;
|
||||
// #define unity_BillboardCameraPosition (unity_BillboardCameraParams.xyz)
|
||||
// #define unity_BillboardCameraXZAngle (unity_BillboardCameraParams.w)
|
||||
// CBUFFER_END
|
||||
|
||||
CBUFFER_START(UnityBillboardPerBatch)
|
||||
float3 unity_BillboardSize;
|
||||
CBUFFER_END
|
||||
|
||||
float4 _CTI_SRP_Wind;
|
||||
float _CTI_SRP_Turbulence;
|
||||
|
||||
#if defined(_PARALLAXMAP)
|
||||
float2 _CTI_TransFade;
|
||||
#endif
|
||||
|
||||
|
||||
float4 SmoothCurve(float4 x) {
|
||||
return x * x * (3.0 - 2.0 * x);
|
||||
}
|
||||
|
||||
float4 TriangleWave(float4 x) {
|
||||
return abs(frac(x + 0.5) * 2.0 - 1.0);
|
||||
}
|
||||
|
||||
float4 SmoothTriangleWave(float4 x) {
|
||||
return (SmoothCurve(TriangleWave(x)) - 0.5) * 2.0;
|
||||
}
|
||||
|
||||
// Billboard Vertex Function
|
||||
void CTI_BillboardVert_float (
|
||||
float3 positionOS,
|
||||
float2 texcoord,
|
||||
float3 texcoord1,
|
||||
|
||||
// float3 lightDir,
|
||||
|
||||
out float3 o_positionOS,
|
||||
out half3 o_normalOS,
|
||||
out half3 o_tangentOS,
|
||||
out float2 o_uv,
|
||||
out float o_cv
|
||||
)
|
||||
{
|
||||
|
||||
float3 position = positionOS;
|
||||
float3 positionWS = positionOS + UNITY_MATRIX_M._m03_m13_m23;
|
||||
|
||||
// Store Color Variation
|
||||
//float3 TreeWorldPos = abs(positionWS.xyz * 0.125f);
|
||||
o_cv = saturate((frac(positionWS.x + positionWS.y + positionWS.z) + frac((positionWS.x + positionWS.y + positionWS.z) * 3.3)) * 0.5);
|
||||
|
||||
// #if defined(_PARALLAXMAP)
|
||||
// float3 distVec = _WorldSpaceCameraPos - positionWS;
|
||||
// float distSq = dot(distVec, distVec);
|
||||
// o_UvColorVariationStipple.w = saturate( (_CTI_TransFade.x - distSq) / _CTI_TransFade.y);
|
||||
// #endif
|
||||
|
||||
// ////////////////////////////////////
|
||||
// Set vertex position
|
||||
// #if (SHADERPASS == SHADERPASS_SHADOWCASTER)
|
||||
// float3 eyeVec = -lightDir; //normalize(GetCurrentViewPosition() - positionWS);
|
||||
// #else
|
||||
// float3 eyeVec = normalize(_WorldSpaceCameraPos - positionWS);
|
||||
// #endif
|
||||
// Shadows go nuts:
|
||||
// float3 eyeVec = normalize(unity_BillboardCameraPosition - positionWS);
|
||||
|
||||
// So we do it manually
|
||||
// We do not have access to _LightDirection or _LightPosition as these are defined later in code...
|
||||
#if (SHADERPASS == SHADERPASS_SHADOWCASTER)
|
||||
#define cameraForward UNITY_MATRIX_V[2].xyz
|
||||
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
// Matches HDRP GetCurrentViewPosition()
|
||||
float3 eyeVec = normalize(UNITY_MATRIX_I_V._14_24_34 - positionWS); // normalize(_LightPosition - worldPos);
|
||||
#else
|
||||
float3 eyeVec = cameraForward; // _LightDirection;
|
||||
#endif
|
||||
#else
|
||||
float3 eyeVec = GetWorldSpaceNormalizeViewDir(positionWS);
|
||||
#endif
|
||||
|
||||
// NOTE: We have incorrect triangle winding...
|
||||
float3 billboardTangent = normalize(float3(-eyeVec.z, 0, eyeVec.x));
|
||||
float3 billboardNormal = float3(billboardTangent.z, 0, -billboardTangent.x);
|
||||
float2 percent = texcoord.xy;
|
||||
float3 billboardPos = (percent.x - 0.5) * unity_BillboardSize.x * texcoord1.x * billboardTangent;
|
||||
billboardPos.y += (percent.y * unity_BillboardSize.y + unity_BillboardSize.z) * texcoord1.y;
|
||||
|
||||
// Wind
|
||||
// Make sure we apply it in "object space" (use billboardPos)
|
||||
if (_WindStrength > 0)
|
||||
{
|
||||
//positionWS.xyz = abs(positionWS.xyz * 0.125f);
|
||||
float origLength = length(billboardPos);
|
||||
float sinuswave = _SinTime.z;
|
||||
float4 vOscillations = SmoothTriangleWave(float4(positionWS.x + sinuswave, positionWS.z + sinuswave * 0.8, 0.0, 0.0));
|
||||
float fOsc = vOscillations.x + (vOscillations.y * vOscillations.y);
|
||||
fOsc = 0.75 + (fOsc + 3.33) * 0.33;
|
||||
// saturate added to stop warning on dx11...
|
||||
float percentage = pow(saturate(percent.y), _WindPower); // pow(y,1.5) matches the wind baked to the mesh trees
|
||||
billboardPos.xyz += _CTI_SRP_Wind.xyz * ( _CTI_SRP_Wind.w * _WindStrength * fOsc * percentage );
|
||||
billboardPos = normalize(billboardPos) * origLength;
|
||||
}
|
||||
|
||||
// Now bring it to the proper position
|
||||
position.xyz += billboardPos;
|
||||
o_positionOS.xyz = position.xyz;
|
||||
|
||||
|
||||
// ////////////////////////////////////
|
||||
// Get billboard texture coords
|
||||
float angle = atan2(billboardNormal.z, billboardNormal.x); // signed angle between billboardNormal to {0,0,1}
|
||||
angle += angle < 0 ? 2 * PI : 0;
|
||||
// Set Rotation
|
||||
angle += texcoord1.z;
|
||||
// Write final billboard texture coords
|
||||
const float invDelta = 1.0 / (45.0 * ((PI * 2.0) / 360.0));
|
||||
float imageIndex = fmod(floor(angle * invDelta + 0.5f), 8.0);
|
||||
float2 column_row;
|
||||
column_row.x = imageIndex * 0.25;
|
||||
column_row.y = saturate(4.0 - imageIndex) * 0.5;
|
||||
o_uv.xy = column_row + texcoord.xy * float2(0.25, 0.5);
|
||||
|
||||
// ////////////////////////////////////
|
||||
// Set Normal and Tangent
|
||||
o_normalOS = billboardNormal.xyz;
|
||||
// We have to fix normalTS in pixel shader as up is flipped!?
|
||||
o_tangentOS = billboardTangent.xyz;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a599a3b81d0717d44a255d53c65784ed
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
void CTI_SimpleTranslucentLighting_half(
|
||||
float3 PositionWS,
|
||||
half3 NormalWS,
|
||||
half3 TangentWS,
|
||||
half3 BitangentWS,
|
||||
|
||||
half3 Albedo,
|
||||
half3 NormalTS,
|
||||
half3 Transmission,
|
||||
half TransmissionMask,
|
||||
|
||||
half Occlusion,
|
||||
|
||||
out half3 o_NormalWS,
|
||||
out half3 o_Transmission
|
||||
)
|
||||
{
|
||||
#ifdef SHADERGRAPH_PREVIEW
|
||||
o_NormalWS = half3(0,1,0);
|
||||
o_Transmission = 0;
|
||||
#else
|
||||
|
||||
half3 translucency = 1;
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(PositionWS);
|
||||
half3x3 tangentToWorld = half3x3(TangentWS, BitangentWS, NormalWS);
|
||||
o_NormalWS = NormalizeNormalPerPixel(TransformTangentToWorld(NormalTS, tangentToWorld));
|
||||
|
||||
half4 shadowCoord = TransformWorldToShadowCoord(PositionWS);
|
||||
Light mainLight = GetMainLight(shadowCoord);
|
||||
|
||||
half w = 0.3; // 0.4
|
||||
half NdotL = saturate((dot(o_NormalWS, mainLight.direction) + w) / ((1 + w) * (1 + w)));
|
||||
|
||||
half3 transLightDir = mainLight.direction + o_NormalWS * Transmission.z;
|
||||
half transDot = dot( transLightDir, -viewDirWS );
|
||||
transDot = exp2(saturate(transDot) * Transmission.y - Transmission.y);
|
||||
o_Transmission = transDot * (1.0 - NdotL) * mainLight.color * mainLight.shadowAttenuation * Transmission.x;
|
||||
|
||||
if(_AmbientTranslucency > 0)
|
||||
{
|
||||
o_Transmission += SampleSH(-o_NormalWS) * _AmbientTranslucency * Occlusion;
|
||||
}
|
||||
|
||||
o_Transmission *= Albedo * TransmissionMask;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void SampleSH(half3 normalWS, out half3 Ambient)
|
||||
{
|
||||
// LPPV is not supported in Ligthweight Pipeline
|
||||
real4 SHCoefficients[7];
|
||||
SHCoefficients[0] = unity_SHAr;
|
||||
SHCoefficients[1] = unity_SHAg;
|
||||
SHCoefficients[2] = unity_SHAb;
|
||||
SHCoefficients[3] = unity_SHBr;
|
||||
SHCoefficients[4] = unity_SHBg;
|
||||
SHCoefficients[5] = unity_SHBb;
|
||||
SHCoefficients[6] = unity_SHC;
|
||||
|
||||
Ambient = max(half3(0, 0, 0), SampleSH9(SHCoefficients, normalWS));
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f091e92bb3c3a8346a1a082b1b1260dc
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
void CTI_ShadowFade_half(
|
||||
half alpha,
|
||||
out half o_alpha
|
||||
)
|
||||
{
|
||||
#if (SHADERPASS == SHADERPASS_SHADOWS)
|
||||
o_alpha = 1.0;
|
||||
#else
|
||||
o_alpha = alpha;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CTI_ColorVariation_half(
|
||||
half3 Albedo,
|
||||
half4 ColorVariation,
|
||||
half ColorVariationStrength,
|
||||
|
||||
out half3 o_Albedo
|
||||
)
|
||||
{
|
||||
o_Albedo = lerp(Albedo, (Albedo + ColorVariation.rgb) * 0.5, (ColorVariationStrength * ColorVariation.a).xxx );
|
||||
}
|
||||
|
||||
void CTI_UnpackFixNormal_half(
|
||||
half4 normalSample,
|
||||
half normalScale,
|
||||
float isFrontFace,
|
||||
out half3 o_normalTS
|
||||
)
|
||||
{
|
||||
o_normalTS = UnpackNormalAG(normalSample, normalScale);
|
||||
o_normalTS.z *= isFrontFace ? 1 : -1;
|
||||
}
|
||||
|
||||
void CTI_UnpackNormal_half(
|
||||
half4 normalSample,
|
||||
half normalScale,
|
||||
out half3 o_normalTS
|
||||
)
|
||||
{
|
||||
o_normalTS = UnpackNormalAG(normalSample, normalScale);
|
||||
}
|
||||
|
||||
void CTI_UnpackNormalBillboard_half(
|
||||
half4 normalSample,
|
||||
half normalScale,
|
||||
out half3 o_normalTS
|
||||
)
|
||||
{
|
||||
// Up is flipped!
|
||||
normalSample.g = 1 - normalSample.g;
|
||||
o_normalTS = UnpackNormalAG(normalSample, normalScale);
|
||||
}
|
||||
|
||||
void CTI_AlphaLeak_half(
|
||||
half alphaSample,
|
||||
half leak,
|
||||
out half o_Occlusion
|
||||
)
|
||||
{
|
||||
o_Occlusion = (alphaSample <= leak) ? 1 : alphaSample; // Eliminate alpha leaking into ao
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5d97cde99a37644e83755790f752d33
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,271 @@
|
||||
float4 _CTI_SRP_Wind;
|
||||
float _CTI_SRP_Turbulence;
|
||||
|
||||
float3x3 GetRotationMatrix(float3 axis, float angle)
|
||||
{
|
||||
//axis = normalize(axis); // moved to calling function
|
||||
float s = sin(angle);
|
||||
float c = cos(angle);
|
||||
float oc = 1.0 - c;
|
||||
|
||||
return float3x3 (oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s,
|
||||
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s,
|
||||
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c);
|
||||
}
|
||||
|
||||
float4 SmoothCurve( float4 x ) {
|
||||
return x * x *( 3.0 - 2.0 * x );
|
||||
}
|
||||
float4 TriangleWave( float4 x ) {
|
||||
return abs( frac( x + 0.5 ) * 2.0 - 1.0 );
|
||||
}
|
||||
float4 SmoothTriangleWave( float4 x ) {
|
||||
return SmoothCurve( TriangleWave( x ) );
|
||||
}
|
||||
// Overloads for single float
|
||||
float SmoothCurve( float x ) {
|
||||
return x * x *( 3.0 - 2.0 * x );
|
||||
}
|
||||
float TriangleWave( float x ) {
|
||||
return abs( frac( x + 0.5 ) * 2.0 - 1.0 );
|
||||
}
|
||||
float SmoothTriangleWave( float x ) {
|
||||
return SmoothCurve( TriangleWave( x ) );
|
||||
}
|
||||
|
||||
half3 CTI_UnpackScaleNormal(half4 packednormal, half bumpScale)
|
||||
{
|
||||
half3 normal;
|
||||
normal.xy = (packednormal.wy * 2 - 1);
|
||||
#if (SHADER_TARGET >= 30)
|
||||
// SM2.0: instruction count limitation
|
||||
// SM2.0: normal scaler is not supported
|
||||
normal.xy *= bumpScale;
|
||||
#endif
|
||||
normal.z = sqrt(1.0f - saturate(dot(normal.xy, normal.xy)));
|
||||
return normal;
|
||||
}
|
||||
|
||||
float4 AfsSmoothTriangleWave( float4 x ) {
|
||||
return (SmoothCurve( TriangleWave( x )) - 0.5f) * 2.0f;
|
||||
}
|
||||
|
||||
void CTI_AnimateVertexSG_float(
|
||||
float3 PositionOS,
|
||||
half3 NormalOS,
|
||||
half4 VertexColor,
|
||||
float2 UV2,
|
||||
float3 UV3,
|
||||
|
||||
float leafNoise,
|
||||
|
||||
float3 baseWindMultipliers,
|
||||
|
||||
bool enableNormalRotation,
|
||||
|
||||
bool EnableAdvancedEdgeBending,
|
||||
float2 AdvancedEdgeBending,
|
||||
|
||||
float3 timeParams,
|
||||
|
||||
bool IsLeaves,
|
||||
|
||||
out float3 o_positionOS,
|
||||
out half3 o_normalOS,
|
||||
out half2 o_colorVariationAmbient
|
||||
|
||||
) {
|
||||
const float fDetailAmp = 0.1f;
|
||||
const float fBranchAmp = 0.3f;
|
||||
|
||||
#define Phase animParams.r
|
||||
#define Flutter animParams.g
|
||||
#define MainBending animParams.z
|
||||
#define BranchBending animParams.w
|
||||
|
||||
float4 animParams = float4(VertexColor.rg, UV2.xy);
|
||||
animParams.zwy *= baseWindMultipliers.xyz;
|
||||
|
||||
// Init output
|
||||
o_positionOS = PositionOS;
|
||||
o_normalOS = NormalOS;
|
||||
// Store ambient occlusion
|
||||
o_colorVariationAmbient = 0;
|
||||
|
||||
const float3 TreeWorldPos = UNITY_MATRIX_M._m03_m13_m23;
|
||||
|
||||
float sinuswave = sin(timeParams.x * 0.5);
|
||||
float shiftedsinuswave = (sinuswave + timeParams.y) * 0.5;
|
||||
|
||||
//#if defined (_LEAFTUMBLING)
|
||||
// float shiftedsinuswave = sin(_Time.y * 0.5 + _TimeOffset);
|
||||
// float4 vOscillations = SmoothTriangleWave(float4(TreeWorldPos.x + sinuswave, TreeWorldPos.z + sinuswave * 0.7, TreeWorldPos.x + shiftedsinuswave, TreeWorldPos.z + shiftedsinuswave * 0.8));
|
||||
//#else
|
||||
float4 vOscillations = SmoothTriangleWave(float4(TreeWorldPos.x + sinuswave, TreeWorldPos.z + sinuswave * 0.7, TreeWorldPos.x + shiftedsinuswave, TreeWorldPos.z + shiftedsinuswave * 0.8));
|
||||
//#endif
|
||||
|
||||
// x used for main wind bending / y used for tumbling
|
||||
float2 fOsc = vOscillations.xz + (vOscillations.yw * vOscillations.yw);
|
||||
fOsc = 0.75 + (fOsc + 3.33) * 0.33;
|
||||
|
||||
// float fObjPhase = abs(frac((TreeWorldPos.x + TreeWorldPos.z) * 0.5) * 2 - 1);
|
||||
// NOTE: We have to limit (frac) fObjPhase in case we use fBranchPhase in tumbling or turbulence
|
||||
float fObjPhase = dot(TreeWorldPos, 1);
|
||||
float fBranchPhase = fObjPhase + Phase;
|
||||
float fVtxPhase = dot(o_positionOS.xyz, Flutter + fBranchPhase);
|
||||
|
||||
// x is used for edges; y is used for branches
|
||||
float2 vWavesIn = timeParams.xx + float2(fVtxPhase, fBranchPhase );
|
||||
|
||||
// 1.975, 0.793, 0.375, 0.193 are good frequencies
|
||||
float4 vWaves = (frac( vWavesIn.xxyy * float4(1.975, 0.793, 0.375, 0.193) ) * 2.0 - 1.0);
|
||||
vWaves = SmoothTriangleWave( vWaves );
|
||||
float2 vWavesSum = vWaves.xz + vWaves.yw;
|
||||
|
||||
// Get local Wind
|
||||
#define absWindStrength _CTI_SRP_Wind.w
|
||||
|
||||
float turbulence = _CTI_SRP_Turbulence;
|
||||
float3 windDir = mul((float3x3)GetWorldToObjectMatrix(), _CTI_SRP_Wind.xyz);
|
||||
float4 Wind = float4(windDir, absWindStrength);
|
||||
|
||||
// Leaf specific bending
|
||||
if (IsLeaves)
|
||||
{
|
||||
float3 pivot;
|
||||
|
||||
// Decode UV3
|
||||
// 15bit compression 2 components only, important: sign of y
|
||||
pivot.xz = (frac(float2(1.0f, 32768.0f) * UV3.xx) * 2) - 1;
|
||||
pivot.y = sqrt(1 - saturate(dot(pivot.xz, pivot.xz)));
|
||||
pivot *= UV3.y;
|
||||
|
||||
half tumbleInfluence = frac(VertexColor.b * 2.0);
|
||||
|
||||
// Move point to 0,0,0
|
||||
o_positionOS.xyz -= pivot;
|
||||
|
||||
#if defined(_LEAFTUMBLING) || defined (_LEAFTURBULENCE)
|
||||
|
||||
float3 fracs = frac(pivot * 33.3);
|
||||
|
||||
//float offset = fracs.x + fracs.y + fracs.z; // /* this adds a lot of noise, so we use * 0.1 */ + (BranchBending + Phase) * leafNoise;
|
||||
|
||||
float offset = fracs.x + fracs.y + fracs.z /* this adds a lot of noise, so we use * 0.1 */ + (BranchBending + Phase) * leafNoise;
|
||||
float tFrequency = _TumbleFrequency * (timeParams.x + fObjPhase * 10.0 );
|
||||
float4 vWaves1 = SmoothTriangleWave( float4( (tFrequency + offset) * (1.0 + offset * 0.25), tFrequency * 0.75 + offset, tFrequency * 0.5 + offset, tFrequency * 1.5 + offset));
|
||||
|
||||
float3 windTangent = float3(-windDir.z, windDir.y, windDir.x);
|
||||
float twigPhase = vWaves1.x + vWaves1.y + (vWaves1.z * vWaves1.z);
|
||||
|
||||
#define packedBranchAxis UV3.z
|
||||
|
||||
//#if defined (_EMISSION)
|
||||
// This was the root of the fern issue: branchAxes slightly varied on different LODs!
|
||||
float3 branchAxis = frac( packedBranchAxis * float3(1.0, 256.0, 65536.0) );
|
||||
branchAxis = branchAxis * 2.0 - 1.0;
|
||||
branchAxis = normalize(branchAxis);
|
||||
// we can do better in case we have the baked branch main axis
|
||||
float facingWind = (dot(branchAxis, windDir));
|
||||
//#else
|
||||
// half facingWind = (dot(normalize(float3(v.positionOS.x, 0, v.positionOS.z)), windDir)); //saturate
|
||||
//#endif
|
||||
|
||||
|
||||
|
||||
//float localWindStrength = dot(abs(xWind.xyz), 1) * tumbleInfluence * (1.35 - facingWind) * xWind.w + absWindStrength; // Use abs(_Wind)!!!!!!
|
||||
half localWindStrength = (1.35h - facingWind) * tumbleInfluence * absWindStrength;
|
||||
|
||||
// tumbling
|
||||
#if defined(_LEAFTUMBLING)
|
||||
// float angleTumble =
|
||||
// (twigPhase + fBranchPhase * 0.25 + BranchBending)
|
||||
// * localWindStrength * tumbleStrength
|
||||
// * fOsc.y
|
||||
// ;
|
||||
// Let's keep it simple
|
||||
float angleTumble = (twigPhase + BranchBending) * localWindStrength * _TumbleStrength;
|
||||
|
||||
float3x3 tumbleRot = GetRotationMatrix( windTangent, angleTumble);
|
||||
o_positionOS.xyz = mul(tumbleRot, o_positionOS.xyz);
|
||||
if(enableNormalRotation)
|
||||
{
|
||||
o_normalOS = mul(tumbleRot, o_normalOS);
|
||||
}
|
||||
#endif
|
||||
|
||||
// turbulence
|
||||
#if defined (_LEAFTURBULENCE)
|
||||
// float angleTurbulence =
|
||||
// // center rotation so the leaves rotate leftwards as well as rightwards according to the incoming waves
|
||||
// ((twigPhase + vWaves1.w) * 0.25 - 0.5)
|
||||
// // make rotation strength depend on absWindStrength and all other inputs
|
||||
// * localWindStrength * leafTurbulence * saturate(lerp(1.0, Flutter * 8.0, _EdgeFlutterInfluence))
|
||||
// * fOsc.x
|
||||
// ;
|
||||
// Let's keep it simple
|
||||
float angleTurbulence =
|
||||
((twigPhase + vWaves1.w) * 0.25 - 0.5)
|
||||
* localWindStrength * _LeafTurbulence * saturate(lerp(1.0, Flutter * 8.0, _EdgeFlutterInfluence))
|
||||
;
|
||||
|
||||
float3x3 turbulenceRot = GetRotationMatrix( -branchAxis, angleTurbulence);
|
||||
o_positionOS.xyz = mul(turbulenceRot, o_positionOS.xyz);
|
||||
if(enableNormalRotation)
|
||||
{
|
||||
o_normalOS = mul(turbulenceRot, NormalOS);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// fade in/out leave planes
|
||||
// float lodfade = ceil(pos.w - 0.51);
|
||||
// asset store
|
||||
// float lodfade = (pos.w > 0.5) ? 1 : 0;
|
||||
// latest
|
||||
if (unity_LODFade.x < 1.0)
|
||||
{
|
||||
float lodfade = (VertexColor.b > (1.0f / 255.0f * 126.0f) ) ? 1 : 0; // Make sure that the 1st vertex is taken into account
|
||||
o_positionOS.xyz *= 1.0 - unity_LODFade.x * lodfade;
|
||||
}
|
||||
|
||||
// Move point back to origin
|
||||
o_positionOS.xyz += pivot;
|
||||
|
||||
// Advanced edge fluttering (has to be outside preserve length)
|
||||
if(EnableAdvancedEdgeBending)
|
||||
{
|
||||
o_positionOS.xyz += o_normalOS.xyz * SmoothTriangleWave( tumbleInfluence * timeParams.x * AdvancedEdgeBending.y + Phase ) * AdvancedEdgeBending.x * Flutter * absWindStrength;
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve Length
|
||||
float origLength = length(o_positionOS.xyz);
|
||||
|
||||
// Primary bending / Displace position
|
||||
o_positionOS.xyz += animParams.z * Wind.xyz * fOsc.x * absWindStrength ;
|
||||
|
||||
#if defined(_NORMALIZEBRANCH)
|
||||
// Preserve Length - good here but stretches real branches
|
||||
o_positionOS.xyz = normalize(o_positionOS.xyz) * origLength;
|
||||
#endif
|
||||
|
||||
// Apply secondary bending and edge flutter
|
||||
float3 bend = animParams.y * fDetailAmp * abs(o_normalOS.xyz);
|
||||
bend.y = animParams.w * fBranchAmp;
|
||||
o_positionOS.xyz += ((vWavesSum.xyx * bend) + (Wind.xyz * vWavesSum.y * animParams.w)) * absWindStrength * _CTI_SRP_Turbulence;
|
||||
|
||||
#if !defined(_NORMALIZEBRANCH)
|
||||
// Preserve Length - good here but stretches real branches
|
||||
o_positionOS.xyz = normalize(o_positionOS.xyz) * origLength;
|
||||
#endif
|
||||
|
||||
// Store Variation
|
||||
#if !defined(UNITY_PASS_SHADOWCASTER) && !defined(DEPTHONLYPASS)
|
||||
o_colorVariationAmbient.x = saturate ( ( frac(TreeWorldPos.x + TreeWorldPos.y + TreeWorldPos.z) + frac( (TreeWorldPos.x + TreeWorldPos.y + TreeWorldPos.z) * 3.3 ) ) * 0.5 );
|
||||
o_colorVariationAmbient.y = VertexColor.a;
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6edaaabf19fadfe4fa45576b1902b0c8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user