地形的构建ogre地形shader 析解

地形的构建

以一个terrainSize为513的Terrain为例子,他应该分成多少个tile呢?

由maxBatchSize这个参数决定,numTiles = (terrainSize-1) / (maxBatchSize-1)

加入maxBatchSize = 65,那么地形分成8*8的地形tile,一个tile 64*64的顶点,

maxBatchSize这个参数,一般默认为65,最大为129,为什么最大为129而不是257呢,因为Ogre为了显卡的通用性,采用16为顶点索引

索引数量不能超过2的16次方,如果顶点为257*257就超过呢。。。想起我的项目,就遇到这样的问题,导致有些不支持32为顶点索引的显卡,看不到模型。

minBatchSize这个参数决定了tile的size在减少到某个程度后应该和周围得3个兄弟tile合并成一个tile,一般来说,这个值不要和maxBatchSize差距太多倍

因为Ogre只是在最小LOD的时候才会和周围3个兄弟tile合并成一个tile,而不会在中间的LOD级别合并的.

513 x 513   65/33:
LODlevels = log2(513 - 1) - log2(33 - 1) + 1 = 9 - 5 + 1 = 5
TreeDepth = log2( (513 - 1) / (65 - 1) ) + 1 = log2(512 / 64) + 1 = log2(8) + 1 = 3 + 1 = 4

LOD 0: 513 vertices, 8 x 8 titles, 64 x 64 vertices  8 x 65 vertex tiles (tree depth 3)   vdata 0-4 [ 129 x 4]
LOD 1: 257 vertices, 8 x 8 titles, 32 x 32 vertices  8 x 33 vertex tiles (tree depth 3)	  vdata 0-4 [ 129 x 4]
LOD 2: 129 vertices, 4 x 4 titles, 32 x 32 vertices  4 x 33 vertex tiles (tree depth 2)   vdata	0-4 [ 129 x 4]
LOD 3: 65  vertices, 2 x 2 titles, 32 x 32 vertices  2 x 33 vertex tiles (tree depth 1)   vdata 5   [ 129 x 1]
LOD 4: 32  vertices, 1 x 1 titles, 32 x 32 vertices  1 x 33 vertex tiles (tree depth 0)	  vdata 5   [ 129 X 1]

22:24:43: *** Terrain Vertex Program: OgreTerrain/52654158/sm2/vp/hlod ***
void main_vp(
float2 posIndex : POSITION,
float height  : TEXCOORD0,
float2 delta  : TEXCOORD1,
uniform float4x4 worldMatrix,
uniform float4x4 viewProjMatrix,
uniform float2   lodMorph,
uniform float4x4   posIndexToObjectSpace,
uniform float    baseUVScale,
uniform float4 uvMul_0, 
out float4 oPos : POSITION,
out float4 oPosObj : TEXCOORD0 
, out float4 oUVMisc : TEXCOORD1 // xy = uv, z = camDepth
, out float4 oUV0 : TEXCOORD2
, out float4 oUV1 : TEXCOORD3
, uniform float4 fogParams
, out float fogVal : COLOR
)
{
	float4 pos;
	pos = mul(posIndexToObjectSpace, float4(posIndex, height, 1));//根据索引,高度,得到顶点的本地坐标位置 
																	/* // centre the terrain on local origin	
																	mBase = -mWorldSize * 0.5;  mWorldsize = 12000;
																	// scale determines what 1 unit on the grid becomes in world space
																	mScale =  mWorldSize / (Real)(mSize-1); mSize = 513;
																	//outpos->y = height (z), 
																	
																	(*posIndexToObjectSpace)[1][2] = 1.0f;
																	//outpos->x = x * mScale + mBase;
																	(*posIndexToObjectSpace)[0][0] = mScale;
																	(*posIndexToObjectSpace)[0][3] = mBase;
																	//outpos->z = y * -mScale - mBase;
																	(*posIndexToObjectSpace)[2][1] = -mScale;
																	(*posIndexToObjectSpace)[2][3] = -mBase;*/
																	
   	float2 uv = float2(posIndex.x * baseUVScale, 1.0 - (posIndex.y * baseUVScale));//编码顶点纹理坐标 (baseUVScale = 1 / (terrain->mSize -1)
	float4 worldPos = mul(worldMatrix, pos);//得到顶点的世界坐标,
	oPosObj = pos;//本地坐标输出到TEXCOORD0
	float toMorph = -min(0, sign(delta.y - lodMorph.y));//lodMorph.x=lodTransition,logMorph.y=currentLod + baseLod +1,sign去符号,小于0取-1,等于0取0,大于0取1,
	worldPos.y += delta.x * toMorph * lodMorph.x;//重新计算顶点世界Y坐标
	oUV0.xy =  uv.xy * uvMul_0.r;//根据各层的worldsize计算第一层第一张纹理的坐标,输出到TEXTOORD2.xy,rgba分别对应各层的worldsize
	oUV0.zw =  uv.xy * uvMul_0.g;//根据各层的worldsize计算第一层第二张纹理的坐标,输出到TEXTOORD2.zw
	oUV1.xy =  uv.xy * uvMul_0.b;//根据各层的worldsize计算第二层第一张纹理的坐标,输出到TEXTOORD3.xy
	oUV1.zw =  uv.xy * uvMul_0.a;//根据各层的worldsize计算第二层第二张纹理的坐标,输出到TEXTOORD3.xy
	oPos = mul(viewProjMatrix, worldPos);//计算顶点的观察投影后的坐标,放到POSITION
	oUVMisc.xy = uv.xy;//顶点纹理坐标输出到TEXCOORD1.xy;
	fogVal = saturate((oPos.z - fogParams.y) * fogParams.w);//截取雾颜色[0,1].rgba;
}

