No problems, just wanted to say what a fantastic job you've done with these tutorials. I come from a Flash to Silverlight to WPF to now XNA background, and you're tutorials are awesome. Very well written. Wish I would have found them 4 weeks ago, but reading them all as an "overview summary" and still finding things I've missed. Hope your Masters stuff works out great for you. Thanks for all this work, man. Much appreciated by everyone who uses it, I'm sure!
Thanks for the feedback Rick! It's always nice to know people are finding it useful!
Hi! Your tutorials are great, well detailed and explained.
Unfortunately, it doesn't work properly. When I use the command:
"effect.EnableDefaultLighting();"
My model is drawn as totally black. Even if I set DiffuseColor, it is still black.
Without that row, it is drawn well, with texture too, but I need to have some light too.
Can anyone explain how to resolve this problem?
Many thanks,
Benedek
I had the same problem for the ship2.x model (in tutorial ‘3 - Picking’ from series ‘5 - Input Tutorials’), and I have found a small workaround on this page (remove spaces):
community.monogame . net/t/black-textures-on-models/6836/2
Swapping effect.EnableDefaultLighting(); to effect.AmbientLightColor = new Vector3(1f, 0, 0); has seem to displayed the textures now.
It would still be nice to understand how EnableDefaultLighting works exactly and why it results in this, but the documentation does not seem to give many details about it.
PS: it turns out that you do not even need to set effect.AmbientLightColor, simply removing/disabling the EnableDefaultLighting instruction is enough.
PPS: having found out today (30/01/2022) what happens in a very similar case (when drawing with 3D primitives) and looking at whether someone addressed this in some comment, I stumble back here and can now provide a possible explanation!
The model has probably absent or incorrect normal vectors information, which is used by many lighting effects (as you can see if you delve into the ‘Effects and HLSL Tutorials’ here), except for ambient lighting.
This is why you can set some ambient color anyway if you wish so, but not anything more.
By the way, an important point when using 3D primitives instead of 3D models (which is my case and had me scratching my head for several days) is that you can set the normal vectors using the VertexPositionNormalTexture class. (There does not seem to be a VertexPositionNormalColor class nor VertexPositionNormal, strangely.)
Hello,
I applied tutorial ‘3 - Picking’ from series ‘5 - Input Tutorials’, reusing the code from the 3D tutorials; in particular, I had both the upward-moving small ship with lighting effects and the motionless small ship, with the same model.
It turned out that, although I used two different versions of DrawModel to draw them, both had the lighting effects applied to them; nevertheless, they were positioned correctly. This suggests that although the World, View and Projection properties are local to meshes, at least some lighting properties may be persistent/global/static!
Is my interpretation correct? If it is, do you have to reassign effect values each time you draw several copies of the same model with differing lightings, or is there any other more optimised way?
Thanks in advance to anyone that would have an idea about it.
PS: I have just conducted some tests, and I think it is sufficient to just turn off LightingEnabled and FogEnabled, instead of having to reset more values! :) Thus, in my DrawModelPicking method:
effect.LightingEnabled = false;
effect.FogEnabled = false;