アセット選定
This commit is contained in:
@@ -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:
|
||||
Reference in New Issue
Block a user