mouse_wheel = zoom | click_drag = rotate
// The 4x4 world view projection matrix. float4x4 worldViewProjection : WorldViewProjection; float4x4 World : World; // The texture sampler is used to access the texture bitmap in the fragment // shader. sampler texSampler0; // positions of the light and camera float3 light_pos; float3 camera_pos; // phong lighting components of the light source float4 light_ambient; float4 light_diffuse; float4 light_specular; // shininess of the material. (for specular lighting) float shininess; // input parameters for our vertex shader struct VertexShaderInput { float4 postion : POSITION; float3 normal : NORMAL; float4 color : COLOR; float2 tex : TEXCOORD0; // Texture coordinates }; // input parameters for our pixel shader // also the output parameters for our vertex shader struct PixelShaderInput { float4 postion : POSITION; float2 tex : TEXCOORD0; // Texture coordinates float3 normal : TEXCOORD1; float3 lightVector : TEXCOORD3; float3 viewPosition : TEXCOORD2; float4 color : COLOR; }; /** * Vertex Shader - vertex shader for phong illumination */ PixelShaderInput vertexShaderFunction(VertexShaderInput input) { PixelShaderInput output; output.postion = mul(input.postion, worldViewProjection); /** * lightVector - light vector * normal - normal vector * viewPosition - view vector (from camera) */ float3 lightVector = light_pos - input.postion.xyz; float3 normal = mul(input.normal, World); float3 viewPosition = camera_pos - input.postion.xyz; output.lightVector = lightVector; output.normal = normal; output.viewPosition = viewPosition; output.color = input.color; output.tex = input.tex; return output; } /** * Pixel Shader */ float4 pixelShaderFunction(PixelShaderInput input): COLOR { /*float3 lightVector = normalize(input.lightVector); float3 normal = normalize(input.normal); float3 viewPosition = normalize(input.viewPosition); float3 halfVector = normalize(lightVector + viewPosition); float4 phong_coeff = lit(dot(normal, lightVector), dot(normal, halfVector), shininess); float4 ambient = light_ambient * phong_coeff.x * input.color; float4 diffuse = light_diffuse * phong_coeff.y * input.color; float4 specular = light_specular * phong_coeff.z * input.color;*/ float4 texval = tex2D(texSampler0, input.tex); texval.a = texval.r; //float4 lighting = diffuse + specular; return texval; } // Here we tell our effect file *which* functions are // our vertex and pixel shaders. // #o3d VertexShaderEntryPoint vertexShaderFunction // #o3d PixelShaderEntryPoint pixelShaderFunction // #o3d MatrixLoadOrder RowMajor