diff --git a/Assets/Emotions/Scripts/FaceAnimation.cs b/Assets/Emotions/Scripts/FaceAnimation.cs index e656c19..a6c5803 100644 --- a/Assets/Emotions/Scripts/FaceAnimation.cs +++ b/Assets/Emotions/Scripts/FaceAnimation.cs @@ -236,8 +236,7 @@ private void Start() LoadData(); } - [ExecuteInEditMode] - void Update() + void _Update() { if(_State==State.Play) { diff --git a/Assets/Emotions/Scripts/FurBallParams.cs b/Assets/Emotions/Scripts/FurBallParams.cs new file mode 100644 index 0000000..efa7a30 --- /dev/null +++ b/Assets/Emotions/Scripts/FurBallParams.cs @@ -0,0 +1,89 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace FurBall +{ + //[System.Serializable] + public class BaseParams : ScriptableObject + { + public float _Radius = 1; + public Vector3 _EyeUVR; + public float _EyeScale; + + [Range(-30.0f, 30.0f)] + public float _ULid_XY_Rot_Deg = 0; + [Range(-30.0f, 30.0f)] + public float _DLid_XY_Rot_Deg = 0; + + [Range(-10.0f, 10.0f)] + public float _ULid_YZ_Rot_Start_Deg = 0; + [Range(-10.0f, 10.0f)] + public float _DLid_YZ_Rot_Start_Deg = 0; + + [Range(-10.0f, 90.0f)] + public float _ULid_YZ_Rot_Range_Deg = 80; + [Range(-90.0f, 10.0f)] + public float _DLid_YZ_Rot_Range_Deg = -80; + + public Color _FurColor = Color.white; + } + + public class AniParams + { + public Vector3 _Pos = Vector3.zero; + public Quaternion _Rot = Quaternion.identity; + + + public float _Eye1Open = 1; + public float _Eye2Open = 1; + + } + + public class FurBallParams : MonoBehaviour + { + public BaseParams _baseParams; + + + Transform _trans; + Transform trans + { + get + { + if(_trans==null) + { + _trans = transform; + } + return _trans; + } + } + + Material _mat; + Material mat + { + get + { + if(_mat==null) + { + var mr = GetComponent(); + _mat = mr.sharedMaterial; + } + return _mat; + } + } + + [ContextMenu("SaveBaseParams")] + void saveBaseParams() + { + + } + + + + private void Update() + { + + } + + } +} diff --git a/Assets/Emotions/Scripts/FurBallParams.cs.meta b/Assets/Emotions/Scripts/FurBallParams.cs.meta new file mode 100644 index 0000000..103929a --- /dev/null +++ b/Assets/Emotions/Scripts/FurBallParams.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 372442555c619394092be7d04348066d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Emotions/Scripts/Utils.meta b/Assets/Emotions/Scripts/Utils.meta new file mode 100644 index 0000000..57a1ad4 --- /dev/null +++ b/Assets/Emotions/Scripts/Utils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6fd636dac1afee74191f0398f926cf43 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Emotions/Scripts/Utils/Utils.cs b/Assets/Emotions/Scripts/Utils/Utils.cs new file mode 100644 index 0000000..6dd2234 --- /dev/null +++ b/Assets/Emotions/Scripts/Utils/Utils.cs @@ -0,0 +1,61 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace FFUtils +{ + public static class Maths + { + public static Vector3 sphericalToCartesian(Vector3 uvr, Vector3 center) + { + Vector3 pos; + + uvr.x = Mathf.Clamp01(uvr.x); + uvr.y = Mathf.Clamp01(uvr.y); + uvr.x *= Mathf.PI; + uvr.y *= Mathf.PI; + + pos.x = Mathf.Sin(uvr.y) * Mathf.Cos(uvr.x); + pos.z = Mathf.Sin(uvr.y) * Mathf.Sin(uvr.x); + pos.y = Mathf.Cos(uvr.y); + pos *= uvr.z; + pos += center; + return pos; + } + } + + public class Mat_NameID + { + private string _Name; + private int _ID; + + public string Name + { + get + { + return _Name; + } + } + + public int ID + { + get + { + return _ID; + } + set + { + _ID = value; + } + } + + public Mat_NameID(string name) + { + _Name = name; + _ID = Shader.PropertyToID(_Name); + } + } + + +} + diff --git a/Assets/Emotions/Scripts/Utils/Utils.cs.meta b/Assets/Emotions/Scripts/Utils/Utils.cs.meta new file mode 100644 index 0000000..104d44f --- /dev/null +++ b/Assets/Emotions/Scripts/Utils/Utils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 57300eb5d6b38a3449c9504d2dac4373 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Emotions/Shaders.meta b/Assets/Emotions/Shaders.meta new file mode 100644 index 0000000..b1d401c --- /dev/null +++ b/Assets/Emotions/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a0d8b90cff9182146a9f6e83a85fbe89 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/fur.png b/Assets/Emotions/Shaders/fur.png similarity index 100% rename from Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/fur.png rename to Assets/Emotions/Shaders/fur.png diff --git a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/fur.png.meta b/Assets/Emotions/Shaders/fur.png.meta similarity index 100% rename from Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/fur.png.meta rename to Assets/Emotions/Shaders/fur.png.meta diff --git a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.hlsl b/Assets/Emotions/Shaders/furBall.hlsl similarity index 100% rename from Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.hlsl rename to Assets/Emotions/Shaders/furBall.hlsl diff --git a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.hlsl.meta b/Assets/Emotions/Shaders/furBall.hlsl.meta similarity index 100% rename from Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.hlsl.meta rename to Assets/Emotions/Shaders/furBall.hlsl.meta diff --git a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.mat b/Assets/Emotions/Shaders/furBall.mat similarity index 95% rename from Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.mat rename to Assets/Emotions/Shaders/furBall.mat index f511600..73977d5 100644 --- a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.mat +++ b/Assets/Emotions/Shaders/furBall.mat @@ -92,6 +92,8 @@ Material: - _DetailNormalMapScale: 1 - _DstBlend: 0 - _EnvironmentReflections: 1 + - _Eye1Open: 1 + - _Eye2Open: 1 - _EyelidThickness: 0.05 - _FurDepth: 0.362 - _FurDepthScale: 5 @@ -122,7 +124,7 @@ Material: - _BlockBall_Offset_Scale: {r: 0, g: 0, b: 0, a: 0.8} - _Color: {r: 1, g: 1, b: 1, a: 1} - _DownlidOffset: {r: 0, g: 0, b: 0, a: 1} - - _Downlid_Start_Range: {r: -1.8, g: 3.9, b: 0, a: 1} + - _Downlid_Start_Range: {r: 0, g: -0.9, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _Eyeball_Pos_Scale: {r: 0.22, g: 0, b: 0.35, a: 0.32} - _FurColor: {r: 1, g: 1, b: 1, a: 1} @@ -130,9 +132,9 @@ Material: - _IrisColor: {r: 0.089999996, g: 0.0315, b: 0.0135, a: 1} - _Iris_UV: {r: 0.5, g: 0.5, b: 0, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - - _UpDownLid_XYRot: {r: -0.6, g: 0.6, b: 0, a: 1} + - _UpDownLid_XYRot: {r: 0, g: 0, b: 0, a: 1} - _UplidOffset: {r: 0, g: -0.2, b: -0, a: 1} - - _Uplid_Start_Range: {r: 1.8, g: -3.9, b: 0, a: 1} + - _Uplid_Start_Range: {r: 0, g: 0.9, b: 0, a: 1} m_BuildTextureStacks: [] --- !u!114 &1260275427789698038 MonoBehaviour: diff --git a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.mat.meta b/Assets/Emotions/Shaders/furBall.mat.meta similarity index 100% rename from Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.mat.meta rename to Assets/Emotions/Shaders/furBall.mat.meta diff --git a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.shader b/Assets/Emotions/Shaders/furBall.shader similarity index 90% rename from Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.shader rename to Assets/Emotions/Shaders/furBall.shader index 9793c63..e1d9514 100644 --- a/Assets/uRaymarching/Examples/UniversalRP/Sphere Box Morph/furBall.shader +++ b/Assets/Emotions/Shaders/furBall.shader @@ -25,6 +25,9 @@ Shader "Unlit/furBall" _UpDownLid_XYRot("UpDownLid_XYRot",Vector) = (0.6,-0.6,0.0) + _Eye1Open("Eye1Open",Range(0,1)) = 0.5 + _Eye2Open("Eye2Open",Range(0,1)) = 0.5 + _Iris_UV("Iris_UV",Vector) = (0.5,0.5,0.0) _IrisColor("IrisColor", Color) = (0.09,0.0315,0.0135) _IrisSize("IrisSize", Range(0.1,1.0)) = 0.8 @@ -124,6 +127,8 @@ Shader "Unlit/furBall" float2 _HighlightOffset; float _AAScale; float4 _FurColor; + float _Eye1Open; + float _Eye2Open; float3 animData; @@ -267,31 +272,45 @@ Shader "Unlit/furBall" //return ret; - //eyelid - float3 oos = qos - _Eyeball_Pos_Scale.xyz*_Radius; - float d2 = sdSphere(oos,_Radius*(_Eyeball_Pos_Scale.w + _EyelidThickness)); - - oos += _UplidOffset * _Radius; + //eyelid1 + float3 posEye1 = pos - _Eyeball_Pos_Scale.xyz*_Radius; + float dLid1 = sdSphere(posEye1,_Radius*(_Eyeball_Pos_Scale.w + _EyelidThickness)); + + float3 posUpLid = posEye1; + posUpLid += _UplidOffset * _Radius; + posUpLid.xy = rot(posUpLid.xy, _UpDownLid_XYRot.x); + + float3 posDownLid = posEye1; + posDownLid += _DownlidOffset * _Radius; + posDownLid.xy = rot(posDownLid.xy, _UpDownLid_XYRot.y); + + posUpLid.yz = rot(posUpLid.yz,_Uplid_Start_Range.x+_Uplid_Start_Range.y*_Eye1Open); + posDownLid.yz = rot(posDownLid.yz,_Downlid_Start_Range.x+_Downlid_Start_Range.y*_Eye1Open); - // oos.z += 0.2; - // oos.y += -0.0; + dLid1 = smax(dLid1-0.005*_Radius, -max(posUpLid.y+0.098*_Radius,-posDownLid.y-0.025*_Radius), 0.06*_Radius ); - oos.xy = rot(oos.xy, _UpDownLid_XYRot.x); - oos.yz = rot(oos.yz,_Uplid_Start_Range.x+_Uplid_Start_Range.y*animData.x); + //eyelid2 + float3 posEye2 = pos - float3(-_Eyeball_Pos_Scale.x,_Eyeball_Pos_Scale.yz)*_Radius; + float dLid2 = sdSphere(posEye2,_Radius*(_Eyeball_Pos_Scale.w + _EyelidThickness)); - float3 eos = qos - _Eyeball_Pos_Scale.xyz*_Radius; + posUpLid = posEye2; + posUpLid += _UplidOffset * _Radius; + posUpLid.xy = rot(posUpLid.xy, -_UpDownLid_XYRot.x); - eos += _DownlidOffset * _Radius; - eos.xy = rot(eos.xy, _UpDownLid_XYRot.y); - eos.yz = rot(eos.yz,_Downlid_Start_Range.x+_Downlid_Start_Range.y*animData.x); + posDownLid = posEye2; + posDownLid += _DownlidOffset * _Radius; + posDownLid.xy = rot(posDownLid.xy, -_UpDownLid_XYRot.y); - d2 = smax(d2-0.005*_Radius, -max(oos.y+0.098*_Radius,-eos.y-0.025*_Radius), 0.06*_Radius ); - d2 = smin(d2,d,0.1*_Radius); - // d2 = min(d2,d); + posUpLid.yz = rot(posUpLid.yz,_Uplid_Start_Range.x+_Uplid_Start_Range.y*_Eye2Open); + posDownLid.yz = rot(posDownLid.yz,_Downlid_Start_Range.x+_Downlid_Start_Range.y*_Eye2Open); - //d2 = d; + dLid2 = smax(dLid2-0.005*_Radius, -max(posUpLid.y+0.098*_Radius,-posDownLid.y-0.025*_Radius), 0.06*_Radius ); - ret.x = d2; + float dLid = smin(dLid1,dLid2,0.1*_Radius); + + d = smin(dLid,d,0.1*_Radius); + + ret.x = d; outMat = 1.0; uvw = pos; @@ -299,7 +318,7 @@ Shader "Unlit/furBall" //eyeball // pos.x /= 1.05; - eos = qos-_Eyeball_Pos_Scale.xyz*_Radius; + float3 eos = qos-_Eyeball_Pos_Scale.xyz*_Radius; d = sdSphere(eos,_Eyeball_Pos_Scale.w*_Radius); if(d