I managed to get terrain splatting using a color texture plus four terrain textures. I am trying to add a sixth texture to use as a grid. I am at a total loss on what I am doing wrong for adding the 6th texture.
python:
colorTexture = Texture()
colorTexture.load(colormap)
# Textureize
grassTexture = loader.loadTexture("Textures/grass.png")
rockTexture = loader.loadTexture("Textures/rock.jpg")
rockTexture.setWrapU(Texture.WMMirror)
rockTexture.setWrapV(Texture.WMMirror)
sandTexture = loader.loadTexture("Textures/sand.jpg")
snowTexture = loader.loadTexture("Textures/ice.png")
snowTexture.setWrapU(Texture.WMMirror)
snowTexture.setWrapV(Texture.WMMirror)
# Grid for city placement and guide and stuff
gridTexture = loader.loadTexture("Textures/grid.png")
gridTexture.setWrapU(Texture.WMRepeat)
gridTexture.setWrapV(Texture.WMRepeat)
# Set multi texture
# Source https://discourse.panda3d.org/viewtopic.php?t=4536
root.setTexture( TextureStage('color'),colorTexture )
root.setTexture( TextureStage('rock'),rockTexture )
root.setTexture( TextureStage('grass'),grassTexture )
root.setTexture( TextureStage('sand'), sandTexture)
root.setTexture( TextureStage('snow'), snowTexture )
root.setTexture( TextureStage('grid'), gridTexture )
root.setShader(loader.loadShader('Shaders/terraintexture.sha'))
terrain.update()
Shader
//Cg
//
//Cg profile arbvp1 arbfp1
//from https://discourse.panda3d.org/viewtopic.php?t=4536
void vshader( in float4 vtx_position : POSITION,
in float2 vtx_texcoord0 : TEXCOORD0,
in uniform float4x4 mat_modelproj,
out float4 l_position : POSITION,
out float2 l_texcoord0 : TEXCOORD0,
out float2 l_detail1 : TEXCOORD1,
out float2 l_detail2 : TEXCOORD2,
out float2 l_detail3 : TEXCOORD3,
out float2 l_detail4 : TEXCOORD4,
out float2 l_detail5 : TEXCOORD5)
{
l_position = mul(mat_modelproj,vtx_position);
l_texcoord0 = vtx_texcoord0;
//detail texture coordinates scaled, we must get the correct scale fator to make terrain look like in EarthSculptor
l_detail1 = vtx_texcoord0; //* 27.365000 in EarthSculptor
l_detail2 = vtx_texcoord0; //*20.000000 in EarthSculptor
l_detail3 = vtx_texcoord0; //*22.389999 in EarthSculptor
l_detail4 = vtx_texcoord0; //*22.389999 in EarthSculptor
l_detail5 = vtx_texcoord0; //Tried 0.0001 to 10000, no dice
}
void fshader( in float4 l_position : POSITION,
in float2 l_texcoord0 : TEXCOORD0,
in float2 l_detail1 : TEXCOORD1,
in float2 l_detail2 : TEXCOORD2,
in float2 l_detail3 : TEXCOORD3,
in float2 l_detail4 : TEXCOORD4,
in float2 l_detail5 : TEXCOORD5,
in uniform sampler2D tex_0 : TEXUNIT0,
in uniform sampler2D tex_1 : TEXUNIT1,
in uniform sampler2D tex_2 : TEXUNIT2,
in uniform sampler2D tex_3 : TEXUNIT3,
in uniform sampler2D tex_4 : TEXUNIT4,
in uniform sampler2D tex_5 : TEXUNIT5,
out float4 o_color : COLOR )
{
//add 4 detail colors
float4 alpha = tex2D(tex_0, l_texcoord0.xy);
o_color = tex2D(tex_1, l_detail1.xy) * alpha.x
+ tex2D(tex_2, l_detail2.xy) * alpha.y
+ tex2D(tex_3, l_detail3.xy) * alpha.z
+ tex2D(tex_4, l_detail4.xy) * alpha.w;
//
o_color = o_color + tex2D(tex_5, l_detail5.xy);
o_color.a = 1.0;
}
Thank you for any help.