Jump to content
  • Advertisement
Sign in to follow this  
Lord_Taren

Implementing Texture Splatting

This topic is 4636 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently working on the 3D terrain for my Game and I read a great article called "Texture Splatting in Direct3D" by Nate Glasser. I am writting the app in C# Using Managed DirectX 9.0 (Oct 2005 Update).I started to implement the technique in my game, but I ran into some problems. I have a 3D Primitive object that I use to represent my terrain. I am using one file that contains a grass texture and another file that contains the alpha mask. The alpha mask is a 32-bit tga file with the alpha on the RGB and the Alpha channel. Here's what I am getting as output. The alpha texture is being rendered to the terrain and it looks like the grass texture is being ignored. Anyone have any ideas where I am going wrong. Here's my code I am adding the alpha to texture stage 0 and the texture to stage 1: this.m_dxTextures[0] = sAlpha; this.m_dxTextures[1] = sText; Then I am setting the texture stage. GrafixEnv.Device.SetTextureStageState(0, TextureStageStates.AlphaOperation, TextureOperation.SelectArg1); GrafixEnv.Device.SetTextureStageState(0, TextureStageStates.AlphaArgument1, TextureArgument.TextureColor); GrafixEnv.Device.SetTextureStageState(1, TextureStageStates.ColorOperation, TextureOperation.SelectArg1); GrafixEnv.Device.SetTextureStageState(1, TextureStageStates.ColorArgument1, TextureArgument.TextureColor); GrafixEnv.Device.SetTextureStageState(1, TextureStageStates.AlphaOperation, TextureOperation.SelectArg1); GrafixEnv.Device.SetTextureStageState(1, TextureStageStates.AlphaArgument1, TextureArgument.Current); I am also setting the following renderstates. GrafixEnv.setRenderState(RenderStates.AlphaBlendEnable, true); GrafixEnv.setRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha); GrafixEnv.setRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha);

Share this post


Link to post
Share on other sites
Advertisement
Hi,

My advice is ditch the fixed function pipeline ..unless you have a very good reason for not using a shader to do your splatting that is [smile]

If you want an example of splatting using a fragment shader (avec source) then moon-labs has one.

All the best,
ViLiO

Share this post


Link to post
Share on other sites
I want to implement this using the fixed function pipeline so that I can get my app to run on as many different video devices as possible. After that I will also implement it using a pixel shader.

Share this post


Link to post
Share on other sites
AFAIK, you cannot use a 4 channel texture as your alphamap using the fixed function pipeline. I believe that's why all implementations of Texture Splatting that I've encountered use 4 different textures as the alphamaps.

I'd second the recommendation to use the programmable pipeline for this kind of solution. I can't think of a better example where this would be of more use.

Hope this helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!