***   ***
22:24:43: *** Terrain Fragment Program: OgreTerrain/52654158/sm2/fp/hlod ***
float4 expand(float4 v)
{ 
	return v * 2 - 1;
}


float4 main_fp(
float4 vertexPos : POSITION,//顶点的观察投影变换后的坐标
float4 position : TEXCOORD0,//顶点的本地坐标
float4 uvMisc : TEXCOORD1,//顶点纹理坐标
float4 layerUV0 : TEXCOORD2, //第一层两张纹理计算后的坐标
float4 layerUV1 : TEXCOORD3, //第二层两张纹理计算后的坐标
uniform float3 fogColour, //输入的雾颜色
float fogVal : COLOR,//上一个程序截取的雾的颜色
uniform float3 ambient,//环境光颜色
uniform float4 lightPosObjSpace,//
uniform float3 lightDiffuseColour,//灯光漫反射颜色
uniform float3 lightSpecularColour,//灯光镜面反射颜色
uniform float3 eyePosObjSpace,//
uniform float4 scaleBiasSpecular,//镜面反射缩放值
uniform sampler2D globalNormal : register(s0)
, uniform sampler2D lightMap : register(s1)
, uniform sampler2D blendTex0 : register(s2)
, uniform sampler2D difftex0 : register(s3)
, uniform sampler2D normtex0 : register(s4)
, uniform sampler2D difftex1 : register(s5)
, uniform sampler2D normtex1 : register(s6)
, uniform sampler2D difftex2 : register(s7)
, uniform sampler2D normtex2 : register(s8)
) : COLOR
{
	float4 outputCol;//定义像素输出颜色
	float shadow = 1.0;//定义阴影值
	float2 uv = uvMisc.xy;//得到顶点纹理坐标
	outputCol = float4(0,0,0,1);//设置像素输出颜色a=1;
	float3 normal = expand(tex2D(globalNormal, uv)).rgb;//根据纹理坐标uv采样全局顶点(地形)法线纹理像素颜色值rgba,然后调用expand(rgba * 2 -1).rgb得到地形顶点法向量
	float3 lightDir = 
		lightPosObjSpace.xyz -  (position.xyz * lightPosObjSpace.w);//计算世界坐标系下灯光方向向量xyz;
	float3 eyeDir = eyePosObjSpace - position.xyz;//计算世界坐标系下的观察方向向量xyz;
	float3 diffuse = float3(0,0,0);//定义漫反射颜色diffuse.rgb
	float specular = 0;//定义镜面反射系数
	float4 blendTexVal0 = tex2D(blendTex0, uv);//根据顶点纹理坐标采样混合权重纹理,颜色值blendTexVal0.rgba
	float3 tangent = float3(1, 0, 0);//定义切线向量
	float3 binormal = normalize(cross(tangent, normal));//计算切线向量和全局顶点法向量的叉积(切线和顶点法向量的上向量↑)并单位化.
	tangent = normalize(cross(normal, binormal));//重新计算切线向量
	float3x3 TBN = float3x3(tangent, binormal, normal);//根据上面的三个向量,构造3x3矩阵TBN,类似于带上向量的摄像机坐标系(UVN相机系统)
	float4 litRes, litResLayer;
	float3 TSlightDir, TSeyeDir, TShalfAngle, TSnormal;
	float displacement;
	TSlightDir = normalize(mul(TBN, lightDir));//将灯光方向转换到UVN坐标系下,并单位化到TSlightDir
	TSeyeDir = normalize(mul(TBN, eyeDir));//将观察方向转换到UVN坐标系下,并单位化到TSeyeDir;
	float2 uv0 = layerUV0.xy;//取第一层第一张纹理坐标
	displacement = tex2D(normtex0, uv0).a
		* scaleBiasSpecular.x + scaleBiasSpecular.y;//根据第一层第一张纹理坐标采样normtex0的a值,计算displacement = a * scaleBiasSpecular.x + scaleBiasSpecular.y;
	uv0 += TSeyeDir.xy * displacement;//重新计算第一层第一张纹理坐标 (modify UV)
	TSnormal = expand(tex2D(normtex0, uv0)).rgb;//根据第一层第一张纹理坐标采样normatex0像素颜色rgb,然后调用expand(rgb *2 -1).rgb 得到TSnormal(位移法向量)//access TS normal map
	TShalfAngle = normalize(TSlightDir + TSeyeDir);//单位化UVN相机系统坐标系下的(光照向量+ 观察向量)
	litResLayer = lit(dot(TSlightDir, TSnormal), dot(TShalfAngle, TSnormal), scaleBiasSpecular.z);//得到光照矢量
	litRes = litResLayer;//光照矢量放入litRes
	float4 diffuseSpecTex0 = tex2D(difftex0, uv0);//根据modify UV 采样纹理difftex0,得到纹理difftex0的rgba值,
	diffuse = diffuseSpecTex0.rgb;//取rgb作为漫反射颜色值
	specular = diffuseSpecTex0.a;//取a作为镜面反射系数
	float2 uv1 = layerUV0.zw;//取第一层第二张纹理坐标
	displacement = tex2D(normtex1, uv1).a
		* scaleBiasSpecular.x + scaleBiasSpecular.y;//根据第一层第二张纹理坐标采样normtex1的a值,计算displacement = a * scaleBiasSpecular.x + scaleBiasSpecular.y;
	uv1 += TSeyeDir.xy * displacement;//modify uv;
	TSnormal = expand(tex2D(normtex1, uv1)).rgb;//根据第一层第二张纹理modify uv采样normtex1像素颜色值rgb,然后调用expand(rgb *2 -1).rgb 得到TSnormal(位移法向量)//access TS normal map
	TShalfAngle = normalize(TSlightDir + TSeyeDir);//单位化UVN相机系统坐标系的(光照向量 + 观察向量)
	litResLayer = lit(dot(TSlightDir, TSnormal), dot(TShalfAngle, TSnormal), scaleBiasSpecular.z);//得到光照矢量
	litRes = lerp(litRes, litResLayer, blendTexVal0.r);//Returns litRes = litRes + blenTexVal0.r(litResLayer - litRes).插值得到normalTex0和normalTex1混合颜色值rgba-->litRes.
	float4 diffuseSpecTex1 = tex2D(difftex1, uv1);//根据第一层第二张纹理坐标modify uv采样difftex1-->diffuseSpecTex1.rgba,
	diffuse = lerp(diffuse, diffuseSpecTex1.rgb, blendTexVal0.r);//Returns diffuse = diffuse(=diffusespecTex0.rgb) + blenTexVal0.r*(diffuseSpecTex1.rgb- diffuse(=diffusespecTex0.rgb)), 插值得到diffuseSpecTex0和diffuseSpecTex1的混合颜色值rgb-->diffuse.
	specular = lerp(specular, diffuseSpecTex1.a, blendTexVal0.r);//Returns specular= specular(=diffuseSpecTex0.a)+ blenTexVal0.r*(diffuseSpecTex1.a - specular(=diffuseSpecTex0.a)),插值得到diffuseSpecTex0和diffuseSpecTex1的镜面反射混合系数-->specular.
	float2 uv2 = layerUV1.xy;//取第二层第一张纹理坐标
	displacement = tex2D(normtex2, uv2).a
		* scaleBiasSpecular.x + scaleBiasSpecular.y;
	uv2 += TSeyeDir.xy * displacement;//modify uv;
	TSnormal = expand(tex2D(normtex2, uv2)).rgb;//根据第二层第一张纹理坐标采样normtex2像素颜色值rgba,然后调用expand(rgba *2 -1).rgb 得到TSnormal(位移法向量)//access TS normal map
	TShalfAngle = normalize(TSlightDir + TSeyeDir);
	litResLayer = lit(dot(TSlightDir, TSnormal), dot(TShalfAngle, TSnormal), scaleBiasSpecular.z);//得到光照矢量
	litRes = lerp(litRes, litResLayer, blendTexVal0.g);//Returns litRes = litRes + blenTexVal0.g*(litResLayer - litRes).插值得到第一层normalTex0,第一层normalTex1,第二层的normalTex2混合颜色值rgba-->litRes.
	float4 diffuseSpecTex2 = tex2D(difftex2, uv2);//根据第二层第一张纹理修改后的纹理坐标采样difftex2像素颜色值rgba
	diffuse = lerp(diffuse, diffuseSpecTex2.rgb, blendTexVal0.g);//插值计算第一层diffuseSpecTex0,diffuseSpceTec1与第二层diffuseSpecTex2的rgb-->diffuse;
	specular = lerp(specular, diffuseSpecTex2.a, blendTexVal0.g);//插值计算第一层diffuseSpecTex0,diffuseSpceTec1 与第二层diffuseSpecTex2的a-->speclar;
	shadow = tex2D(lightMap, uv).r;//根据顶点纹理采样光照阴影图,取r值作为阴影值
	outputCol.rgb += ambient * diffuse + litRes.y * lightDiffuseColour * diffuse * shadow;设置像素输出颜色outputCol(0,0,0,1)+=ambient * (diffusetex0,1,2).rgb +(normaltex0,1,2).y *  光照漫反射颜色 * (diffusetex0,1,2).rgb * 光照阴影.r
	outputCol.rgb += litRes.z * lightSpecularColour * specular * shadow; //像素输出颜色 += (normalTex0,1,2).z * 光照镜面反射颜色 * (diffuse0,1,2).a * 光照阴影.r
	outputCol.rgb = lerp(outputCol.rgb, fogColour, fogVal);//像素输出颜色 += 插值雾颜色
	return outputCol;
}

