Please view this AVI (DivX Codec, 1.1MB - reduced quality to reduce the size):
http://www.EvilMasterMindsInc.com/Image ... roblem.avi
Note the spinning roid and the shadow and lighting. The light source is behind the station (the sun , the yellow spot, is just peaking over the station) in the background. The static roids on either side of the spinning roid are casting a shadow correctly (i.e we are seeing the backside - the darkside - of the roid).
The light seems to be following only one side of the roid. There is only ONE light source (the sun).
Ogre.log is not reporting any problems. It parses all files with no errors (we have TRIVIAL logging turned on).
So, we could use some help with this:
roid3.material script file
Code: Select all
material roid3/SOLID/roid3.bmp
{
receive_shadows off
technique
{
pass
{
vertex_program_ref Shaders/sbvs
{
param_named_auto view_proj_matrix worldviewproj_matrix
param_named_auto light_position light_position 0
param_named_auto eye_position camera_position_object_space
param_named_auto inv_view_matrix inverse_worldview_matrix
}
fragment_program_ref Shaders/sbps
{
param_indexed_auto 2 light_specular_colour 0
param_indexed 3 float 0
param_indexed 4 float 1
param_indexed 5 float 1
param_indexed 6 float 100
param_indexed 7 float 1
param_indexed_auto 0 ambient_light_colour
param_indexed_auto 1 light_diffuse_colour 0
}
texture_unit
{
texture roid3f.png
}
texture_unit
{
texture roid3_nor.png
}
}
}
}
shaders.program file
Code: Select all
vertex_program Shaders/sbvs hlsl
{
source sbvs.txt
entry_point main
target vs_2_0
}
fragment_program Shaders/sbps asm
{
source sbps.asm
syntax ps_2_0
}
sbps.asm file
Code: Select all
//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.04.91.0000
//
// Parameters:
//
// float Ka;
// float Kd;
// float Ks;
// float4 ambient;
// sampler2D base_map;
// sampler2D bump_map;
// float bumpiness;
// float4 diffuse;
// float4 specular;
// float specular_power;
//
//
// Registers:
//
// Name Reg Size
// -------------- ----- ----
// ambient c0 1
// diffuse c1 1
// specular c2 1
// Ka c3 1
// Kd c4 1
// Ks c5 1
// specular_power c6 1
// bumpiness c7 1
// base_map s0 1
// bump_map s1 1
//
ps_2_0
def c8, 0.5, 0.5, 1, 0
def c9, -0.5, -0.5, -1, 2
dcl t0.xy
dcl t1.xyz
dcl t2.xyz
dcl_2d s0
dcl_2d s1
texld r1, t0, s1
texld r0, t0, s0
add r1.xyz, r1, c9
mov r0.w, c7.x
mad r1.xyz, r0.w, r1, c8
mad r1.xyz, c9.w, r1, c9.z
nrm r2.xyz, r1
nrm r1.xyz, t1
dp3 r3.x, r2, r1
mul r1.xyz, r0, c1
mul r0.xyz, r0, c0
max r0.w, r3.x, c8.w
mul r1.xyz, r1, c4.x
mul r1.xyz, r0.w, r1
nrm r3.xyz, t2
dp3 r2.x, r2, r3
mad r1.xyz, r0, c3.x, r1
max r1.w, r2.x, c8.w
pow r0.w, r1.w, c6.x
mov r1.w, c5.x
mul r0.xyz, r1.w, c2
mad r0.xyz, r0, r0.w, r1
mov r0.w, c8.z
mov oC0, r0
// approximately 32 instruction slots used (2 texture, 30 arithmetic)
sbvs.txt file
Code: Select all
float4x4 view_proj_matrix: register(c0);
float4 light_position: register(c8);
float4 eye_position: register(c9);
float4x4 inv_view_matrix;
struct VS_INPUT_STRUCT
{
float4 position: POSITION;
float3 normal: NORMAL;
float2 texcoord0: TEXCOORD0;
float3 binormal: BINORMAL0;
float3 tangent: TANGENT0;
};
struct VS_OUTPUT_STRUCT
{
float4 position: POSITION;
float2 bump_map: TEXCOORD0;
float3 light_vector: TEXCOORD1;
float3 half_angle: TEXCOORD2;
};
//**---------------------------------------------------------
//** Function: main
//** Description: Declare the main entry point for the shader
//** Input: VS_INPUT_STRUCT, derived from the stream
//** mapping parameters defined in the workspace
//** Returns: VS_OUTPUT_STRUCT
//**---------------------------------------------------------
VS_OUTPUT_STRUCT main( VS_INPUT_STRUCT vsInStruct )
{
VS_OUTPUT_STRUCT vsOutStruct; //** Declare the output struct
vsOutStruct.position = mul( view_proj_matrix, vsInStruct.position );
vsOutStruct.bump_map = vsInStruct.texcoord0;
//float3 binormal=cross(vsInStruct.tangent,vsInStruct.normal);
//float3 binormal=cross(vsInStruct.normal,vsInStruct.tangent);
float3 temp_light_position = mul( inv_view_matrix, light_position );
float3 temp_light_vector = temp_light_position - vsInStruct.position;
vsOutStruct.light_vector.x = dot( temp_light_vector, vsInStruct.normal );
vsOutStruct.light_vector.y = dot( temp_light_vector, vsInStruct.binormal);
vsOutStruct.light_vector.z = dot( temp_light_vector, vsInStruct.tangent );
float3 temp_eye_position = eye_position;
float3 temp_view_vector = temp_eye_position - vsInStruct.position;
float3 temp_view_vector2;
temp_view_vector2.x = dot( temp_view_vector, vsInStruct.tangent );
temp_view_vector2.y = dot( temp_view_vector, vsInStruct.binormal );
temp_view_vector2.z = dot( temp_view_vector, vsInStruct.normal );
vsOutStruct.half_angle = vsOutStruct.light_vector + temp_view_vector2;
return vsOutStruct; //** Return the resulting output struct
}

