You can also look at the multi-texturing vidéo from the ShowRoom
Tutorial : Textures & Multi-Texturing
// load textures into the engine
BrumeTexture texture1 = this.GetTexture("multitex3.tga");
BrumeTexture texture2 = this.GetTexture("multitex2.tga");
Add a simple cube to the scene. This cube will be used to preview mult-texturing results :
override protected void GameInit()
{
// camera setup
BrumeVector cameraPos = new BrumeVector(3.0f, 0.0f, -3.0f);
BrumeVector cameraDir = new BrumeVector(-0.7f, 0.0f, 0.7f);
BrumeVector cameraUp = new BrumeVector(0.0f, 1.0f, 0.0f);
BrumeFPSCamera camera = new BrumeFPSCamera(this, "camera", cameraPos, cameraDir, cameraUp);
this.SetActiveCamera(camera);
// buffer clear color setup
this.BufferClearColor = Color.Black;
...
...
override protected void GameInit()
{
...
...
// a simple cube
BrumeCubeTextured theCube = new BrumeCubeTextured(this, "Textured Cube");
...
...
To perform multi-texturing, you will need textures. You can create your own textures but for this tutorial we will use Brume integrated textures.
Note that we just load the textures into the engine without assigning them to a mesh. You can use this technique if you wants to test your textures with the debug console (you will be able to select it as input for color and alpha operations).
// use the loaded textures with multitexturing
theCube.RenderStates.Texture[0] = texture1;
// we mix the first texture with the second (and we also use alpha)
theCube.RenderStates.Texture[1] = texture2;
theCube.RenderStates.TextureStates[1].ColorArg2 = BrumeTextureParams.ARG_CURRENT; theCube.RenderStates.TextureStates[1].ColorOperation =
BrumeTextureParams.OP_BLEND_TEXTURE_ALPHA;
This tutorial will show you how to load textures and set up multi-texturing on Brume objects.
Create a new project named "TutorialTextures" as shown in "The Basics" tutorial.
In the InitGame method setup a camera and clear color as shown below :
For this sample we used two stages of multi-texturing.
You can access all the stages by the property "RenderStates.TextureState[X]" where X is the stage.
For each stage you can access multiple arguments and operations :
- ColorArg1
- ColorArg2
- ColorOperation
- AlphaArg1
- AlphaArg2
- AlphaOperation
- ....
For each stage you can assign a texture using "RenderStates.Texture[X]" property.
The final result will be computed as a unique texture and displayed on screen.
We advice you to run this sample, open the debug console, right click on the cube and go to Multi-texturing menu. Here you can adjust all texturing stages and play with the operations and arguments to better understand the states.
Once you find an interesting effect, all you have to do is to write down the textures, arguments and operations you selected and translate them into the source code.
Click on the images below to view the slideshow :
Finally we setup the multi-texturing states on the object and we assign the previously loaded textures :