This is a port of a shader I wrote a long time ago at University to Silverlight. It was originally written it Direct X and C++. I am not going to go into too much detail about the implementation but will mention key points I came across.
Using the Application:
- The light is a directional light facing the surface which can be moved from left to right in the x-axis. It is at a set distance from the surface.
- The light also gets rotated with the surface via the plane rotation.
- The surface parameters are used by the shader to determine the ratio’s of the diffuse, ambient and specular(the shininess) lighting of the surface.
- It is possible to drop your own texture and normal by dropping them on the two panels (png or jpg).
- Have fun playing around as you can create some quite random effects. (Update: I have just added the ability to use the webcam as the source, you can make a random ‘ice’ effect by using the second sample texture)
Background reading to understand the concepts:
Issues / annoyances while porting:
- In Silverlight there is no way to set a float3 in the pixel shader, so i registered a Point for the X/Y and also a float for the Z axis.
- Vector3 class from here. As I couldn’t be bothered to write my own, also has some very good descriptions of the class and each method.
- I cant for the life of me remember where I found the first 3 textures and normals. The others came from here.
- I took advantage of using my image loader here.
- Original shader: