I'm new to XNA, i created an effect and just want to use lightning but in default effect that XNA create we should do texture mapping or the model appears 'RED', because of this lines of code in the effect file:
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 output = float4(1,0,0,1);
return output;
}
and if i want to see my model (appear like when i use basiceffect) must do texture mapping by UV coordinates. but my model does not have UV coordinates assigned or its UV coordinates is not exported. and if i do texture mapping i got error.
(i do texture mapping by this line of code in vertexshaderfunction and other necessary codes)
output.UV= input.UV
i have many of this models and want to work with them.(my models are in .FBX format)
when i use Bassiceffect i have no problem and model appears correctly.
how can i use "just" lightnings in my custom effects? and don't do texture mapping
(because i have no UV coordinates in my models) and my model be look like when i use BasicEffect?
if you need my complete code Here it is:
http://www.mediafire.com/?4jexhd4ulm2icm2
here is inside of my Model Using BasicEffect
http://i.imgur.com/ygP2h.jpg?1
and this is my code for drawing with or without BasicEffect inside of my draw() method:
Matrix baseWorld = Matrix.CreateScale(Scale) * Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, 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 (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);
}
}
mesh.Draw();
}
setEffectParameter is another method that sets effect parameter if i use my custom effect.