Announcement

Collapse
No announcement yet.

WW 1.4 : Fixing broken plugins (renderable)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • WW 1.4 : Fixing broken plugins (renderable)

    There have been changes to WW rendering engine that break most plug-in that have a renderable layer. I'm in the process of fixing mine, here are my notes so far :

    Recenter World

    One of the change in 1.4 is that the world is not anymore centered on the origin at all time. This is to deal with camera 'jitter' and floating point precision. This code has to be added before drawing :

    Code:
    drawArgs.device.Transform.World *= Matrix.Translation(
       (float)-drawArgs.WorldCamera.ReferenceCenter.X,
       (float)-drawArgs.WorldCamera.ReferenceCenter.Y,
       (float)-drawArgs.WorldCamera.ReferenceCenter.Z
       );
    Textures

    For some reasons, many textured surface now render as pure white... i could fix that with this code before drawing :

    Code:
    device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
    device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
    device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
    device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
    I hope this may help others with their plug-ins.
    My World Wind Java Blog & WW.net Plugins page

  • #2
    There is another change you have to make for sprites too. I think the method that is supposed to project points from the world to the screen doesn't take that camera reference center offset into account. I managed to work around it for Mashi's Image Overlay plugin:

    Code:
    // camera jitter fix
    drawArgs.device.Transform.World = Matrix.Translation(
        (float)-drawArgs.WorldCamera.ReferenceCenter.X,
        (float)-drawArgs.WorldCamera.ReferenceCenter.Y,
        (float)-drawArgs.WorldCamera.ReferenceCenter.Z
        );
    
    
    // CameraBase.Project appears to not work using the transformed world matrix?
    // Old code:
    //Vector3 pointScreenXy = drawArgs.WorldCamera.Project(worldPoint);
    
    //... so project from world to screen manually with the transformed world matrix
    // New Code:
    Vector3 pointScreenXy = worldPoint;
    pointScreenXy.Project(drawArgs.WorldCamera.Viewport,
        drawArgs.WorldCamera.ProjectionMatrix,
        drawArgs.WorldCamera.ViewMatrix,
        drawArgs.device.Transform.World
        );
    
    //camera jitter fix
    drawArgs.device.Transform.World = drawArgs.WorldCamera.WorldMatrix;
    Before this change, the sprites were rendering way up in the air above the point where they were supposed to be.

    Maybe someone who understands this better than I can fix the CameraBase.Project method to work correctly in this situation.
    Last edited by withak; 11-06-2006, 10:43 PM.

    Comment


    • #3
      RenderPriority

      Layers RenderPriority is not handled as before... I'm not sure i ever understood how it was affecting the rendering order, but something has changed.

      Now RenderPriority.AtmosphericImages renders AFTER RenderPriority.SurfaceImages.

      I would guess that this layer property is now doing what it was supposed to do before - defining the proper rendering order. But i didnt test all values...
      My World Wind Java Blog & WW.net Plugins page

      Comment


      • #4
        More on RenderPriority

        Some time ago i tried various ways in hope of having some grasp over the layers rendering order... and i tried this :

        Code:
        this.RenderPriority = RenderPriority.Custom - 1; // Custom minus 1 (no render)
        At the time, it probably didnt change the rendering order - and didnt hurt, but now it will not render at all ! So keep it straight :

        Code:
        this.RenderPriority = RenderPriority.Custom; // Good
        Note : i think we should gather all that on a wiki page... It would have been nice if Chris had left us some notes though.
        My World Wind Java Blog & WW.net Plugins page

        Comment


        • #5
          RenderState[0] options and alpha

          Still trying to get the Planetary Rings textures right... I could use some help here

          The rings projected sahdows on Saturn is a textured half sphere using CustomVertex.PositionColoredTextured vertex. That means that the final rendering of the texture should have both the vertex alpha channel and the ring texture alpha channel combined.

          The vertex alpha is especialy useful in this case to fade the projected shadow when it wraps on the night side and to suppress any artefact at the 'bottom' of the dome - which otherwise shows a brown stripe.

          This is broken in WW 1.4 : the vertex alpha is ignored. The ring shadow can be seen on the night side and the brown strip shows 'below' the rings.

          I'm confused about all the RenderState and TextureState[0] options... any idea someone
          Last edited by patmurris; 11-10-2006, 04:53 AM.
          My World Wind Java Blog & WW.net Plugins page

          Comment


          • #6
            This was greatly helpful, thanks!

            Comment

            Working...
            X