diff --git a/Assets/Fur/fur-leo2.png b/Assets/Fur/fur-leo2.png new file mode 100644 index 0000000..71e49c3 Binary files /dev/null and b/Assets/Fur/fur-leo2.png differ diff --git a/Assets/Fur/fur-leo2.png.meta b/Assets/Fur/fur-leo2.png.meta new file mode 100644 index 0000000..00dcae9 --- /dev/null +++ b/Assets/Fur/fur-leo2.png.meta @@ -0,0 +1,90 @@ +fileFormatVersion: 2 +guid: e30efced99f28894e8b9a878a8ff5817 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + 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: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + 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: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PickObject.cs b/Assets/PickObject.cs index 701c8f2..54472d8 100644 --- a/Assets/PickObject.cs +++ b/Assets/PickObject.cs @@ -26,6 +26,15 @@ public static void SetAlpha(this Material material, float value) color.a = value; material.color = color; } + + public static void SetColorFloat(this Material material, float value) + { + Color color = material.color; + color.r = value; + color.g = value; + color.b = value; + material.color = color; + } } @@ -45,22 +54,16 @@ public class PickObject : MonoBehaviour public Material baseMaterial; public Material shellMaterial; public Texture2D shellTexture; - //public bool export = false; public Button buttonFur; public GameObject infoText; - - // Start is called before the first frame update - void Start() - { - - } + public void createFur() { - //if (duplicate) + { float scaleX = 1, scaleY = 1, scaleZ = 1; float localY = 0.0f; @@ -72,7 +75,9 @@ public void createFur() scaleY = shellRoot.transform.localScale.y; scaleZ = shellRoot.transform.localScale.z; - //localY = shellRoot.transform.position.y; + //we just need to set the parent GameObject to have the same material (only useful for this demo) + Material m = Instantiate(baseMaterial); + objToDuplicate.GetComponent().sharedMaterial = m; } for (int i = 0; i < shellNumber; i++) @@ -85,44 +90,28 @@ public void createFur() shell.transform.localScale = new Vector3(scaleX, scaleY, scaleZ); Material m = Instantiate(shellMaterial); - //Material mat = new Material(Shader.Find("Standard"); m.SetAsFade(); Color color = m.color; - //Color color = new Color(1.0f, 1.0f, 1.0f, 1.0f); - color.r = 1.0f / shellNumber * i + colorStartingValue; - color.g = 1.0f / shellNumber * i + colorStartingValue; - color.b = 1.0f / shellNumber * i + colorStartingValue; + color.r = Mathf.Lerp(colorStartingValue, 1.0f, shellNumber); + color.g = Mathf.Lerp(colorStartingValue, 1.0f, shellNumber); + color.b = Mathf.Lerp(colorStartingValue, 1.0f, shellNumber); m.color = color; m.name = "Shell_" + i.ToString(); m.SetTexture("_MainTex", shellTexture); - //m.SetAlpha(1.0f - (1.0f / i)); - m.SetAlpha((1.0f / (i / 2))); - - if (i == 0) - { - Debug.Log("i: " + i + "Alpha value: " + color.a); - m.SetAlpha(0.9f); - } - if (i == 1) - { - Debug.Log("i: " + i + "Alpha value: " + color.a); - m.SetAlpha(0.75f); - } + + float layerCoeff = ((float)i) / ((float)shellNumber); + Debug.Log("layerCoeff: " + layerCoeff); + Debug.Log("Value: " + Mathf.Lerp(colorStartingValue, 1.0f, layerCoeff)); + + m.SetAlpha(Mathf.Lerp(colorStartingValue, 1.0f, layerCoeff)); shell.GetComponent().sharedMaterial = m; - //shell.GetComponent().material.SetAsFade(); - //shell.GetComponent().material.SetAlpha(1.0f - (1.0f / i)); - //shell.GetComponent().material.name = "Shell_" + i.ToString(); - //shell.GetComponent().material.SetTexture("_MainTex", shellTexture); - //shell.GetComponent().material.SetColor("_Color", color); - // shell.GetComponent().material.DisableKeyword("_EMISSION"); + shell.GetComponent().material.SetFloat("_Glossiness", Mathf.Lerp(colorStartingValue, 1.0f, layerCoeff) - 0.5f); } shellRoot.transform.parent = objToDuplicate.transform; - //objToDuplicate.transform.position = new Vector3(0.0f, 0.0f, 0.0f); - //shellRoot.transform.position = new Vector3(0.0f, 0.0f, 0.0f); Material mRoot = Instantiate(baseMaterial); shellRoot.GetComponent().material = mRoot; @@ -135,8 +124,6 @@ void Update() { if (Input.GetMouseButtonDown(0)) { - // Debug.Log("Mouse is down"); - RaycastHit hitInfo = new RaycastHit(); bool hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo); if (hit) @@ -145,27 +132,7 @@ void Update() buttonFur.interactable = true; infoText.SetActive(false); - /* Debug.Log("Hit " + hitInfo.transform.gameObject.name); - if (hitInfo.transform.gameObject.tag == "Construction") - { - Debug.Log("It's working!"); - } - else - { - Debug.Log("nopz"); - }*/ } - /*else - { - Debug.Log("No hit"); - } - Debug.Log("Mouse is down");*/ } - - - - - - } } diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index ba2caf4..cee7d71 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -329,7 +329,7 @@ MonoBehaviour: colorStartingValue: 0.75 baseMaterial: {fileID: 2100000, guid: f5e7e0376718e7045a0b807a6e2eb913, type: 2} shellMaterial: {fileID: 2100000, guid: df35f0ff42acccf46a46daaaaee8c136, type: 2} - shellTexture: {fileID: 2800000, guid: 166e04a991603c040ae1302e93068897, type: 3} + shellTexture: {fileID: 2800000, guid: e30efced99f28894e8b9a878a8ff5817, type: 3} buttonFur: {fileID: 1404210155} infoText: {fileID: 1206362163} --- !u!4 &683208518 @@ -775,7 +775,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} m_LocalRotation: {x: -0.22874412, y: 0.65991217, z: -0.22184816, w: -0.680423} - m_LocalPosition: {x: 6.2603693, y: 4.880243, z: 0.87538666} + m_LocalPosition: {x: 6, y: 4.880243, z: 0.87538666} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/standard_material.mat b/Assets/standard_material.mat index 79e931b..455a6dd 100644 --- a/Assets/standard_material.mat +++ b/Assets/standard_material.mat @@ -40,7 +40,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MainTex: - m_Texture: {fileID: 2800000, guid: 47d2d908061f54ba8bf31c9af00a9a3c, type: 3} + m_Texture: {fileID: 2800000, guid: e30efced99f28894e8b9a878a8ff5817, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MetallicGlossMap: diff --git a/Documentation/texture1.png b/Documentation/texture1.png new file mode 100644 index 0000000..ba82da5 Binary files /dev/null and b/Documentation/texture1.png differ diff --git a/Documentation/texture2.png b/Documentation/texture2.png new file mode 100644 index 0000000..55f70ff Binary files /dev/null and b/Documentation/texture2.png differ diff --git a/README.md b/README.md index 6afe326..2413ed3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ ![Fur Shell Example](Documentation/screen_shells1.png "") -# Quick’n’dirty Fur Shell Demo V1.0 +# Quick’n’dirty Fur Shell Demo V1.1 QnFurShell is a demo of the "sheel concept" for Fur rendering in 3D models. The app is made with Unity, and has been tested & run on Windows & OSX. +## Update 1.1 +Changed the way the fur alpha is set, as well as the base color. +![Image008](Documentation/texture1.png) +![Image009](Documentation/texture2.png) + ## System Requirements Unity 2018.3 or more (the script should work on lower version, but the minimum version I used was that one)