I was creating a plane that uses the following material.

Code: Select all

```
material PlanarEnv
{
technique
{
pass
{
texture_unit
{
texture ToastMapOfEarth.jpg
env_map planar
}
}
}
}
```

**The material doesn't work at all with RTSS.**

I found out that the problem lies in the vertex shading function FFP_GenerateTexCoord_EnvMap_Sphere found in \Media\RTShaderLib\[ShadingLanguage]\FFPLib_Texturing.[ShadingLanguage]

FFP_GenerateTexCoord_EnvMap_Sphere maps UV coordinates as a function of the object's Normal, denoted as 'N' as follows:

U = Nx / 2 + 0.5

V = Ny / 2 + 0.5

The reason it doesn't work is because all the normals in a plane have the same values, hence UV coordinates are the same, hence the problem.

In order To fix the issue I rewrote FFP_GenerateTexCoord_EnvMap_Sphere according to this document http://www.bluevoid.com/opengl/sig00/ad ... de184.html as follows:

Code: Select all

```
void FFP_GenerateTexCoord_EnvMap_Sphere(in float4x4 mWorld,
in float4x4 mView,
in float4x4 mWorldViewIT,
in float4 vPos,
in float3 vNormal,
in float4x4 mTexture,
out float2 vOut)
{
float4x4 worldview = mul(mView,mWorld);
float3 normal = normalize(mul(mWorldViewIT,float4(vNormal,0.0)).xyz);
float3 eyedir = normalize(mul(worldview, vPos)).xyz;
float3 r = reflect(eyedir, normal);
float two_p = 2.0 * sqrt( r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
vOut = mul(mTexture,float4(0.5 + r.x / two_p,0.5 - r.y / two_p,0.0,0.0)).xy;
}
```

The file OgreShaderFFPTexturing.cpp also had to be changed according to FFP_GenerateTexCoord_EnvMap_Sphere input parameters.

* notice the change of the input parameter mWorldIT to mWorldViewIT.

* 'ToastMapOfEarth.jpg' can be found here http://www.worldwidetelescope.org/docs/ ... fEarth.jpg