

Typically, the texture file follows the name of the model (i.e. The first file is the compiled model, and the second is a texture file. The MonoGame pipeline tool has no issues compiling FBX, but take care that compiling FBX will output two files. I used Blender and UV image mapping to place my textures on the models. There is nothing special about the texture baking. I will show you how to set these shader parameters later, but I’d recommend creating a Light object to hold the position, color, intensity, and radius.ĭiffuseTexture – My models are FBX based with textures baked in. These will represent your point lights within the world. PointLightPosition, PointLightColor, PointLightIntensity, PointLightRadius – N.B. Finally, SunLightIntensity controls the scene wide intensity of the lights. Because you are using MonoGame, you can easily set this in code using the built in colors (i.e. SunLightColor is the R, G, B, A values for your world’s ambient colors. I typically do not set this, so Vector3.Zero is acceptable here. SunLightDirection is the Vector3 that represents the ambient light direction.

SunLightDirection, SunLightColor, SunLightIntensity – These are your ambient world lights. WorldViewProj is merely your World * View * Projection product.ĬameraPosition – This should be the Vector3 that represents your camera in the world. I won’t cover matrices in this blog post, but again, you should already have these values. World, WorldViewProj – If you are already rendering 3d models in MonoGame, you should have these values. Special thanks to the user kosmonautgames on the MonoGame community forums for assisting me with this.

This isn’t too complicated, but I’ll give a summary of the parameters below. The first thing I’m going to share is the actual shader code. I had played with shaders in XNA years ago for 2d projects, and it turned out that shaders for 3d projects weren’t too much different. When I first embarked to accomplish Ambient & Point Lighting, I had only a basic knowledge of how shaders worked. If you find bugs or have suggestions, I’d love to hear about them! I am just a developer who has managed to bend shaders to my will. This post assumes you have basic knowledge of MonoGame, creating a MonoGame project in Visual Studio, and rendering a simple 3d model.ĭisclaimer: I’m not an expert on shaders, HLSL, or proper techniques.
