Beispiel #1
0
        public DrawContext(DeviceContext context, CommonInitParam initParam)
        {
            m_initParam = initParam;
            m_context   = context;

            var d3d = m_initParam.D3D;

            m_mainVtxConst         = DrawUtil.CreateConstantBuffer <_VertexShaderConst_Main>(d3d, m_maxInstanceCount);
            m_boneVtxConst         = DrawUtil.CreateConstantBuffer(d3d, Utilities.SizeOf <Matrix>() * MaxBoneMatrices);
            m_modelVtxConst        = DrawUtil.CreateConstantBuffer <_VertexShaderConst_Model>(d3d, 1);
            m_mainPixConst         = DrawUtil.CreateConstantBuffer <_PixelShaderConst_Main>(d3d, m_maxInstanceCount);
            m_modelPixConst        = DrawUtil.CreateConstantBuffer <_PixelShaderConst_Model>(d3d, 1);
            m_modelMinimapPixConst = DrawUtil.CreateConstantBuffer <_PixelShaderConst_ModelMinimap>(d3d, 1);

            m_instanceMainVtxConst = new _VertexShaderConst_Main[m_maxInstanceCount];
            m_instanceMainPixConst = new _PixelShaderConst_Main[m_maxInstanceCount];

            m_lastTextureSlots = new _TextureSlot[2];
            for (int index = 0; index < m_lastTextureSlots.Count(); ++index)
            {
                m_lastTextureSlots[index] = _TextureSlot.Create(index);
            }
        }
Beispiel #2
0
        public static DrawModel CreateFrustum(String uid, Matrix viewProjectionMatrix, Color4 color)
        {
            var drawSys = DrawSystem.GetInstance();
            var d3d     = drawSys.D3D;

            viewProjectionMatrix.Invert();

            var points = new Vector4[8];

            points[0] = Vector3.Transform(new Vector3(-1, -1, 0), viewProjectionMatrix);
            points[1] = Vector3.Transform(new Vector3(1, -1, 0), viewProjectionMatrix);
            points[2] = Vector3.Transform(new Vector3(-1, 1, 0), viewProjectionMatrix);
            points[3] = Vector3.Transform(new Vector3(1, 1, 0), viewProjectionMatrix);
            points[4] = Vector3.Transform(new Vector3(-1, -1, 1), viewProjectionMatrix);
            points[5] = Vector3.Transform(new Vector3(1, -1, 1), viewProjectionMatrix);
            points[6] = Vector3.Transform(new Vector3(-1, 1, 1), viewProjectionMatrix);
            points[7] = Vector3.Transform(new Vector3(1, 1, 1), viewProjectionMatrix);

            var vertices = new _VertexDebug[]
            {
                new _VertexDebug()
                {
                    Position = points[0]
                },
                new _VertexDebug()
                {
                    Position = points[1]
                },
                new _VertexDebug()
                {
                    Position = points[1]
                },
                new _VertexDebug()
                {
                    Position = points[3]
                },
                new _VertexDebug()
                {
                    Position = points[3]
                },
                new _VertexDebug()
                {
                    Position = points[2]
                },
                new _VertexDebug()
                {
                    Position = points[2]
                },
                new _VertexDebug()
                {
                    Position = points[0]
                },

                new _VertexDebug()
                {
                    Position = points[4]
                },
                new _VertexDebug()
                {
                    Position = points[5]
                },
                new _VertexDebug()
                {
                    Position = points[5]
                },
                new _VertexDebug()
                {
                    Position = points[7]
                },
                new _VertexDebug()
                {
                    Position = points[7]
                },
                new _VertexDebug()
                {
                    Position = points[6]
                },
                new _VertexDebug()
                {
                    Position = points[6]
                },
                new _VertexDebug()
                {
                    Position = points[4]
                },

                new _VertexDebug()
                {
                    Position = points[0]
                },
                new _VertexDebug()
                {
                    Position = points[4]
                },
                new _VertexDebug()
                {
                    Position = points[1]
                },
                new _VertexDebug()
                {
                    Position = points[5]
                },
                new _VertexDebug()
                {
                    Position = points[2]
                },
                new _VertexDebug()
                {
                    Position = points[6]
                },
                new _VertexDebug()
                {
                    Position = points[3]
                },
                new _VertexDebug()
                {
                    Position = points[7]
                },
            };

            Aabb aabb = Aabb.Invalid();

            for (int i = 0; i < vertices.Length; ++i)
            {
                vertices[i].Position.X /= vertices[i].Position.W;
                vertices[i].Position.Y /= vertices[i].Position.W;
                vertices[i].Position.Z /= vertices[i].Position.W;
                vertices[i].Position.W  = 1;
                vertices[i].Color       = color;
                aabb.ExtendByPoint(MathUtil.ToVector3(vertices[i].Position));
            }

            var model = new DrawModel(uid);

            model.m_nodeList.Add(new Node()
            {
                Mesh     = DrawUtil.CreateMeshData <_VertexDebug>(d3d, PrimitiveTopology.LineList, vertices),
                Material = DebugMaterial.Create(),
                IsDebug  = true,
                HasBone  = false,
            });
            model.m_bb = aabb;

            return(model);
        }
