Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualMedo3337

Posted 24 April 2013 - 02:07 PM

I'm currently creating the terrain in 3Ds Max and using UVW Map modifier to set the tiling UVW.

 

When I remove the UVW Map modifier in 3Ds Max, I get no tiling at all which is a problem, I want the tiling to be based on the grass and stone texture and the blending map should be applied to the whole terrain not each tile.

 

 

Here is the code:

device->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(1, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetSamplerState(2, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(2, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(2, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetSamplerState(3, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(3, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(3, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetSamplerState(4, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(4, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(4, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(2, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(3, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(4, D3DTSS_TEXCOORDINDEX, 0);

device->SetTexture(0, texBlendingMap);
device->SetTexture(1, tex1);
device->SetTexture(2, tex2);
device->SetTexture(3, tex3);
device->SetTexture(4, tex4);

device->SetPixelShader(splatPixelShader);
// Code to render terrain here...

 

Pixel shader:

ps_1_4

////////////////////////////////
// r0: alphamaps
// r1 - r4: textures
////////////////////////////////

// Sample textures
texld r0, t0
texld r1, t1
texld r2, t1
texld r3, t1
texld r4, t1

// Combine textures together based off of their alphamaps
mul r1, r1, r0.x
lrp r2, r0.y, r2, r1
lrp r3, r0.z, r3, r2
lrp r0, r0.w, r4, r3

#1Medo3337

Posted 24 April 2013 - 02:07 PM

I'm currently creating the terrain in 3Ds Max and using UVW Map modifier to set the tiling UVW.

 

When I remove the UVW Map modifier in 3Ds Max, I get no tiling at all which is a problem, I want the tiling to be based on the grass and stone texture and the blending map should be applied to the whole terrain not each tile.

 

 

Here is the code:

device->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(1, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetSamplerState(2, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(2, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(2, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetSamplerState(3, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(3, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(3, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetSamplerState(4, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
device->SetSamplerState(4, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
device->SetSamplerState(4, D3DSAMP_ADDRESSW, D3DTADDRESS_MIRROR);

device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(2, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(3, D3DTSS_TEXCOORDINDEX, 0);
device->SetTextureStageState(4, D3DTSS_TEXCOORDINDEX, 0);

device->SetTexture(0, texBlendingMap);
device->SetTexture(1, tex1);
device->SetTexture(2, tex2);
device->SetTexture(3, tex3);
device->SetTexture(4, tex4);

device->SetPixelShader(splatPixelShader);
// Code to render terrain here...

Pixel shader:

 

ps_1_4

////////////////////////////////
// r0: alphamaps
// r1 - r4: textures
////////////////////////////////

// Sample textures
texld r0, t0
texld r1, t1
texld r2, t1
texld r3, t1
texld r4, t1

// Combine textures together based off of their alphamaps
mul r1, r1, r0.x
lrp r2, r0.y, r2, r1
lrp r3, r0.z, r3, r2
lrp r0, r0.w, r4, r3

PARTNERS