Windows 10, DirectX, Visual Studio 2015, release Monogame 3.5 installer (from http://www.monogame.net/downloads/ not nuget or github.)
I’ve been trying to light my 3D geometry with the BasicEffect.
However, all the geometry has washed out to white.
Only when I set the DiffuseColor value to Vector3(0.01,0.01,0.01) or less do I get a reasonable amount of lighting.
I am turning off vertex colors, and using two directional lights and a scene ambient light color.
The setup looks like this:
fx.Alpha = 255; fx.AmbientLightColor = CalcAmbientColor(); fx.DiffuseColor = new Vector3(0.01f, 0.01f, 0.01f); fx.DirectionalLight0.Enabled = true; fx.DirectionalLight0.DiffuseColor = sunlight.ToVector3(); fx.DirectionalLight0.Direction = -sunPosition; fx.DirectionalLight0.SpecularColor = sunlight.ToVector3(); fx.DirectionalLight1.Enabled = true; fx.DirectionalLight1.DiffuseColor = skylight.ToVector3(); fx.DirectionalLight1.Direction = new Vector3(0, -1, 0); fx.DirectionalLight1.SpecularColor = new Vector3(0, 0, 0); fx.DirectionalLight2.Enabled = false; fx.DirectionalLight2.DiffuseColor = new Vector3(0, 0, 0); fx.DirectionalLight2.Direction = new Vector3(0, 1, 0); fx.DirectionalLight2.SpecularColor = new Vector3(0, 0, 0); fx.EmissiveColor = new Vector3(0, 0, 0); fx.FogColor = fogColor.ToVector3(); fx.FogEnabled = true; fx.FogStart = fogDistance * 0.1f; fx.FogEnd = fogDistance; fx.LightingEnabled = true; fx.PreferPerPixelLighting = true; fx.SpecularColor = new Vector3(0.005f, 0.005f, 0.005f); fx.SpecularPower = 40.0f; fx.TextureEnabled = true; fx.Texture = someTexture; fx.VertexColorEnabled = false;
The value of sunlight is in the 0.8f range, and the value of skylight is in the 0.2f range.
The texture is a beige cracked-stone texture.
sunlight = new Color(new Vector3(0.85f, 0.8f, 0.7f)); skylight = new Color(new Vector3(0.1f, 0.15f, 0.25f)); sunPosition = new Vector3(1, 1, -3); sunPosition.Normalize(); fogColor = Color.CornflowerBlue; fogDistance = 1000.0f;
CalcAmbientColor() returns a color value in the 0.2 range as well.
I’ve tried debugging the shader in Visual Studio Graphics Tools, but the way the shader is built for the installer does not include debug info and thus I can only step through the assembly. I can see it takes the SM4 path, not the DX9 path; that’s about it. (Well, and the sampler value of the texture looks OK)
It feels approximatly like there is an erroneous multiplication by 255 somewhere in the treatment of the diffusecolor and specularcolor material values?
What should I do to fix this? Is this a known bug? A patch/later release?