Beispiel #3
0
        public static DrawModel CreateBox(String uid, Aabb box, Color4 color)
        {
            var drawSys = DrawSystem.GetInstance();
            var d3d     = drawSys.D3D;

            Vector3 min      = box.Min;
            Vector3 max      = box.Max;
            var     vertices = new _VertexDebug[]
            {
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, min.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, min.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, min.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, min.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, min.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, min.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, min.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, min.Y, min.Z, 1)
                },

                new _VertexDebug()
                {
                    Position = new Vector4(min.X, min.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, max.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, min.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, max.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, min.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, max.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, min.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, max.Y, max.Z, 1)
                },

                new _VertexDebug()
                {
                    Position = new Vector4(min.X, max.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, max.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, max.Y, min.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, max.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(max.X, max.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, max.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, max.Y, max.Z, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(min.X, max.Y, min.Z, 1)
                },
            };

            Aabb aabb = Aabb.Invalid();

            for (int i = 0; i < vertices.Length; ++i)
            {
                vertices[i].Position.W = 1;
                vertices[i].Color      = color;
                aabb.ExtendByPoint(MathUtil.ToVector3(vertices[i].Position));
            }

            var model = new DrawModel(uid);

            model.m_nodeList.Add(new Node()
            {
                Mesh     = DrawUtil.CreateMeshData <_VertexDebug>(d3d, PrimitiveTopology.LineList, vertices),
                Material = DebugMaterial.Create(),
                IsDebug  = true,
                HasBone  = false,
            });
            model.m_bb = aabb;

            return(model);
        }
