Ejemplo n.º 1
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Clipper() : base()
 {
     _sampler2         = new EffectSampler(this);
     _sampler2.Name    = "Mask";
     _sampler2.Comment = "The opacity mask brush";
     Samplers.Add(_sampler2);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public Subtractor() : base()
        {
            _gain2    = new EffectProperty(this);
            _sampler2 = new EffectSampler(this);

            _sampler2.Name    = "Input2";
            _sampler2.Comment = "A brush to substract from the original element.";
            Samplers.Add(_sampler2);

            _gain2.Name         = "Gain2";
            _gain2.WrapperType  = typeof(double);
            _gain2.DefaultValue = "1.0";
            Properties.Add(_gain2);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public Mixer() : base()
        {
            _gain1    = new EffectProperty(this);
            _gain2    = new EffectProperty(this);
            _sampler2 = new EffectSampler(this);

            _sampler2.Name    = "Input2";
            _sampler2.Comment = "A brush to mix with the original element.";
            Samplers.Add(_sampler2);

            _gain1.Name         = "Gain1";
            _gain1.WrapperType  = typeof(double);
            _gain1.DefaultValue = "0.5";
            Properties.Add(_gain1);

            _gain2.Name         = "Gain2";
            _gain2.WrapperType  = typeof(double);
            _gain2.DefaultValue = "0.5";
            Properties.Add(_gain2);
        }
Ejemplo n.º 4
0
            public void CreateSampler(string Name, bool IsConstant)
            {
                var mat = MaterialAnimData;

                var SamplerInfo = new TexturePatternAnimInfo();

                if (IsConstant)
                {
                    SamplerInfo.BeginConstant = (ushort)mat.Constants.Count;
                    SamplerInfo.CurveIndex    = (ushort)65535;
                }
                else
                {
                    SamplerInfo.BeginConstant = (ushort)65535;
                    SamplerInfo.CurveIndex    = (ushort)mat.Curves.Count;
                }
                mat.TexturePatternAnimInfos.Add(SamplerInfo);

                BfresSamplerAnim sampler = new BfresSamplerAnim(SamplerInfo.Name, matAnimWrapper, this);

                Samplers.Add(sampler);
            }
Ejemplo n.º 5
0
        /*
         * public byte[] GetBuffer(int bufferIndex)
         * {
         *  return FileChunks[bufferIndex + 1].Data;
         * }
         */

        public void ParseJSON(string JSONstring)
        {
            var json = JsonConvert.DeserializeObject <dynamic>(JSONstring);

            foreach (var bufferViewJSON in json.bufferViews)
            {
                GLBBufferView bufferView = new GLBBufferView();

                bufferView.Buffer     = FileChunks[(int)bufferViewJSON.buffer + 1].Data;
                bufferView.ByteOffset = bufferViewJSON.byteOffset;
                bufferView.ByteLength = bufferViewJSON.byteLength;
                bufferView.Target     = bufferViewJSON.target;

                BufferViews.Add(bufferView);
            }

            foreach (var accessorJSON in json.accessors)
            {
                GLBAccessor accessor = new GLBAccessor();

                accessor.BufferView    = BufferViews[(int)accessorJSON.bufferView];
                accessor.ComponentType = accessorJSON.componentType;
                accessor.Count         = accessorJSON.count;
                accessor.Type          = accessorJSON.type;

                Accessors.Add(accessor);
            }

            foreach (var imageJSON in json.images)
            {
                GLBImage image = new GLBImage();

                image.BufferView = BufferViews[(int)imageJSON.bufferView];
                image.MimeType   = imageJSON.mimeType;

                Images.Add(image);
            }

            foreach (var samplerJSON in json.samplers)
            {
                GLBSampler sampler = new GLBSampler();

                sampler.MinFilter = samplerJSON.minFilter;
                sampler.MagFilter = samplerJSON.magFilter;
                sampler.WrapS     = samplerJSON.wrapS;
                sampler.WrapT     = samplerJSON.wrapT;

                Samplers.Add(sampler);
            }

            foreach (var textureJSON in json.textures)
            {
                GLBTexture texture = new GLBTexture();

                texture.Source  = Images[(int)textureJSON.source];
                texture.Sampler = Samplers[(int)textureJSON.sampler];

                Textures.Add(texture);
            }

            foreach (var materialJSON in json.materials)
            {
                GLBMaterial material = new GLBMaterial();

                material.Name = materialJSON.name;

                Materials.Add(material);
            }

            foreach (var meshJSON in json.meshes)
            {
                GLBMesh mesh = new GLBMesh();

                mesh.Name = meshJSON.name;

                foreach (var primitiveJSON in meshJSON.primitives)
                {
                    GLBPrimitive primitive = new GLBPrimitive();

                    GLBAttributes attributes = new GLBAttributes();

                    attributes.Position = Accessors[(int)primitiveJSON.attributes.POSITION];
                    attributes.Normal   = Accessors[(int)primitiveJSON.attributes.NORMAL];

                    primitive.Attributes = attributes;
                    primitive.Indices    = Accessors[(int)primitiveJSON.indices];
                    primitive.Material   = Materials[(int)primitiveJSON.material];

                    mesh.Primitives.Add(primitive);
                }

                Meshes.Add(mesh);
            }
        }
Ejemplo n.º 6
0
        public void Reload(Material material)
        {
            ShaderArchive = "";
            ShaderModel   = "";
            ShaderParams.Clear();
            ShaderOptions.Clear();
            Samplers.Clear();
            TextureMaps.Clear();

            UpdateRenderState();

            if (material.ShaderAssign != null)
            {
                ShaderArchive = material.ShaderAssign.ShaderArchiveName;
                ShaderModel   = material.ShaderAssign.ShadingModelName;
            }

            foreach (var param in material.ShaderParams)
            {
                ShaderParams.Add(param.Key, param.Value);
            }
            foreach (var option in material.ShaderAssign.ShaderOptions)
            {
                ShaderOptions.Add(option.Key, option.Value);
            }

            // if (ShaderParams.ContainsKey("gsys_i_color_ratio0"))
            //   ShaderParams["gsys_i_color_ratio0"].DataValue = 0.1f;

            for (int i = 0; i < material.TextureRefs.Count; i++)
            {
                string  name        = material.TextureRefs[i].Name;
                Sampler sampler     = material.Samplers[i];
                var     texSampler  = material.Samplers[i].TexSampler;
                string  samplerName = sampler.Name;
                string  fragSampler = "";

                //Force frag shader sampler to be used
                if (material.ShaderAssign.SamplerAssigns.ContainsValue(samplerName))
                {
                    material.ShaderAssign.SamplerAssigns.TryGetKey(samplerName, out fragSampler);
                }

                Samplers.Add(fragSampler);

                this.TextureMaps.Add(new TextureMap()
                {
                    Name      = name,
                    Sampler   = samplerName,
                    MagFilter = GXConverter.ConvertMagFilter(texSampler.MagFilter),
                    MinFilter = GXConverter.ConvertMinFilter(
                        texSampler.MipFilter,
                        texSampler.MinFilter),
                    Type    = GetTextureType(fragSampler),
                    WrapU   = GXConverter.ConvertWrapMode(texSampler.ClampX),
                    WrapV   = GXConverter.ConvertWrapMode(texSampler.ClampY),
                    LODBias = texSampler.LodBias,
                    MaxLOD  = texSampler.MaxLod,
                    MinLOD  = texSampler.MinLod,
                });
            }
        }