Sign in to follow this  
Followers 0
Medo Mex

Texture Splatting Using SetTextureStageState() and SetRenderState()

22 posts in this topic

If I have 2 different textures and want to blend them together with blending map:

device->SetTexture(0, &blendingMapTexture);
device->SetTexture(1, &grassTexture);
device->SetTexture(2, &stoneTexture);
 
I want someone to tell me what should I give to:
device->SetTextureStageState() and device->SetRenderState()
 
To make it work.
0

Share this post


Link to post
Share on other sites

I tried the tutorial before, but couldn't get it to work, can you directly give me what device->SetTextureStageState() and device->SetRenderState() values that I need to set to make the following works:device->SetTexture(0, &blendingMapTexture);

device->SetTexture(0, &blendingMapTexture);
device->SetTexture(1, &grassTexture);
device->SetTexture(2, &stoneTexture);
Edited by Medo3337
0

Share this post


Link to post
Share on other sites

OMG. Medo3337, there is a demo with source, you just have to copy-paste relevant parts that you need:

//-----------------------------------------------------------------------------
// Render using the fixed function pipeline
//-----------------------------------------------------------------------------
void RenderWithoutShader() {
    // Alphamap: take the alpha from the alphamap, we don't care about the color
    g_Direct3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
    g_Direct3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

    // Texture: take the color from the texture, take the alpha from the previous stage
    g_Direct3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
    g_Direct3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    g_Direct3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
    g_Direct3DDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);

    // Disable textures from the pixel shader mode
    g_Direct3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
    g_Direct3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

    // Disable the pixel shader
    g_Direct3DDevice->SetPixelShader(NULL);

    g_Direct3DDevice->SetTexture(0, g_Alphamap1);
    g_Direct3DDevice->SetTexture(1, g_Texture1);
    g_Direct3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Vertices, sizeof(QuadVertex));

    g_Direct3DDevice->SetTexture(0, g_Alphamap2);
    g_Direct3DDevice->SetTexture(1, g_Texture2);
    g_Direct3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Vertices, sizeof(QuadVertex));

    g_Direct3DDevice->SetTexture(0, g_Alphamap3);
    g_Direct3DDevice->SetTexture(1, g_Texture3);
    g_Direct3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Vertices, sizeof(QuadVertex));

    g_Direct3DDevice->SetTexture(0, g_Alphamap4);
    g_Direct3DDevice->SetTexture(1, g_Texture4);
    g_Direct3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Vertices, sizeof(QuadVertex));
}
0

Share this post


Link to post
Share on other sites

The way that I'm drawing the terrain differ from the sample.

 

I have exported terrain and drawing it ONCE, in the above example, it's drawing the terrain 4 times to set 4 textures which I think it's not a good idea for performance.

 

I want to accomplish texture splatting without Shader and draw the terrain once.

 

The way that I want to do it is exactly as I mentioned:

 

device->SetTexture(0, &blendingMapTexture);
device->SetTexture(1, &grassTexture);
device->SetTexture(2, &stoneTexture);
// Code to draw terrain here...

and NOT this:

device->SetTexture(0, &blendingMapTexture);
device->SetTexture(1, &grassTexture);
// Code to draw terrain...
device->SetTexture(0, &blendingMapTexture);
device->SetTexture(1, &stoneTexture);
// Code to draw terrain again...
0

Share this post


Link to post
Share on other sites

I am currently playing with FFP texture splatting, although i am not familiar with it as i am doing this same thing with shaders.

Try this (one pass):

NOTE: blendmap should be grayscale image with no alpha!

 

d3d9device->SetTexture(0, terrBlendTex);
        d3d9device->SetTexture(1, terr1Tex);
        d3d9device->SetTexture(2, terr2Tex);

        d3d9device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );

        D3DXMATRIX blendmapTrans, tex1Trans, tex2Trans;
        D3DXMatrixScaling(&blendmapTrans, 1.f, 1.f, 1.f);
        D3DXMatrixScaling(&tex1Trans, 32.f, 32.f, 32.f);
        D3DXMatrixScaling(&tex2Trans, 4.f, 4.f, 4.f);
        d3d9device->SetTransform( D3DTS_TEXTURE0, &blendmapTrans );
        d3d9device->SetTransform( D3DTS_TEXTURE1, &tex1Trans );
        d3d9device->SetTransform( D3DTS_TEXTURE2, &tex2Trans );

        d3d9device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, 0 );

        d3d9device->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );

        d3d9device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
        d3d9device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        d3d9device->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
        d3d9device->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_MODULATE );
        d3d9device->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        d3d9device->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
        d3d9device->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
        d3d9device->SetTextureStageState( 2, D3DTSS_COLOROP,   D3DTOP_MODULATE );
        d3d9device->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        d3d9device->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_CURRENT | D3DTA_COMPLEMENT );
        d3d9device->SetTextureStageState( 2, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );

        TerrMesh->DrawSubset(0);

        d3d9device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );

 

