Here is some info on the usage of dbSetBlendMappingOn() and what it's params are for(its taken from a DarkSource snippet called "good sky clouds")
//Blending Modes
// These values were taken from a darksource snippet
// BLEND MODE PARAMS
// iStage 0-7
// iImage Index
// iTexCoordMode
// 0 - Regular UV Stage Match
// 1 - Sphere Mapping UV Data
// 2 - Cube Mapping UV Data
// 3 - Steal UV Data From Stage Zero
// 10-17 - Take UV Data From Stage.. (10=0,11-1,etc)
// iBlendMode
// D3DTOP_DISABLE = 1,
// D3DTOP_SELECTARG1 = 2,
// D3DTOP_SELECTARG2 = 3,
// D3DTOP_MODULATE = 4,
// D3DTOP_MODULATE2X = 5,
// D3DTOP_MODULATE4X = 6,
// D3DTOP_ADD = 7,
// D3DTOP_ADDSIGNED = 8,
// D3DTOP_ADDSIGNED2X = 9,
// D3DTOP_SUBTRACT = 10,
// D3DTOP_ADDSMOOTH = 11,
// D3DTOP_BLENDDIFFUSEALPHA = 12,
// D3DTOP_BLENDTEXTUREALPHA = 13,
// D3DTOP_BLENDFACTORALPHA = 14,
// D3DTOP_BLENDTEXTUREALPHAPM = 15,
// D3DTOP_BLENDCURRENTALPHA = 16,
// D3DTOP_PREMODULATE = 17,
// D3DTOP_MODULATEALPHA_ADDCOLOR = 18,
// D3DTOP_MODULATECOLOR_ADDALPHA = 19,
// D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,
// D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,
// D3DTOP_BUMPENVMAP = 22,
// D3DTOP_BUMPENVMAPLUMINANCE = 23,
// D3DTOP_DOTPRODUCT3 = 24,
// D3DTOP_MULTIPLYADD = 25,
// D3DTOP_LERP = 26
Here is the class for making clouds that I took the above from(it wont be compilable as it relies on a number of external classes I developed, but you should be able to get an idea of where the blendmapping is and what it's doing.)
Header :
#ifndef _H_CBACKGROUND_H_
#define _H_CBACKGROUND_H_
#include "DarkGDK.h"
#include "main.h"
class cBackground
{
HEIGHTMAP *m_pHeightMap;
HEIGHTMAP *hm2;
INTPOINT HMSize;
D3DXVECTOR3 posa;
int iStage;
int iImage;
int iTexCoordMode;
int iBlendMode;
float q;
int m_iTikCount;
int iBlnkImg;
int iClouds;
Object3D *BBL;
Object3D *BBR;
Object3D *BBT;
Object3D *BBB;
DWORD BorderCol;
DWORD SpecCol;
public:
cBackground(int iSize);
~cBackground();
void Init(void);
void Update(int iSpeed);
//textured object, public for easy access
Object3D *AnimPlain;
};
#endif
Code :
#include "cBackground.h"
cBackground::cBackground(int iSize)
{
iStage = 1;
iImage = 7501;
iTexCoordMode = 0;
iBlendMode = 5;
q = 1.0;
HMSize.Set(iSize, iSize);
posa.x = 0.0;
posa.y = 0.0;
posa.z = 0.0;
m_iTikCount = 0;
m_pHeightMap = new HEIGHTMAP(HMSize, 210.0f);
hm2 = new HEIGHTMAP(HMSize, 230.0f);
AnimPlain = new Object3D();
BBL = new Object3D();
BBR = new Object3D();
BBT = new Object3D();
BBB = new Object3D();
BorderCol = 0;
SpecCol = 0;
};
cBackground::~cBackground()
{
delete m_pHeightMap;
delete hm2;
delete AnimPlain;
dbDeleteImage(7500);
dbDeleteImage(7501);
delete BBB;
delete BBT;
delete BBL;
delete BBR;
};
void cBackground::Init(void)
{
// make blank white image
iBlnkImg = 7501;
if(dbMemblockExist(1))
dbDeleteMemblock(1);
dbMakeMemblock(1, 12 + (1024 * 1024 * 4));
dbWriteMemblockDword(1, 0, 1024);
dbWriteMemblockDword(1, 4, 1024);
dbWriteMemblockDword(1, 8, 32);
int Pos = 0;
for(int x = 0; x <= 1023; x++)
{
for(int z = 0; z <= 1023; z++)
{
Pos = (12 + (z * (1024 * 4)) + (x * 4));
dbWriteMemblockByte(1, Pos + 2, 255);
dbWriteMemblockByte(1, Pos + 1, 255);
dbWriteMemblockByte(1, Pos + 0, 255);
dbWriteMemblockByte(1, Pos + 3, 255);
}
}
dbMakeImageFromMemblock(iBlnkImg, 1);
dbDeleteMemblock(1);
// make cloud image.
// make perlin noise for cloud images
m_pHeightMap->CreateRandomHeightMap(rand()%3000, 4.5f, 0.82f, 12);
hm2->CreateRandomHeightMap(rand()%2000, 2.5f, 0.7f, 6);
hm2->Cap(hm2->m_maxHeight * 0.4f);
*m_pHeightMap *= *hm2;
hm2->Release();
iClouds = 7500;
if(dbMemblockExist(1))
dbDeleteMemblock(1);
dbMakeMemblock(1, 12 + (1024 * 1024 * 4));
dbWriteMemblockDword(1, 0, 1024);
dbWriteMemblockDword(1, 4, 1024);
dbWriteMemblockDword(1, 8, 32);
Pos = 0;
for(int x1 = 0; x1 <= 1023; ++x1)
{
for(int y1 = 0; y1 <= 1023; ++y1)
{
posa = D3DXVECTOR3((float)x1, m_pHeightMap->m_pHeightMap[x1 + y1 * HMSize.x], (float)-y1);
Pos = (12 + (y1 * (1024 * 4)) + (x1 * 4));
dbWriteMemblockByte(1, Pos + 2, (int)posa.y);
dbWriteMemblockByte(1, Pos + 1, (int)posa.y);
dbWriteMemblockByte(1, Pos + 0, (int)posa.y);
dbWriteMemblockByte(1, Pos + 3, (int)posa.y);
}
}
dbMakeImageFromMemblock(iClouds, 1);
//dbSaveImage("cloud.bmp", iClouds);
dbDeleteMemblock(1);
AnimPlain->dbMakeObjectPlain(750, 750);
AnimPlain->dbTextureObject(0, iClouds);
AnimPlain->dbSetObjectTexture(2, 0);
AnimPlain->dbScaleObjectTexture(2, 2);
AnimPlain->dbSetObjectTransparency(2);
AnimPlain->dbSetObjectCollisionOff();
AnimPlain->dbSetObjectLight(0);
AnimPlain->dbSetObjectCull(0);
AnimPlain->dbSetObjectFog(0);
iStage = 1;
iImage = 7501;
iTexCoordMode = 0;
iBlendMode = 5;
AnimPlain->dbSetBlendMappingOn(iStage, iImage, iTexCoordMode, iBlendMode);
iStage = 2;
iImage = 7500;
iTexCoordMode = 0;
iBlendMode = 4;
AnimPlain->dbSetBlendMappingOn(iStage, iImage, iTexCoordMode, iBlendMode);
// now secondary UV data layers for static second texture (alphaportal)
// and a third UV layer for another cloud layer but it scroll speed differs
q = 1.0;
AnimPlain->dbLockVertexDataForLimb(0);
dbSetVertexDataUV( 0,1,0,0);
dbSetVertexDataUV( 0,1,q,0);
dbSetVertexDataUV( 1,1,0,0);
dbSetVertexDataUV( 2,1,q,q);
dbSetVertexDataUV( 3,1,0,0);
dbSetVertexDataUV( 4,1,0,q);
dbSetVertexDataUV( 5,1,q,q);
dbSetVertexDataUV( 0,2,0,0);
dbSetVertexDataUV( 0,2,q,0);
dbSetVertexDataUV( 1,2,0,0);
dbSetVertexDataUV( 2,2,q,q);
dbSetVertexDataUV( 3,2,0,0);
dbSetVertexDataUV( 4,2,0,q);
dbSetVertexDataUV( 5,2,q,q);
AnimPlain->dbUnlockVertexData();
BorderCol = dbRGB(75+dbRnd(174), 75+dbRnd(174), 75+dbRnd(174));
SpecCol = dbRGB(150+dbRnd(105), 150+dbRnd(105), 150+dbRnd(105));
BBB->dbMakeObjectBox(500, 20, 5);
BBB->dbPositionObject(1, -5, -250);
BBB->dbColorObject(BorderCol);
BBB->dbSetObjectSpecular(SpecCol);
BBB->dbSetObjectSpecularPower(25);
BBR->dbMakeObjectBox(500, 20, 100);
BBR->dbPositionObject(300, -5, 3);
BBR->dbColorObject(BorderCol);
BBR->dbRotateObject(0, -90, 0);
BBR->dbSetObjectSpecular(SpecCol);
BBR->dbSetObjectSpecularPower(25);
BBT->dbMakeObjectBox(500, 20, 5);
BBT->dbColorObject(BorderCol);
BBT->dbPositionObject(-1, -5, 250);
BBT->dbSetObjectSpecular(SpecCol);
BBT->dbSetObjectSpecularPower(25);
BBL->dbMakeObjectBox(500, 20, 100);
BBL->dbRotateObject(0, -90, 0);
BBL->dbPositionObject(-300, -5, 1);
BBL->dbColorObject(BorderCol);
BBL->dbSetObjectSpecular(SpecCol);
BBL->dbSetObjectSpecularPower(25);
AnimPlain->SetObjectMask(1 << 0);
BBB->SetObjectMask(1 << 0);
BBT->SetObjectMask(1 << 0);
BBL->SetObjectMask(1 << 0);
BBR->SetObjectMask(1 << 0);
};
void cBackground::Update(int iSpeed)
{
if(m_iTikCount >= 2)
{
AnimPlain->dbScrollObjectTexture(0.00009*iSpeed,0.00008*iSpeed);
AnimPlain->dbScrollObjectTexture(2.00010*iSpeed,0.00009*iSpeed);
m_iTikCount = 0;
}
++m_iTikCount;
};
To see the above class running, download the attachment to this post, it contains my Coding Challenge entry "Eggeroids"(classic Asteroid game clone in 3D with FX and no media) which the above class is taken from. The ZIP has all the source to recompile, but it was written with DarkGDK 7.3, using the March 2009 DirectX SDK. To run the included EXE you will need the latest directX redist installed.
If it ain't broke.... DONT FIX IT !!!