XNA Creators Club Online
Page 1 of 1 (1 items)
Sort Posts: Previous Next

Toon rendering to a transparent background

Last post 07/11/2009 0:41 by lzcd. 0 replies.
  • 07/11/2009 0:41
    • (0)
    • premium membership MVP
    • Posts 4

    Toon rendering to a transparent background

    Hi,

    One of my current projects is utilising the shader(s) / code from the toon rendering sample.
    This is all working well except that I'd really like to be able to render objects in the 'background' *without* the toon effect.

    As I see it, there are two obsticles standing in my way:

    The first is that the background of the texture used to perform the postprocessing is set to an opaque colour:

    ...
      GraphicsDevice.SetRenderTarget(0, sceneRenderTarget);
      GraphicsDevice.Clear(Color.CornflowerBlue);
      effect.CurrentTechnique = cartoonEffect.Techniques["Lambert"];
    ...
    

    And the second is that the shader throws away any transparency information:

    ...
    float4 PixelShader(float2 texCoord : TEXCOORD0, uniform bool applyEdgeDetect,
      uniform bool applySketch,
      uniform bool sketchInColor) : COLOR0
    {
      // Look up the original color from the main scene.
      float3 scene = tex2D(SceneSampler, texCoord);
    ...
    
    ...
      return float4(scene, 1);
    ...
    

    Assuming that my random theories hold true, solving the first problem is trivially easy... and hopefully solving the second isn't significantly harder. :)

    Is this a problem that others have already solved... and would be willing to share a code snippet or hint on how they did so?

    Normally I'd be more than happy to sit down an nut this one out myself but time is short and there are larger, more terrifying code related dragons yet to slay thus a small boost in the right direction would be most appreciated.

    Regards,
    Luke
Page 1 of 1 (1 items) Previous Next