***   ***
22:24:44: *** Terrain Vertex Program: OgreTerrain/52654158/sm2/vp/llod ***
void main_vp(
float2 posIndex : POSITION,
float height  : TEXCOORD0,
float2 delta  : TEXCOORD1,
uniform float4x4 worldMatrix,
uniform float4x4 viewProjMatrix,
uniform float2   lodMorph,
uniform float4x4   posIndexToObjectSpace,
uniform float    baseUVScale,
uniform float4 uvMul_0, 
out float4 oPos : POSITION,
out float4 oPosObj : TEXCOORD0 
, out float4 oUVMisc : TEXCOORD1 // xy = uv, z = camDepth
, uniform float4 fogParams
, out float fogVal : COLOR
)
{
	float4 pos;
	pos = mul(posIndexToObjectSpace, float4(posIndex, height, 1));
  	float2 uv = float2(posIndex.x * baseUVScale, 1.0 - (posIndex.y * baseUVScale));
	float4 worldPos = mul(worldMatrix, pos);
	oPosObj = pos;
	float toMorph = -min(0, sign(delta.y - lodMorph.y));
	worldPos.y += delta.x * toMorph * lodMorph.x;
	oPos = mul(viewProjMatrix, worldPos);
	oUVMisc.xy = uv.xy;
	fogVal = saturate((oPos.z - fogParams.y) * fogParams.w);
}