Its not yet finished, i can't figure out how to set different texcoord scale to each stage/texture set, by some logic it should be like this:

 

d3d9device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, 2 );

 

but then it doesn't show other 2 textures, like there is a always 0,0 for texcoords.

 

If i got it working i'll post it here.

 

EDIT: Forget everything above, i think this is all correct:

d3d9device->SetTexture(0, terrBlendTex);
        d3d9device->SetTexture(1, terr1Tex);
        d3d9device->SetTexture(2, terr2Tex);

        d3d9device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );

        D3DXMATRIX blendmapTrans, tex1Trans, tex2Trans;
        D3DXMatrixScaling(&blendmapTrans, 1.f, 1.f, 1.f);
        D3DXMatrixScaling(&tex1Trans, 4.f, 4.f, 1.f);
        D3DXMatrixScaling(&tex2Trans, 16.f, 16.f, 1.f);
        d3d9device->SetTransform( D3DTS_TEXTURE0, &blendmapTrans );
        d3d9device->SetTransform( D3DTS_TEXTURE1, &tex1Trans );
        d3d9device->SetTransform( D3DTS_TEXTURE2, &tex2Trans );

        d3d9device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, 0 );

        d3d9device->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );

        d3d9device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
        d3d9device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        d3d9device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
        d3d9device->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
        d3d9device->SetTextureStageState( 0, D3DTSS_RESULTARG, D3DTA_TEMP );
        d3d9device->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_MODULATE );
        d3d9device->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        d3d9device->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_TEMP );
        d3d9device->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
        d3d9device->SetTextureStageState( 2, D3DTSS_COLOROP,   D3DTOP_MULTIPLYADD );
        d3d9device->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        d3d9device->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_TEMP | D3DTA_COMPLEMENT );
        d3d9device->SetTextureStageState( 2, D3DTSS_COLORARG0, D3DTA_CURRENT );
        d3d9device->SetTextureStageState( 2, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );

        TerrMesh->DrawSubset(0);

        d3d9device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
Edited by belfegor
0

Share this post


Link to post
Share on other sites

Unfortunately, I tried the above code but couldn't get it to work.

 

I see that the terrain texture in the results is only the one that I set in d3d9device->SetTexture(1, terr1Tex);

0

Share this post


Link to post
Share on other sites

I would strongly suggest you do this first:

 

1. Learn the Texture Blending Cascade by experimenting with it, step by step.

 

Then come back and we can have a discussion why something you did does not work.

 

Otherwise, it's just a waste of time...

0

Share this post


Link to post
Share on other sites

@VladR: I do have ALOT of things to do with the engine, so I'm trying to get the code work and figure out what's going on.

0

Share this post


Link to post
Share on other sites

@VladR: I do have ALOT of things to do with the engine, so I'm trying to get the code work and figure out what's going on.

 

It certainly doesn't look that way from your other threads here.

 

Here's how it looks: "Gimme the code that works and will work when copypasted into my code"

 

Well, guess what - texturing cascade is a process that is pretty complex and can be broken very easily.

 

 

