I need help again.
I use DARK GDK, BTerrain and VC++ 2010.
DBPro code terrain multitexturing work fine:
TerrainObjectID = 1
load image "images/rock4s.png", 2 ` low altitude
load image "images/grass1s.png", 1 ` medium altitude
load image "images/snows.png", 3 ` high altitude
load image "tropicalrgb.tga", 4 ` steep slopes
texture object 1, 0, 1
texture object 1, 1, 2
texture object 1, 2, 3
texture object 1, 3, 4
load effect "terrainFXv2.fx", 1,0,0
set object effect 1, 1
In VC++ this code work fine too:
dbCreateObjectPlane ( 1000, 1000, 1, 90000);
dbTextureObject ( 90000,TERRA_DEATIL_LOW, 0,0);
dbTextureObject ( 90000,TERRA_DEATIL_ME,1,0);
dbTextureObject ( 90000,TERRA_DEATIL_HI,2,0);
dbTextureObject ( 90000,TERRA_COLOR_TEXTURE,3,0);
dbLoadEffect("Resource/FX/terrainFXv2.fx",0,0,TerrainFX );
dbSetObjectEffect(90000, TerrainFX);
In VC++ this code make BLACK terrain
:
BT_BuildTerrain(TerrainID,TERRAIN_MODEL,1);
dbTextureObject ( TERRAIN_MODEL,TERRA_DEATIL_LOW, 0);
dbTextureObject ( TERRAIN_MODEL,TERRA_DEATIL_ME,1);
dbTextureObject ( TERRAIN_MODEL,TERRA_DEATIL_HI,2);
dbTextureObject ( TERRAIN_MODEL,TERRA_COLOR_TEXTURE,3);
dbLoadEffect("Resource/FX/terrainFXv2.fx",0,0,TerrainFX );
dbSetObjectEffect(TERRAIN_MODEL, TerrainFX);
BT Terrain dont support shaders in DarkGDK?
ps. shader code:
// Green Gandalf's Terrain Shader v2.0
// blends three images together using a fourth texture
// to give a detailed terrain
// Created 12 October 2006, modified 18 January 2007.
float4x4 wvp : WorldViewProjection;
float2 repeatScale = {48, 48};
float4 lightDirection = {-0.707107, -0.707107, 0.0, 1.0};
float ambientColour = 0.5;
float4 lightColour = {1.0, 1.0, 1.0, 1.0};
texture detailMap1 <string ResourceName = "";>;
sampler2D detailSample1 = sampler_state
{texture = (detailMap1);
minfilter = linear;
magfilter = linear;
mipfilter = linear;
addressU = wrap;
addressV = wrap;
};
texture detailMap2 <string ResourceName = "";>;
sampler2D detailSample2 = sampler_state
{texture = (detailMap2);
minfilter = linear;
magfilter = linear;
mipfilter = linear;
addressU = wrap;
addressV = wrap;
};
texture detailMap3 <string ResourceName = "";>;
sampler2D detailSample3 = sampler_state
{texture = (detailMap3);
minfilter = linear;
magfilter = linear;
mipfilter = linear;
addressU = wrap;
addressV = wrap;
};
texture rgbaMap <string ResourceName = "";>;
sampler2D rgbaSample = sampler_state
{texture = (rgbaMap);
minfilter = linear;
magfilter = linear;
mipfilter = linear;
addressU = wrap;
addressV = wrap;
};
struct VS_Input
{ float4 pos : position;
float4 UV : texcoord0;
};
struct VS_Output
{ float4 pos : position;
float4 UV : texcoord0;
};
struct PS_Input
{ float4 UV : texcoord0;
};
struct PS_Output { float4 colour : color; };
VS_Output V_Shader(VS_Input In, VS_Output Out)
{ Out.pos = mul(In.pos,wvp);
Out.UV = In.UV;
return Out;
};
PS_Output P_Shader(PS_Input In, PS_Output Out)
{ float4 rgbaColours = tex2D(rgbaSample, In.UV);
float4 baseColour = tex2D(detailSample1, repeatScale * In.UV) * rgbaColours.r;
baseColour += tex2D(detailSample2, repeatScale * In.UV) * rgbaColours.g;
baseColour += tex2D(detailSample3, repeatScale * In.UV) * rgbaColours.b;
Out.colour = baseColour* ambientColour;
return Out;
};
technique terrainBlendv3
{
pass p0
{
VertexShader = compile vs_2_0 V_Shader();
PixelShader = compile ps_2_0 P_Shader();
}
}
zzz!