Esempio n. 1
0
        /// <summary>
        /// Create a CyclesShader based on given Material m
        /// </summary>
        /// <param name="rm">Material to convert to CyclesShader</param>
        /// <param name="gamma">gamma to use for this shader</param>
        /// <returns>The CyclesShader</returns>
        internal CyclesShader CreateCyclesShader(RenderMaterial rm, float gamma)
        {
            var mid    = rm.RenderHash;
            var shader = new CyclesShader(mid);

            shader.Type = CyclesShader.Shader.Diffuse;

            RenderMaterial front;

            if (rm.TypeId.Equals(realtimDisplaMaterialId))
            {
                if (rm.FirstChild?.ChildSlotName?.Equals("front") ?? false)
                {
                    front = rm.FirstChild as RenderMaterial;
                    shader.CreateFrontShader(front, gamma);
                }
                if (rm.FirstChild?.NextSibling?.ChildSlotName?.Equals("back") ?? false)
                {
                    var back = rm.FirstChild.NextSibling as RenderMaterial;
                    shader.CreateBackShader(back, gamma);
                }
            }
            else
            {
                front = rm;
                shader.CreateFrontShader(front, gamma);
            }

            return(shader);
        }