***   ***
22:24:44: *** Terrain Fragment Program: OgreTerrain/52654158/sm2/fp/llod ***
float4 expand(float4 v)
{ 
	return v * 2 - 1;
}


float4 main_fp(
float4 vertexPos : POSITION,
float4 position : TEXCOORD0,
float4 uvMisc : TEXCOORD1,
uniform float3 fogColour, 
float fogVal : COLOR,
uniform float3 ambient,
uniform float4 lightPosObjSpace,
uniform float3 lightDiffuseColour,
uniform float3 lightSpecularColour,
uniform float3 eyePosObjSpace,
uniform float4 scaleBiasSpecular,
uniform sampler2D compositeMap : register(s0)
) : COLOR
{
	float4 outputCol;
	float shadow = 1.0;
	float2 uv = uvMisc.xy;
	outputCol = float4(0,0,0,1);
	float3 lightDir = 
		lightPosObjSpace.xyz -  (position.xyz * lightPosObjSpace.w);
	float3 eyeDir = eyePosObjSpace - position.xyz;
	float3 diffuse = float3(0,0,0);
	float specular = 0;
	float4 composite = tex2D(compositeMap, uv);
	diffuse = composite.rgb;
	outputCol.rgb = diffuse;
	outputCol.rgb = lerp(outputCol.rgb, fogColour, fogVal);
	return outputCol;
}