Beispiel #4
0
        public static DrawModel CreateBone(String uid, float length, Color4 color, Vector4 offset)
        {
            var   drawSys = DrawSystem.GetInstance();
            var   d3d     = drawSys.D3D;
            float w       = 0.1f * length;
            float L       = length;

            var vertices = new _VertexDebug[]
            {
                // bottom pyramid
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, 0, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, 0, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, 0, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, 0, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(w, w, w, 1)
                },

                // middle plane
                new _VertexDebug()
                {
                    Position = new Vector4(w, w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(w, w, w, 1)
                },

                // top pyramid
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, L, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, L, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(w, -w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, L, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(-w, w, w, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(0, 0, L, 1)
                },
                new _VertexDebug()
                {
                    Position = new Vector4(w, w, w, 1)
                },
            };

            Aabb aabb = Aabb.Invalid();

            for (int i = 0; i < vertices.Length; ++i)
            {
                vertices[i].Position  += offset;
                vertices[i].Position.W = 1;
                vertices[i].Color      = color;
                aabb.ExtendByPoint(MathUtil.ToVector3(vertices[i].Position));
            }

            var model = new DrawModel(uid);

            model.m_nodeList.Add(new Node()
            {
                Mesh     = DrawUtil.CreateMeshData <_VertexDebug>(d3d, PrimitiveTopology.LineList, vertices),
                Material = DebugMaterial.Create(),
                IsDebug  = true,
                HasBone  = false,
            });
            model.m_bb = aabb;

            return(model);
        }
Beispiel #5
0
        public static DrawModel CreateBox(float geometryScale, float uvScale, Vector4 offset)
        {
            var   drawSys = DrawSystem.GetInstance();
            var   d3d     = drawSys.D3D;
            float gs      = geometryScale;
            float us      = uvScale;

            var vertices = new _VertexCommon[]
            {
                // top plane
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, gs, 1), Texcoord = new Vector2(us, 0), Normal = Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, -gs, 1), Texcoord = new Vector2(0, us), Normal = Vector3.UnitY
                },

                // bottom plane
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = -Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = -Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, gs, 1), Texcoord = new Vector2(us, 0), Normal = -Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = -Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, -gs, 1), Texcoord = new Vector2(0, us), Normal = -Vector3.UnitY
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = -Vector3.UnitY
                },

                // forward plane
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, -gs, 1), Texcoord = new Vector2(0, 0), Normal = -Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, -gs, 1), Texcoord = new Vector2(us, 0), Normal = -Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = -Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, -gs, 1), Texcoord = new Vector2(0, 0), Normal = -Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = -Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, -gs, 1), Texcoord = new Vector2(0, us), Normal = -Vector3.UnitZ
                },

                // back plane
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, gs, 1), Texcoord = new Vector2(us, us), Normal = Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, gs, 1), Texcoord = new Vector2(us, 0), Normal = Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, gs, 1), Texcoord = new Vector2(0, us), Normal = Vector3.UnitZ
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, gs, 1), Texcoord = new Vector2(us, us), Normal = Vector3.UnitZ
                },

                // left plane
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = -Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, -gs, 1), Texcoord = new Vector2(us, 0), Normal = -Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = -Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = -Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = -Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(-gs, -gs, gs, 1), Texcoord = new Vector2(0, us), Normal = -Vector3.UnitX
                },

                // right plane
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, -gs, 1), Texcoord = new Vector2(us, 0), Normal = Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, gs, gs, 1), Texcoord = new Vector2(0, 0), Normal = Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, gs, 1), Texcoord = new Vector2(0, us), Normal = Vector3.UnitX
                },
                new _VertexCommon()
                {
                    Position = new Vector4(gs, -gs, -gs, 1), Texcoord = new Vector2(us, us), Normal = Vector3.UnitX
                },
            };

            Aabb aabb = Aabb.Invalid();

            for (int i = 0; i < vertices.Length; ++i)
            {
                vertices[i].Position  += offset;
                vertices[i].Position.W = 1;
                aabb.ExtendByPoint(MathUtil.ToVector3(vertices[i].Position));
            }

            var model = new DrawModel("");
            var mesh  = DrawUtil.CreateMeshData <_VertexCommon>(d3d, PrimitiveTopology.TriangleList, vertices);

            model.m_nodeList.Add(new Node()
            {
                Mesh = mesh, Material = DebugMaterial.Create(), IsDebug = false, HasBone = false
            });
            model.m_bb = aabb;

            return(model);
        }
