本文介绍了HLSL问题:缺少TextureCoordinate0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个非常简单的游戏,并且正在与HLSL合作.我的绘制方法出现此错误:

当前顶点声明不包括当前顶点着色器所需的所有元素.缺少TextureCoordinate0."

这是我的绘画方法:

Im trying to create a very simple game, and am working with HLSL. i got this error in my draw method:

"The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing."

and here is my draw method:

public void Draw(Matrix View, Matrix Projection,Vector3 CameraPosition)

{ // Calculate the base transformation by combining translation, rotation, and scaling

        Matrix baseWorld = Matrix.CreateScale(Scale) *
            Matrix.CreateFromYawPitchRoll(Rotation.X, Rotation.Y, Rotation.Z) *
            Matrix.CreateTranslation(Position);
        foreach (ModelMesh mesh in Model.Meshes)
        {
            Matrix localWorld = modelTransforms[mesh.ParentBone.Index] * baseWorld;

            foreach (ModelMeshPart part in mesh.MeshParts)
            {
                Effect effect = part.Effect;
                if (part.Effect is BasicEffect)
                {
                    ((BasicEffect)effect).World = localWorld;
                    ((BasicEffect)effect).View = View;
                    ((BasicEffect)effect).Projection = Projection;
                    ((BasicEffect)effect).EnableDefaultLighting();
                }
                else
                {
                    setEffectParameter(effect, "World", localWorld);
                    setEffectParameter(effect, "View", View);
                    setEffectParameter(effect, "Projection", Projection);
                    setEffectParameter(effect, "CameraPosition", CameraPosition);

                    Material.SetEffectParameters(effect);
                }
            }
            mesh.Draw();
        }



但是,如果在VertexShaderFunction(在LightingEffect中)中,而不是"output.UV = input.UV",我将"output.UV = float2(somefloat,somefloat)"放进去,不会出错.

还有另一件事,当我尝试加载大教堂"模型和其他模型时出现此错误,但是对于茶壶"模型,我没有错误!

我真的很困惑!

这是我完整的代码和模型. http://www.uploadmb.com/dw.php?id=1336639273

谢谢您的帮助.



but if in VertexShaderFunction (in LightingEffect), instead of "output.UV = input.UV" i put "output.UV=float2(somefloat,somefloat)" i got no error.

and there is a another thing, i got this error when i try to load my "Cathedral" model and others, but for "teapot" model i got no error!

i''m realy confused!

here is my complete code and models. http://www.uploadmb.com/dw.php?id=1336639273

thank you for your helping.

推荐答案


这篇关于HLSL问题:缺少TextureCoordinate0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 23:57