***   ***
22:24:46: WARNING: Texture instance 'OgreTerrain/52654158/nm' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:46: WARNING: Texture instance 'OgreTerrain/52654158/lm' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:46: WARNING: Texture instance 'TerrBlend1' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:46: WARNING: Texture instance 'OgreTerrain/52654158/comp' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:46: WARNING: Texture instance 'OgreTerrain/52654158/nm' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:46: WARNING: Texture instance 'OgreTerrain/52654158/lm' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:46: WARNING: Texture instance 'TerrBlend1' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:46: D3D9 : Loading 2D Texture, image name : 'dirt_grayrocky_diffusespecular.dds' with 5 mip map levels
22:24:46: D3D9 : Loading 2D Texture, image name : 'dirt_grayrocky_normalheight.dds' with 5 mip map levels
22:24:46: D3D9 : Loading 2D Texture, image name : 'grass_green-01_diffusespecular.dds' with 5 mip map levels
22:24:46: D3D9 : Loading 2D Texture, image name : 'grass_green-01_normalheight.dds' with 5 mip map levels
22:24:46: D3D9 : Loading 2D Texture, image name : 'growth_weirdfungus-03_diffusespecular.dds' with 5 mip map levels
22:24:46: D3D9 : Loading 2D Texture, image name : 'growth_weirdfungus-03_normalheight.dds' with 5 mip map levels
22:24:46: WARNING: Texture instance 'OgreTerrain/52654158/comp' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
22:24:50: *** Terrain Vertex Program: OgreTerrain/52654158/sm2/vp/comp ***
void main_vp(
float4 pos : POSITION,
float2 uv  : TEXCOORD0,
uniform float4x4 worldMatrix,
uniform float4x4 viewProjMatrix,
uniform float2   lodMorph,
uniform float4 uvMul_0, 
out float4 oPos : POSITION,
out float4 oPosObj : TEXCOORD0 
, out float4 oUVMisc : TEXCOORD1 // xy = uv, z = camDepth
, out float4 oUV0 : TEXCOORD2
, out float4 oUV1 : TEXCOORD3
)
{
	float4 worldPos = mul(worldMatrix, pos);//本地坐标到世界坐标
	oPosObj = pos;//原样输出本地坐标到POSITION
	
	oUV0.xy =  uv.xy * uvMul_0.r;//根据各层的worldsize计算第一层第一张纹理的坐标,输出到TEXTOORD2.xy,rgba分别对应各层的worldsize
	oUV0.zw =  uv.xy * uvMul_0.g;	//根据各层的worldsize计算第一层第二张纹理的坐标,输出到TEXTOORD2.zw
	oUV1.xy =  uv.xy * uvMul_0.b;	//根据各层的worldsize计算第二层第一张纹理的坐标,输出到TEXTOORD3.xy
	oUV1.zw =  uv.xy * uvMul_0.a;	//根据各层的worldsize计算第二层第二张纹理的坐标,输出到TEXTOORD3.xy
	oPos = mul(viewProjMatrix, worldPos);//世界坐标到观察透视坐标,输出到TEXCOORD0
	oUVMisc.xy = uv.xy;//原样输出顶点纹理坐标到TEXCOORD1
}