I can, however, suggest you have a separate project, just for trying out the texturing cascade stuff (and absolutely nothing else - just blend 2-3 TSS and that's it). Because with the rest of the game and engine running, there will 10 other things that will try to break the blending/transparency (HUD, foliage, particles, 3D cursors,  ...).

 

 

Otherwise, even the stuff that works elsewhere, won't work in your code simply because your render states are not what you think they are - are you defaulting their states after every change ? If not, you have a mess and need to reset them to their default values.

0

Share this post


Link to post
Share on other sites

Unfortunately, I tried the above code but couldn't get it to work.

Is your blend image something like grayscale (no need for alpha channel) ?

 

blendmap.png

 

Here is some utility program (from old dx9.b  sdk) mfctex that you can play with, since you force to use FFP.

 

mfctex.jpg

 

It even generates code from provided input in controls.

Edited by belfegor
0

Share this post


Link to post
Share on other sites

Out of curiosity, why does it need to work on an ancient pre-shader-era FFP HW ?

0

Share this post


Link to post
Share on other sites

Okay, since I couldn't get it to work correctly and I don't want to spend much time trying to solve this issue, I tried using Pixel Shader and it's working now, I have a little problem, the blending map SHOULD be based on the whole terrain not each tile, see the screenshot:

[attachment=15208:r.png]

0

Share this post


Link to post
Share on other sites

You have issues with mipmaps as i can tell from the image.

If you want help, give more details.

 

How do you create your terrain? Or is it exported from some modeling program? Did you applied correct texcoords (with just "1 tile")? Show your shader.

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

In 3ds max set one texture to repeat only once (no tiling), then in code you just scale texcoords for textures other then blendmap and it should be as what you have asked.

 

        d3d9device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 2, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 3, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        d3d9device->SetTextureStageState( 4, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );

        D3DXMATRIX blendmapScale, texScale;
        D3DXMatrixScaling(&blendmapScale, 1.f, 1.f, 1.f);
        D3DXMatrixScaling(&texScale, 16.f, 16.f, 1.f);
        d3d9device->SetTransform( D3DTS_TEXTURE0, &blendmapScale );
        d3d9device->SetTransform( D3DTS_TEXTURE1, &texScale );
        d3d9device->SetTransform( D3DTS_TEXTURE2, &texScale );
        d3d9device->SetTransform( D3DTS_TEXTURE3, &texScale );
        d3d9device->SetTransform( D3DTS_TEXTURE4, &texScale );

 

I don't see that you have set mipmap filtering, so in the image that you showed might be point, try to set like these:

        d3d9device->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 2, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 3, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 3, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 3, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 4, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 4, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        d3d9device->SetSamplerState( 4, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
1

Share this post


Link to post
Share on other sites

Ok, Great! I'm getting confused with creating the blending map in photoshop, I made the following image to try to use it as a blending map, but I'm only getting to see 2 textures, I also tried to play around with it but couldn't get to find out how it should work:

[attachment=15226:MU.png]

 

I thought it should be RGBA, R = Texture1, G = Texture2, B = Texture3, A = Texture4.

0

Share this post


Link to post
Share on other sites

I will try to use my psychic powers to solve your problem.

You have declaration for your 5 textures somewhere and set them to NULL ?

 

LPDIRECT3DTEXTURE9 terrBlendTex = NULL;
LPDIRECT3DTEXTURE9 terr1Tex = NULL;
LPDIRECT3DTEXTURE9 terr2Tex = NULL;
LPDIRECT3DTEXTURE9 terr3Tex = NULL;
LPDIRECT3DTEXTURE9 terr4Tex = NULL;

 

And then in part of code when you load them, you have copied code that loads first 2 because you have that from previous tests:

 

    hr = D3DXCreateTextureFromFile(d3d9device, "blendmap.png", &terrBlendTex);
    ...// check for error
    hr = D3DXCreateTextureFromFile(d3d9device, "texture1.png", &terr1Tex); // copied this
    ...// check for error
    hr = D3DXCreateTextureFromFile(d3d9device, "texture2.png", &terr2Tex); // and this
    ...// check for error
    hr = D3DXCreateTextureFromFile(d3d9device, "texture3.png", &terr1Tex); // here
    ...// check for error
    hr = D3DXCreateTextureFromFile(d3d9device, "texture4.png", &terr2Tex); // and here
    ...// check for error

But forget to change pointer variable names?

 

And then when you set those:

 

        d3d9device->SetTexture(0, terrBlendTex);
        d3d9device->SetTexture(1, terr1Tex);
        d3d9device->SetTexture(2, terr2Tex);
        d3d9device->SetTexture(3, terr3Tex); // NULL
        d3d9device->SetTexture(4, terr4Tex); // NULL

3rd & 4th textures are now showing as white?

 

Is that a problem?

 

Try this as blendmap.

Edited by belfegor
0

Share this post


Link to post
Share on other sites

It is simple process in Photoshop

 

1. File->New and set your desired size (default RGB color)

2. Paint whole image with pure black

3. Go to "channels" tab and add alpha channel

4. Set painting color to pure white

5. Select RED channel only, and paint one part of the image

6. Select GREEN channel, and paint some other part of the image

7. Select BLUE channel,  -||-

8. Select ALPHA channel,  -||-

9. Save

1

Share this post


Link to post
Share on other sites

Thanks :) Working very well now!

 

The only problem now is with the tiled texture (it doesn't look realistic because of tiling), I heard I could apply noise map, any idea how I can apply it to the current work?

0

Share this post


Link to post
Share on other sites

I have no idea, you'll have to research those techniques.

It should be less noticeable when you add buildings, rocks, grass, shrubs, trees, various props...

0

Share this post


Link to post
Share on other sites

The only problem now is with the tiled texture (it doesn't look realistic because of tiling), I heard I could apply noise map

Forget about noise map. There's only so much a noise map can do.

 

If you really want to break the repetition, solve the actual original problem - reusing same material in each terrain chunk.

 

You want to look into procedural texturing.

 

Rough Algorithm:

 

1. For Each TerrainChunk

2.    Create New Empty DiffuseTexture (512x512)

3.      Lock The Surface

4.      CalculateTexels ()

5.      Unlock The Surface

 

What about CalculateTexels () ?

1. Start with assigning texels based on elevation : Blue at 0%, Brown from <1%,25%>, Green <26%,50%>, Grey <51%,95%>, White <96%,100%>. This shouldn't take more than one afternoon.

 

2. Then, when this works, create more complex rules with more colors and better transitions between separate layers.

About 8 yrs ago, on a FixedFunction HW (either GF2 or GF3, can't remember correctly ATM), using DX 8, I came up with few rules (through some experimenting) that gave me this scene - I think I was also using a blendmap there to get some high-frequency detail:

ScreenShot005.jpg

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0