Пример #1
0
        public static BitmapTag GetBitmap(this ShaderTag.ShaderTemplateArguments args, H2vMap map, int?index)
        {
            if (index.HasValue == false)
            {
                return(null);
            }

            if (map.TryGetTag(args.BitmapArguments[index.Value].Bitmap, out var bitm))
            {
                return(bitm);
            }

            return(null);
        }
Пример #2
0
        public static Vector4 GetInput(this ShaderTag.ShaderTemplateArguments args, int?index, Vector4 defaultValue = default)
        {
            if (defaultValue == default)
            {
                defaultValue = new Vector4(1, 1, 0, 0);
            }

            if (index.HasValue == false)
            {
                return(defaultValue);
            }

            if (index.Value >= args.ShaderInputs.Length)
            {
                return(defaultValue);
            }

            return(args.ShaderInputs[index.Value]);
        }
Пример #3
0
        private void PopulateFromMapping(
            H2vMap map,
            Material <BitmapTag> mat,
            ShaderTag.ShaderTemplateArguments args,
            MaterialMapping mapping)
        {
            mat.NormalMap      = args.GetBitmap(map, mapping.NormalMapIndex);
            mat.NormalMapScale = args.GetInput(mapping.NormalScaleIndex);

            mat.DiffuseMap = args.GetBitmap(map, mapping.DiffuseMapIndex);

            if (mapping.DiffuseColor.Length == 4)
            {
                mat.DiffuseColor = new Vector4(mapping.DiffuseColor[0], mapping.DiffuseColor[1], mapping.DiffuseColor[2], mapping.DiffuseColor[3]);
            }
            else if (mapping.DiffuseColor.Length == 1)
            {
                mat.DiffuseColor = new Vector4(mapping.DiffuseColor[0]);
            }

            mat.DetailMap1   = args.GetBitmap(map, mapping.Detail1MapIndex);
            mat.Detail1Scale = args.GetInput(mapping.Detail1ScaleIndex);

            mat.DetailMap2   = args.GetBitmap(map, mapping.Detail2MapIndex);
            mat.Detail2Scale = args.GetInput(mapping.Detail2ScaleIndex);

            mat.EmissiveMap       = args.GetBitmap(map, mapping.EmissiveMapIndex);
            mat.EmissiveArguments = args.GetInput(mapping.EmissiveArgumentsIndex);
            mat.EmissiveType      = mapping.EmissiveType;

            mat.AlphaMap     = args.GetBitmap(map, mapping.AlphaMapIndex);
            mat.AlphaFromRed = mapping.AlphaFromRed;

            mat.ColorChangeMask = args.GetBitmap(map, mapping.ColorChangeMaskMapIndex);

            mat.SpecularMap = args.GetBitmap(map, mapping.SpecularMapIndex);
        }