Example #1
0
        public static void LoadMaterials(List <Material> materials)
        {
            lib = materials.ToDictionary(
                kv => kv.Id,
                kv => kv
                );

            matLib = materials.ToDictionary(
                kv => kv.Id,
                kv =>
            {
                var mat   = new UnityEngine.Material(UnityEngine.Shader.Find("Universal Render Pipeline/Lit"));
                mat.name  = kv.Name;
                mat.color = new UnityEngine.Color(
                    kv.Color.Red / 255f,
                    kv.Color.Green / 255f,
                    kv.Color.Blue / 255f,
                    (100 - kv.Transparency) / 100f
                    );
                if (mat.name.Contains("Glass"))
                {
                    mat.color = new UnityEngine.Color(
                        185 / 255f,
                        185 / 255f,
                        224 / 255f,
                        10 / 255f
                        );
                }
                if (kv.Transparency > 0)
                {
                    mat.SetFloat("_Surface", 1);
                    mat.SetFloat("_Blend", 0);
                    mat.SetOverrideTag("RenderType", "Transparent");
                    mat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
                    mat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                    mat.SetInt("_ZWrite", 0);
                    mat.DisableKeyword("_ALPHAPREMULTIPLY_ON");
                    mat.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
                    mat.SetShaderPassEnabled("ShadowCaster", false);
                }
                mat.SetFloat("_Metallic", (float)kv.Shininess / byte.MaxValue);
                mat.SetFloat("_Smoothness", (float)kv.Smoothness / byte.MaxValue);
                return(mat);
            }
                );
        }
Example #2
0
        private void SetAnimation(ref Animator animator, Entity e)
        {
            if (animator.data.Length <= 1)
            {
                if (animator.data.Length == 0)
                {
                    //UnityEngine.Debug.LogError("Animator for entity doesnt have animations.");
                }
                return;
            }
            int animationIndex = 0;

            if (animator.isWalking == 0)
            {
                animationIndex = 0;
            }
            else
            {
                if (animator.data.Length > 1)
                {
                    animationIndex = 1;
                }
            }
            float      timeBegun = UnityEngine.Time.time;
            RenderMesh renderer;
            //UnityEngine.Debug.LogError("Setting new Animation to: " + animationIndex);
            int   framesAddition  = GetFramesAddition(ref animator, animationIndex);
            float animationTime   = (animator.data[animationIndex].time);
            int   framesPerSecond = (animator.data[animationIndex].frames);

            renderer = World.EntityManager.GetSharedComponentData <RenderMesh>(e);
            UnityEngine.Material material = (renderer.material); // new Material
            material.SetFloat("_TimeBegun", timeBegun);
            material.SetFloat("_AnimationTime", animationTime);
            material.SetInt("_FramesAddition", framesAddition);
            material.SetInt("_FramesPerSecond", framesPerSecond);
            //material.SetInt("_AnimationSpeed", 1);
            renderer.material = material;
            World.EntityManager.SetSharedComponentData(e, renderer);
        }
Example #3
0
        static StackObject *SetFloat_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Single @value = *(float *)&ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @name = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            UnityEngine.Material instance_of_this_method = (UnityEngine.Material) typeof(UnityEngine.Material).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.SetFloat(@name, @value);

            return(__ret);
        }
Example #4
0
        private static IEnumerator ResolveMaterialTexture(string id)
        {
            Common.Models.Material mat = GetMaterial(id);
            if (mat == null)
            {
                UnityEngine.Debug.Log($"MATERIAL {id} DOES NOT EXIST");
                _totalCalls--;
                yield return(null);

                yield break;
            }

            string url = $"{_ModelServerURL}/api/material/{mat.Id}";

            UnityEngine.Texture materialTexture = null;

            UnityEngine.Debug.Log(url);
            using (UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(url))
            {
                yield return(webRequest.SendWebRequest());

                if (webRequest.isNetworkError)
                {
                    UnityEngine.Debug.Log("Error: " + webRequest.error);
                    yield return(null);

                    _totalCalls--;
                    yield break;
                }
                else if (webRequest.isHttpError)
                {
                    // UnityEngine.Debug.Log("Error: " + webRequest.error);
                    yield return(null);

                    _totalCalls--;
                    yield break;
                }
                else
                {
                    materialTexture = ((DownloadHandlerTexture)webRequest.downloadHandler).texture;
                }
            }

            if (materialTexture != null)
            {
                UnityEngine.Material baseMaterial = LookupMaterial(mat.Id);

                UnityEngine.Material newMaterial = new UnityEngine.Material(baseMaterial.shader);

                newMaterial.CopyPropertiesFromMaterial(baseMaterial);

                newMaterial.name        = mat.Name + " (With Texture)";
                newMaterial.mainTexture = materialTexture;
                newMaterial.color       = new UnityEngine.Color(
                    220f / 255f,
                    220f / 255f,
                    220f / 255f
                    );
                newMaterial.SetFloat("_Metallic", (float)mat.Shininess / byte.MaxValue);
                newMaterial.SetFloat("_Smoothness", (float)mat.Smoothness / byte.MaxValue);

                matLib.Add("_" + id, newMaterial);

                UnityEngine.Debug.Log(JsonConvert.SerializeObject(mat));

                // UnityEngine.GameObject.Find("Test").GetComponent<UnityEngine.MeshRenderer>().material = newMaterial;
            }

            _totalCalls--;
        }
Example #5
0
 public override void Set(string propertyName, float value)
 {
     material.SetFloat(propertyName, value);
 }
Example #6
0
 public void Test(UnityEngine.Material material)
 {
     material.SetFloat("t{caret}est", 10.0f);
 }
Example #7
0
 /////////////////
 // System      //
 /////////////////
 /// <summary>
 /// This function should be called after changing the Albedo Map or AlphaCutoff Properties.
 /// It makes sure that baked system shadows work correctly with alpha clipping.
 /// </summary>
 /// <param name="material"></param>
 public static void UpdateSystemProperties(UnityEngine.Material material)
 {
     material.SetTexture(Uniforms.mainTex.id, Properties.albedoMap.GetValue(material));
     material.SetFloat(Uniforms.cutoff.id, Properties.alphaCutoff.GetValue(material));
 }
 private void OnRenderImage(DisguiseyBoi normalBoi, DisguiseyBoi whereWeDropping)
 {
     seizurePlease.SetFloat("_RainbowBoi", rainbowBoi);
     PixellyBoi.Blit(normalBoi, whereWeDropping, seizurePlease);
 }