***   ***
22:24:50: *** Terrain Fragment Program: OgreTerrain/52654158/sm2/fp/comp ***
float4 expand(float4 v)
{ 
	return v * 2 - 1;
}


float4 main_fp(
float4 vertexPos : POSITION,//上一个vp输出的本地坐标
float4 position : TEXCOORD0,//上一个vp输出的观察投影坐标(locPos * worldMat * viewMat * ProjMat)
float4 uvMisc : TEXCOORD1,//上一个vp原样输出的顶点纹理坐标
float4 layerUV0 : TEXCOORD2, //上一个vp计算的第一层两张纹理的坐标
float4 layerUV1 : TEXCOORD3, //上一个vp计算的第二层两张纹理的坐标
uniform float3 ambient,
uniform float4 lightPosObjSpace,
uniform float3 lightDiffuseColour,
uniform float3 lightSpecularColour,
uniform float3 eyePosObjSpace,
uniform float4 scaleBiasSpecular,
uniform sampler2D globalNormal : register(s0)
, uniform sampler2D lightMap : register(s1)
, uniform sampler2D blendTex0 : register(s2)
, uniform sampler2D difftex0 : register(s3)
, uniform sampler2D normtex0 : register(s4)
, uniform sampler2D difftex1 : register(s5)
, uniform sampler2D normtex1 : register(s6)
, uniform sampler2D difftex2 : register(s7)
, uniform sampler2D normtex2 : register(s8)
) : COLOR
{
	float4 outputCol;
	float shadow = 1.0;
	float2 uv = uvMisc.xy;
	outputCol = float4(0,0,0,1);
	float3 normal = expand(tex2D(globalNormal, uv)).rgb;
	float3 lightDir = 
		lightPosObjSpace.xyz -  (position.xyz * lightPosObjSpace.w);
	float3 eyeDir = eyePosObjSpace - position.xyz;
	float3 diffuse = float3(0,0,0);
	float specular = 0;
	float4 blendTexVal0 = tex2D(blendTex0, uv);
	float3 tangent = float3(1, 0, 0);
	float3 binormal = normalize(cross(tangent, normal));
	tangent = normalize(cross(normal, binormal));
	float3x3 TBN = float3x3(tangent, binormal, normal);
	float4 litRes, litResLayer;
	float3 TSlightDir, TSeyeDir, TShalfAngle, TSnormal;
	float displacement;
	TSlightDir = normalize(mul(TBN, lightDir));
	TSeyeDir = normalize(mul(TBN, eyeDir));
	float2 uv0 = layerUV0.xy;
	TSnormal = expand(tex2D(normtex0, uv0)).rgb;
	TShalfAngle = normalize(TSlightDir + TSeyeDir);
	litResLayer = lit(dot(TSlightDir, TSnormal), dot(TShalfAngle, TSnormal), scaleBiasSpecular.z);
	litRes = litResLayer;
	float4 diffuseSpecTex0 = tex2D(difftex0, uv0);
	diffuse = diffuseSpecTex0.rgb;
	specular = diffuseSpecTex0.a;
	float2 uv1 = layerUV0.zw;
	TSnormal = expand(tex2D(normtex1, uv1)).rgb;
	TShalfAngle = normalize(TSlightDir + TSeyeDir);
	litResLayer = lit(dot(TSlightDir, TSnormal), dot(TShalfAngle, TSnormal), scaleBiasSpecular.z);
	litRes = lerp(litRes, litResLayer, blendTexVal0.r);
	float4 diffuseSpecTex1 = tex2D(difftex1, uv1);
	diffuse = lerp(diffuse, diffuseSpecTex1.rgb, blendTexVal0.r);
	specular = lerp(specular, diffuseSpecTex1.a, blendTexVal0.r);
	float2 uv2 = layerUV1.xy;
	TSnormal = expand(tex2D(normtex2, uv2)).rgb;
	TShalfAngle = normalize(TSlightDir + TSeyeDir);
	litResLayer = lit(dot(TSlightDir, TSnormal), dot(TShalfAngle, TSnormal), scaleBiasSpecular.z);
	litRes = lerp(litRes, litResLayer, blendTexVal0.g);
	float4 diffuseSpecTex2 = tex2D(difftex2, uv2);
	diffuse = lerp(diffuse, diffuseSpecTex2.rgb, blendTexVal0.g);
	specular = lerp(specular, diffuseSpecTex2.a, blendTexVal0.g);
	shadow = tex2D(lightMap, uv).r;
	outputCol.rgb += ambient * diffuse + litRes.y * lightDiffuseColour * diffuse * shadow;
	outputCol.a = shadow;
	return outputCol;
}


