Esempio n. 1
0
    public ShaderAndBytecode <VertexShader> GetVertexShader <T>(string shaderName)
    {
        var key = new ShaderKey(typeof(T), shaderName);

        return(GetOrMake(vertexShaders, key, () => {
            var bytecode = LoadBytesFromResource <T>(shaderName + VertexShaderExtension);
            var shader = new VertexShader(device, bytecode);
            return new ShaderAndBytecode <VertexShader>(shader, bytecode);
        }));
    }
Esempio n. 2
0
 public bool Equals(ShaderKey other)
 {
     return(this.type == other.type && this.name == other.name);
 }
        public void Deserialize(Stream input)
        {
            this.Version = input.ReadValueU32();
            if (this.Version < 2 || this.Version > 6)
            {
                throw new FormatException();
            }

            List <ResourceKey> keyTable = null;

            if (this.Version >= 3)
            {
                keyTable = new List <ResourceKey>();

                long keyTableOffset   = input.ReadValueU32();
                long originalPosition = input.Position;
                long keyTableSize     = input.ReadValueU32();

                input.Seek(originalPosition + keyTableOffset, SeekOrigin.Begin);

                var count = input.ReadValueU32();
                for (uint i = 0; i < count; i++)
                {
                    keyTable.Add(input.ReadResourceKeyTGI());
                }

                input.Seek(originalPosition + 4, SeekOrigin.Begin);
            }

            this.ShaderKeys.Clear();
            {
                var count = input.ReadValueU32();
                for (uint i = 0; i < count; i++)
                {
                    var shaderKey = new ShaderKey();
                    shaderKey.Deserialize(input);
                    this.ShaderKeys.Add(shaderKey);
                }
            }

            if (this.Version >= 3)
            {
                this.SkinRamp    = keyTable[input.ReadValueS32()];
                this.ScatterRamp = keyTable[input.ReadValueS32()];
            }
            else
            {
                this.SkinRamp    = input.ReadResourceKeyIGT();
                this.ScatterRamp = input.ReadResourceKeyIGT();
            }

            this.TextureKeys.Clear();
            {
                var count = input.ReadValueU32();
                for (int i = 0; i < count; i++)
                {
                    var textureKey = new TextureKey();
                    textureKey.Deserialize(input, this.Version, keyTable);
                    this.TextureKeys.Add(textureKey);
                }
            }
        }