Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 30

Thread: [OpenGL] Earth atmosphere effect

  1. #11

    [OpenGL] Earth atmosphere effect

    What i was thinking to fix that is calculating the rotation matrix differently. Find out x,y,z for the center of planet as it is transformed with Modelview matrix and then calculate a "look-at" matrix from that point to eye center, that is in the middle of near plane in frustum... or something

  2. #12

    [OpenGL] Earth atmosphere effect

    Quote Originally Posted by User137
    What i was thinking to fix that is calculating the rotation matrix differently. Find out x,y,z for the center of planet as it is transformed with Modelview matrix and then calculate a "look-at" matrix from that point to eye center, that is in the middle of near plane in frustum... or something
    What do you think of this? Is this of any help maybe?

  3. #13

    [OpenGL] Earth atmosphere effect

    Yes, billboarding is exactly the technique used in the case. The glow is sort of sprite that you turn towards camera.

  4. #14

    [OpenGL] Earth atmosphere effect

    Yip, I agree, but isn't it the technique that is used in my case? Why doesn't it work?

  5. #15

    [OpenGL] Earth atmosphere effect

    Quote Originally Posted by Brainer
    Yip, I agree, but isn't it the technique that is used in my case? Why doesn't it work?
    Obviously, because 3D sphere and 2D billboard will be deformed differently by perspective. Try to flattern the sphere in vertex shader along view vector.

  6. #16

    [OpenGL] Earth atmosphere effect

    I don't know anything about vertex shaders, so that's all black magic to me. I found a little demo on Nehe's website, here's the conversion:
    [pascal]
    { .: GetCameraPosAndUp :. }
    procedure GetCameraPosAndUp(var camPos, camUp: TAffineVector);
    var
    ViewMatrix: array[0..15] of Single;
    M: TMatrix;
    begin
    glGetFloatv(GL_MODELVIEW_MATRIX, @ViewMatrix);

    camPos := AffineVectorMake(-ViewMatrix[12], -ViewMatrix[13], -ViewMatrix[14]);
    camUp := AffineVectorMake(ViewMatrix[1], ViewMatrix[5], ViewMatrix[9]);
    ViewMatrix[12] := 0.0;
    ViewMatrix[13] := 0.0;
    ViewMatrix[14] := 0.0;
    M := ConvertArrayToMatrix(ViewMatrix);
    TransposeMatrix(M);

    camPos := AffineVectorMake(VectorTransform(VectorMake(camPos ), M));
    end;

    { .: CreateBillboardMatrix :. }
    procedure CreateBillboardMatrix(var AMat: TMatrix; const ARight, AUp, ALook,
    APos: TAffineVector);
    begin
    AMat[0][0] := ARight[0];
    AMat[0][1] := ARight[1];
    AMat[0][2] := ARight[2];
    AMat[0][3] := 0.0;
    AMat[1][0] := AUp[0];
    AMat[1][1] := AUp[1];
    AMat[1][2] := AUp[2];
    AMat[1][3] := 0.0;
    AMat[2][0] := ALook[0];
    AMat[2][1] := ALook[1];
    AMat[2][2] := ALook[2];
    AMat[2][3] := 0.0;
    // Add the translation in as well.
    AMat[3][0] := APos[0];
    AMat[3][1] := APos[1];
    AMat[3][2] := APos[2];
    AMat[3][3] := 1.0;
    end;

    { .: BillboardAxis :. }
    procedure BillboardAxis(const Pos, Axis, camPos: TAffineVector);
    var
    Look, Up, Right: TAffineVector;
    begin
    Look := VectorSubtract(camPos, Pos);
    NormalizeVector(Look);

    Up := Axis;
    Right := VectorCrossProduct(Up, Look);
    NormalizeVector(Right);

    Look := VectorCrossProduct(Right, Up);

    CreateBillboardMatrix(M, Right, Up, Look, Pos);
    end;
    [/pascal]
    But this doesn't work either. Here are the screenshots - Screen #1, Screen #2.

    Any more ideas?

  7. #17

    [OpenGL] Earth atmosphere effect

    I did this once. Sphere (planet) is volumetric and due to perspective its projection to the screen is not always a circle. You need to make your planet flat too. This most easily can be done by a vertex shader. But you can flattern it while drawing since you are using glBegin/glEnd, not VBO.
    In other words, for each vertice of the planet you do the following:
    Code:
    DirP := DotProduct(Vertices[i], Direction);
    DrawVertices[i] := SubVector(Vertices[i], ScaleVector(Direction, DirP);
    Direction is normalised direction vector from camera to center of the planet.

  8. #18

    [OpenGL] Earth atmosphere effect

    Don't get me wrong, but what's the point in doing so? I think that the problem is with billboard matrix calculation, not the sphere itself.

  9. #19
    farcodev_
    Guest

    [OpenGL] Earth atmosphere effect

    just try to take a look, in the GLScene CVS branch, for GLAtmosphere, i use it in my game and work well.

  10. #20

    [OpenGL] Earth atmosphere effect

    Yip, I tried to do so, but no success. Besides, as you can read in the comments, it uses up a lot of processing resources, and for all I can see it's possible to achieve the same result in a more efficient way with that glow texture.

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •