private static Block GetLitTextureShaderBlock(Shader shader) { var w = new BlockWriter(); w.WriteString(shader.Name); // shader name w.WriteU32(1); // Lit texture shader attributes: 1 = Lights enabled w.WriteF32(0f); // Alpha Test Reference w.WriteU32(0x00000617); // Alpha Test Function: ALWAYS w.WriteU32(0x00000605); // Color Blend Function: FB_MULTIPLY w.WriteU32(1); // Render pass enabled flags w.WriteU32(string.IsNullOrEmpty(shader.Texture) ? 0u : 1u); // Shader channels (active texture count) w.WriteU32(0); // Alpha texture channels w.WriteString(shader.Material); // Material name // Texture information. if (!string.IsNullOrEmpty(shader.Texture)) { w.WriteString(shader.Texture); // Texture name w.WriteF32(1f); // Texture Intensity w.WriteU8(0); // Blend function: 0 - Multiply w.WriteU8(1); // Blend Source, 1 - blending constant w.WriteF32(1f); // Blend Constant w.WriteU8(0x00); // Texture Mod; 0x00: TM_NONE; shader should use texture coordinates of the model w.WriteArray(Matrix4.GetIdentityMatrix().ToArray()); // Texture Transform Matrix Element w.WriteArray(Matrix4.GetIdentityMatrix().ToArray()); // Texture Wrap Transform Matrix Element w.WriteU8(0x03); // Texture Repeat } return(w.GetBlock(BlockType.LitTextureShader)); }
private static Block GetTextureDeclarationBlock(Texture texture) { var w = new BlockWriter(); w.WriteString(texture.Name); // texture name // Texture image format. w.WriteU32(0); // texture height w.WriteU32(0); // texture width w.WriteU8(0x0F); // texture image type, 0x0F - color RGBA w.WriteU32(1); // continuation image count // Continuation image format. w.WriteU8((byte)texture.ImageFormat); // compression type, 0x01 - JPEG-24, 0x02 - PNG, 0x03 - JPEG-8, 0x04 - TIFF w.WriteU8(0x0F); // texture image channels, 0x0F: alpha, red, green, blue w.WriteU16(0x0000); // continuation image attributes, 0x0000 - default attributes w.WriteU32((uint)texture.Image.Length); // image data byte count return(w.GetBlock(BlockType.TextureDeclaration)); }
private static Block GetTextureContinuationBlock(Texture texture) { var w = new BlockWriter(); w.WriteString(texture.Name); // texture name w.WriteU32(0); // continuation image index // Image data. foreach (byte b in texture.Image) { w.WriteU8(b); } return(w.GetBlock(BlockType.TextureContinuation)); }