18:07:02: Terrain created; size=1025 minBatch=33 maxBatch=65 treeDepth=5 lodLevels=6 leafLods=2
18:07:04: Terrain::distributeVertexData processing source terrain size of 1025
18:07:04:   Assigning vertex data, resolution=1025 startDepth=3 endDepth=5 splits=8
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:0 0 129 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:128 0 257 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:0 128 129 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:128 128 257 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:256 0 385 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:384 0 513 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:256 128 385 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:384 128 513 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:0 256 129 385
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:128 256 257 385
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:0 384 129 513
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:128 384 257 513
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:256 256 385 385
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:384 256 513 385
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:256 384 385 513
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:384 384 513 513
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:512 0 641 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:640 0 769 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:512 128 641 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:640 128 769 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:768 0 897 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:896 0 1025 129
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:768 128 897 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:896 128 1025 257
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:512 256 641 385
18:07:04: AsignVertices:16641 = 129 ^ 2
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts:645 = 129 x 5
18:07:04: numVerts Sum:17931
18:07:04: Rect:640 256 769 385
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:512 384 641 513
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:640 384 769 513
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:768 256 897 385
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:896 256 1025 385
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:768 384 897 513
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:896 384 1025 513
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:0 512 129 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:128 512 257 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:0 640 129 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:128 640 257 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:256 512 385 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:384 512 513 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:256 640 385 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:384 640 513 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:0 768 129 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:128 768 257 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:0 896 129 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:128 896 257 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:256 768 385 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:384 768 513 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:256 896 385 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:384 896 513 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:512 512 641 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:640 512 769 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:512 640 641 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:640 640 769 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:768 512 897 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:896 512 1025 641
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:768 640 897 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:896 640 1025 769
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:512 768 641 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:640 768 769 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:512 896 641 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:640 896 769 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:768 768 897 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:896 768 1025 897
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:768 896 897 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:896 896 1025 1025
18:07:05:   Assigning vertex data, resolution=257 startDepth=1 endDepth=3 splits=2
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:0 0 513 513
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:512 0 1025 513
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:0 512 513 1025
18:07:05: AsignVertices:16641 = 129 ^ 2
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts:645 = 129 x 5
18:07:05: numVerts Sum:17931
18:07:05: Rect:512 512 1025 1025
18:07:05: AsignVertices:4225 = 65 ^ 2
18:07:05: numVerts:195 = 65 x 3
18:07:05: numVerts:195 = 65 x 3
18:07:05: numVerts Sum:4615
18:07:05: Rect:0 0 1025 1025
18:07:05:   Assigning vertex data, resolution: 65 startDepth=0 endDepth=1 splits=1
18:07:05: Terrain::distributeVertexData finished
18:07:05: uvMul_0 Vector4:120 400 60 120
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值