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.


#Actualbelfegor

Posted 23 April 2013 - 07:43 AM

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 );

#2belfegor

Posted 23 April 2013 - 06:04 AM

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.


#1belfegor

Posted 23 April 2013 - 06:02 AM

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):

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.


PARTNERS