CC3GraphicsTexture2D crateTexData = new CC3GraphicsTexture2D("Content/crate.jpg"); CC3GraphicsTexture2D logoTexData = new CC3GraphicsTexture2D("Content/logo.gif"); CC3Texture crateTexture = new LCC3Texture(0, "crate"); crateTexture.GraphicsTexture = crateTexData; CC3Texture logoTexture = new LCC3Texture(1, "logo"); logoTexture.GraphicsTexture = logoTexData;
that are seen below
and then add these textures to our material
multiTexMaterial.AddTexture(crateTexture); multiTexMaterial.AddTexture(logoTexture);
Finally, we need to specify how these textures are overlaid. This is done by setting the ivar TextureUnitMode in our texture objects which is of enum type CC3TextureUnitMode that (currently) takes one of the following values
// replace src with dst CC3TextureUnitMode.Replace, // add src with dst CC3TextureUnitMode.Add, // replace src with dst where alpha > 0.0 CC3TextureUnitMode.Decal, // mix src with dst using TextureUnitConstantColor CC3TextureUnitMode.Blend
Note, that the order of rendering of textures in a material is based on the order in which it's added. So typically the first texture added would have the TextureUnitMode set to CC3TextureUnitMode.Replace. So for our example we would have
crateTexture.TextureUnitMode = CC3TextureUnitMode.Replace;
Then, for subsequent textures that are drawn on top of the initial texture, it's a matter of playing around with the different mixing effects. For the case of CC3TextureUnitMode.Blend a user is required to additionally set a texture object's TextureUnitConstantColor ivar which can adjust the alpha of the source texture as well as overlay it with an additional hue.
Overall, in combination with the other different material/lighting attributes talked about last week, you can get some pretty nice effects as seen below
Click to enlarge |
No comments:
Post a Comment