Beispiel #6
0
        public static DrawModel FromScene(String uid, BlenderScene scene, string fileSearchPath)
        {
            var drawSys        = DrawSystem.GetInstance();
            var drawRepository = drawSys.ResourceRepository;
            var d3d            = drawSys.D3D;

            var  model   = new DrawModel(uid);
            bool hasBone = BlenderUtil.GetLengthOf(scene.NodeList[0].BoneArray) > 0;// boneArray is set to the first node
            var  aabb    = Aabb.Invalid();

            foreach (var n in scene.NodeList)
            {
                if (n.MaterialData.Type == MaterialBase.MaterialTypes.Marker)
                {
                    // marker material is used as 'Marker'
                    continue;
                }

                if (n.Vertics.Count() == 0)
                {
                    // empty vertex list
                    continue;
                }

                // Build a vertex buffer(s)
                var vertices1 = n.Vertics
                                .Select(v => new _VertexCommon()
                {
                    Position = v.Position,
                    Normal   = v.Normal,
                    Texcoord = v.Texcoord
                }).ToArray();

                var vertices2 = n.Vertics
                                .Select(v => v.Tangent).ToArray();

                // update aabb
                foreach (var v in vertices1)
                {
                    aabb.ExtendByPoint(MathUtil.ToVector3(v.Position));
                }

                var node = new Node();
                node.Material = n.MaterialData;
                node.IsDebug  = false;
                node.HasBone  = hasBone;
                if (node.HasBone)
                {
                    // if model has bone, we create a bone vertex info
                    var vertices3 = n.Vertics
                                    .Select(v =>
                    {
                        Debug.Assert(BlenderUtil.GetLengthOf(v.BoneIndices) == BlenderUtil.GetLengthOf(v.BoneWeights), "both of bone index and bone weight must be matched");
                        //Debug.Assert(BlenderUtil.GetLengthOf(v.BoneWeights) <= _VertexBoneWeight.MAX_COUNT, "length of bone weight is over :" + BlenderUtil.GetLengthOf(v.BoneWeights));
                        Debug.Assert(BlenderUtil.GetLengthOf(v.BoneWeights) != 0, "no bone entry");
                        var tmp = new _VertexBoneWeight()
                        {
                            Index0  = BlenderUtil.GetLengthOf(v.BoneIndices) > 0 ? v.BoneIndices[0] : 0,
                            Weight0 = BlenderUtil.GetLengthOf(v.BoneWeights) > 0 ? v.BoneWeights[0] : 0.0f,
                            Index1  = BlenderUtil.GetLengthOf(v.BoneIndices) > 1 ? v.BoneIndices[1] : 0,
                            Weight1 = BlenderUtil.GetLengthOf(v.BoneWeights) > 1 ? v.BoneWeights[1] : 0.0f,
                            Index2  = BlenderUtil.GetLengthOf(v.BoneIndices) > 2 ? v.BoneIndices[2] : 0,
                            Weight2 = BlenderUtil.GetLengthOf(v.BoneWeights) > 2 ? v.BoneWeights[2] : 0.0f,
                            Index3  = BlenderUtil.GetLengthOf(v.BoneIndices) > 3 ? v.BoneIndices[3] : 0,
                            Weight3 = BlenderUtil.GetLengthOf(v.BoneWeights) > 3 ? v.BoneWeights[3] : 0.0f,
                        };
                        float sumWeight = tmp.Weight0 + tmp.Weight1 + tmp.Weight2 + tmp.Weight3;
                        tmp.Weight0    /= sumWeight;
                        tmp.Weight1    /= sumWeight;
                        tmp.Weight2    /= sumWeight;
                        tmp.Weight3    /= sumWeight;
                        return(tmp);
                    }).ToArray();

                    node.Mesh = DrawUtil.CreateMeshData(d3d, PrimitiveTopology.TriangleList, vertices1, vertices2, vertices3);
                }
                else
                {
                    node.Mesh = DrawUtil.CreateMeshData(d3d, PrimitiveTopology.TriangleList, vertices1, vertices2);
                }

                // add dispoable

/*
 * foreach (var buf in node.Mesh.Buffers)
 * {
 *  model._AddDisposable(buf.Buffer);
 * }
 */

                // create skeleton
                if (model.m_boneArray == null && n.BoneArray != null)
                {
                    model.m_boneArray = (DrawSystem.BoneData[])n.BoneArray.Clone();
                }

                // load new texture
                foreach (var texInfo in n.TextureInfos.Values)
                {
                    if (!drawRepository.Contains(texInfo.Name))
                    {
                        var tex = TextureView.FromFile(texInfo.Name, drawSys.D3D, Path.Combine(fileSearchPath, texInfo.Name));
                        drawRepository.AddResource(tex);
                    }
                }

                // copy textures from cache
                foreach (DrawSystem.TextureTypes textureType in Enum.GetValues(typeof(DrawSystem.TextureTypes)))
                {
                    if (n.TextureInfos.ContainsKey(textureType))
                    {
                        node.Material.SetTextureData(
                            textureType,
                            new DrawSystem.TextureData
                        {
                            Resource = drawRepository.FindResource <TextureView>(n.TextureInfos[textureType].Name),
                            UvScale  = n.TextureInfos[textureType].UvScale,
                        });
                    }
                }

                model.m_nodeList.Add(node);
            }

            model.m_bb = aabb;
            return(model);
        }
