I'm so close. All I am seeing is a flat square that is slightly off-white due to 80% ambient light, but no texture. As far as I know the code is so close. I just don't know what my mistake is. I'm guessing my parameters are wrong.
Here is the material file.
Code:
fragment_program MyFragmentShader1 cg
{
source WorldCraftTerrainShaders.cg
entry_point MyFragmentShader1
profiles ps_1_1 arbfp1
default_params
{
param_named_auto world world_matrix
}
}
vertex_program MyVertexShader1 cg
{
source WorldCraftTerrainShaders.cg
entry_point MyVertexShader1
profiles vs_1_1 arbvp1
default_params
{
param_named_auto worldViewMatrix worldviewproj_matrix
param_named_auto world world_matrix
}
}
material Worldcraft/Greengrass
{
technique
{
pass
{
fragment_program_ref MyFragmentShader1
{
}
texture_unit
{
texture grass_1024.jpg
}
}
}
}
Here is the cg file.
Code:
void MyFragmentShader1(float4 position : POSITION,
float4 worldPosition : TEXCOORD0,
out float4 color: COLOR
uniform float4x4 world)
{
worldPosition = mul(world, position);
color = tex2D(texture, WorldPosition.xy / 10.0f);
}
void MyVertexShader1(float4 position : POSITION,
out float4 oPosition : POSITION,
out float4 worldPosition : TEXCOORD0,
uniform float4x4 worldViewMatrix,
uniform float4x4 world)
{
}
The vertex shader is not being used currently.
So am I messing up a parameter or miscalculating the world space?