Get rid of the margin and it doesn't work quite right.

Apr 20, 2010 at 8:12 PM
Hey, first of all ... I love the plane projection library (that's tucked inside the overall Silverlight Flow library) you've created for WPF. I was wondering if you knew that things don't work quite right if you remove the margin on the grid around the colored rectangles (obviously in the plane projection sample application). My expectation would that it would just clip what you can't see ... but it is doing something else entirely.
Apr 20, 2010 at 9:40 PM


I am aware of the issue, it is due to the way the ShaderEffect samples the input texture : sample coordinates are clamped to the [0,0 - 1,1] range, so when the effect try to sample something that is outside of the source texture, it receive the color of the source pixel that is the closest to the desired coordinate.

The workaround is to have a transparent border that will be sampled instead.

Something I will consider is to declare an effect padding of 1 pixel in the shader effet to automatically get rid of this strange artefact.

Apr 20, 2010 at 9:56 PM
That totally makes sense! Thanks for the reply. Hmm. To get this 1 pixel border ... are you considering modifying the current plane projection effect ... or are you suggesting creating another effect? If I could make a suggestion ... I would try to modify the current effect ... it seems as nested effects would be less performant ... and one of the main reasons to use this approach (vs WPF 3D) is for performance (the other reason being, of course, parity with Silverlight).
Apr 20, 2010 at 10:36 PM

You don't have to change the effect to workaround this problem:

Instead of doing <myControl><sstfuff:PlaneProjection.Projection><sstuff:PlaneProjection/></sstuff:PlaneProjection.Projection></myControl> you do:
<border background="Transparent"><sstfuff:PlaneProjection.Projection><sstuff:PlaneProjection/></sstuff:PlaneProjection.Projection><myControl margin="1" /></border>

The second way, is something I might do in the next version to avoid the need of a 1pixel margin

Apr 20, 2010 at 10:39 PM
Yes, I understood your workaround the first time ... it is what you are doing in the sample application. My suggestion was about what you might do in the future.