Beispiel #7
0
            public Factory(DrawSystem.D3DData d3d, DrawResourceRepository repository)
            {
                m_initParam.D3D        = d3d;
                m_initParam.Repository = repository;

                m_initParam.WorldVtxConst = DrawUtil.CreateConstantBuffer <_VertexShaderConst_World>(d3d, 1);
                m_initParam.WorldPixConst = DrawUtil.CreateConstantBuffer <_PixelShaderConst_World>(d3d, 1);

                m_initParam.RasterizerState = new RasterizerState(d3d.Device, new RasterizerStateDescription()
                {
                    CullMode = CullMode.Back,
                    FillMode = FillMode.Solid,
                    IsAntialiasedLineEnabled = false,                           // we do not use wireframe
                    IsDepthClipEnabled       = true,
                    IsMultisampleEnabled     = false,
                });

                var renderModes = new[] { DrawSystem.RenderMode.Opaque, DrawSystem.RenderMode.Transparency };

                m_initParam.BlendStates = new BlendState[renderModes.Length];
                foreach (DrawSystem.RenderMode mode in renderModes)
                {
                    int index = (int)mode;
                    m_initParam.BlendStates[index] = _CreateBlendState(d3d, mode);
                }
                m_initParam.DepthStencilStates = new DepthStencilState[renderModes.Length];
                foreach (DrawSystem.RenderMode mode in renderModes)
                {
                    int index = (int)mode;
                    m_initParam.DepthStencilStates[index] = _CreateDepthStencilState(d3d, mode);
                }

                {
                    var shader = new Effect(
                        "Std",
                        d3d,
                        new InputElement[]
                    {
                        new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                        new InputElement("NORMAL", 0, Format.R32G32B32_Float, 16, 0),
                        new InputElement("TEXCOORD", 0, Format.R32G32_Float, 28, 0),
                        new InputElement("TANGENT", 0, Format.R32G32B32_Float, 0, 1),
                        new InputElement("BONEINDEX", 0, Format.R32G32B32A32_UInt, 0, 2),
                        new InputElement("BONEWEIGHT", 0, Format.R32G32B32A32_Float, 16, 2),
                    },
                        "Shader/VS_Std.fx",
                        "Shader/PS_Std.fx");

                    repository.AddResource(shader);
                }

                {
                    var shader = new Effect(
                        "Minimap",
                        d3d,
                        new InputElement[]
                    {
                        new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                        new InputElement("NORMAL", 0, Format.R32G32B32_Float, 16, 0),
                        new InputElement("TEXCOORD", 0, Format.R32G32_Float, 28, 0),
                        new InputElement("TANGENT", 0, Format.R32G32B32_Float, 0, 1),
                        new InputElement("BONEINDEX", 0, Format.R32G32B32A32_UInt, 0, 2),
                        new InputElement("BONEWEIGHT", 0, Format.R32G32B32A32_Float, 16, 2),
                    },
                        "Shader/VS_Std.fx",
                        "Shader/PS_Minimap.fx");

                    repository.AddResource(shader);
                }

                {
                    var shader = new Effect(
                        "Debug",
                        d3d,
                        new InputElement[]
                    {
                        new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                        new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0),
                    },
                        "Shader/VS_Debug.fx",
                        "Shader/PS_Debug.fx");

                    repository.AddResource(shader);
                }
            }