Author Topic: BillBoard  (Read 10542 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
BillBoard
« on: January 21, 2018, 12:27:35 pm »
Mike--

This is a very basic 3D project for the purpose of checking with different billboarding technics.

Next, i shall create a C++ billboard project based on a simplified version of 3D chart, focusing only of the display of billboarded meshes.

...
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: BillBoard
« Reply #1 on: January 21, 2018, 01:36:52 pm »
Thank you, Patrice.

Historically, I have a zillion of very basic billboard projects from all over the world to consult with, starting from the very base basics of basic OpenGL basically called "Billboard Snowmen". :D

Every billboard repositioning algo is bound to the particular implementation of camera in the associated code project. The angles are different, coord systems are different, matrices are different, projections are different, orders of translations and rotations are different, direct3d and opengl are different, row-major and column-major arrays are different in different languages, and so on and so forth. :)

My interest in your 3D chart is also very basic. I simply don't believe that the two "ducks" (camera implementations) belonging to the same master (you) that are looking similar, walking similar, and quacking similar may all of a sudden start to behave differently regarding their food rations (billboards and flares). :)

Please do not over-simplify your 3D chart version. I am not going to steal your commercial secrets (I have already retired on pension and am quite happy with it). It must have the exact same render routine as your master 3D chart, exact same objects to handle and the exact same order of handling, and it should have the exact same camera implementation including possible model and other scene objects displacement and/or scaling routines.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
Re: BillBoard
« Reply #2 on: January 21, 2018, 05:13:51 pm »
Here is the VS2010 project that has been cleaned up to keep only the billboard objects.
Should work with your 2013 PRO.
I have moved most of the specific GDImage CHART code, into chart.h

Please, tell me if there is something i forget to past into this project.

Added
Here is a couple of missing functions to add into chart.h, to replace the call to the GDImage ZI_ResizeGLWindow
Code: [Select]
void setGLPerspective(IN float rFovy, IN float rAspect, IN float zNear, IN float zFar) {
    float rXmin, rXmax, rYmin, rYmax;
    const double mul = 0.00872664626;
    rYmax =  (float) (zNear * tan(rFovy * mul));
    rYmin = -rYmax;
    rXmin =  rYmin * rAspect;
    rXmax =  rYmax * rAspect;
    glFrustum(rXmin, rXmax, rYmin, rYmax, zNear, zFar);
}

long GLfovy(IN long nFovy, IN long RW) {
    static long WasnFovy;
    if (RW) {
        if (nFovy < 1) { nFovy = 45; }
        WasnFovy = min(nFovy, 180);
    }
    if (WasnFovy == 0) { WasnFovy = 45; }
    return WasnFovy;
}

//void ZI_ResizeGLWindow (IN HWND hWnd) {
void gl_ResizeGLWindow (IN HWND hWnd) {
    RECT rc; GetClientRect(hWnd, &rc);
    glViewport( 0, 0, rc.right, rc.bottom);
    float rAspect = (float) (rc.right / (float)rc.bottom);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    long nFovy = GLfovy(0,0); if (nFovy == 0) { nFovy = 45; }
    setGLPerspective((float) nFovy, rAspect, 2.0f, 100000.0f);
    glMatrixMode(GL_MODELVIEW);
}
« Last Edit: January 22, 2018, 01:55:35 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: BillBoard
« Reply #3 on: January 22, 2018, 08:34:28 pm »
Thank you very much for your confidence, Patrice!

Done as requested. I promise to have the sources erased from my PC the moment my analysis is over.

I think the problem lies in gluLookAt(). I will need some time to verify it though. But if my fears are confirmed, then my suggestion will be to have the camera code re-written so that it would fit in some known paradigm to make our life with billboards easier.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
Re: BillBoard
« Reply #4 on: January 22, 2018, 08:56:14 pm »
Mike

Between you and me, there is no problem for the source code, as long as we keep any GDImage code private.
« Last Edit: January 22, 2018, 09:28:04 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: BillBoard
« Reply #5 on: January 23, 2018, 06:31:44 am »
Patrice,

I succeeded in implementing smoothly rotating spherical and cylindrical billboards in one common function. The code exists only in Objector for now but it will work in both our renderers for all our cameras.

I will send you the mods later today after I'm through with sorting out my today's real life matters. I will also describe some rules of billboard sizing and placement to avoid unwanted parallax you're seeing in the Tron billboards. There's one thing however that I'd rather articulate right now for you to have some extra time to get accustomed to: billboards and flares must be equilateral foursquares and no argue about that. That's the easiest and least computationally intensive approach. Don't forget we're drawing multi-million poly models rather than a few simple quadrics on the 3D chart stage.

The chart_billboard.zip archive and its constituent files have been erased from my disks as promised. Thanks again for your invaluable assistance in getting the code to work properly. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
Re: BillBoard
« Reply #6 on: January 23, 2018, 07:12:58 am »
Thank you for the feedback, i am looking forward for the latest mods, i can live with equilateral quadrics as long as i am aware of it.

Just one more thing, do you think it will be possible to let them rotate on themselves for the purpose of cheap animation (around the center of the quad) while running in animate mod (like for a rotating knob) ?

I have sorted out, the smoothing of the tron cycle mesh, that means we are switching now slowly to high poly  :)
BTW, that was a very tedious work, because everything must be turned into quad before i could use subdivision to smooth the surface.

Added
One more thing about BillBoard, i think it would be nice to use the spherical mod (same as in 3d chart) as the default.
« Last Edit: January 23, 2018, 12:48:11 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: BillBoard
« Reply #7 on: January 23, 2018, 10:10:20 pm »
1. Use these example billboard materials with your billboarded Tron:

newmtl big_flare
#billboard nodepth
Ka 2 2.8 2.9
Kd 0 0.8 0.9
Ks 2 2.8 2.9
Ke 1 1 1
map_Kd big_flare.png
Ns 2
d 0.9
illum 2

newmtl logo
#billboard cylinder flip nodepth
Ka 2 2.8 2.9
Kd 0 0.8 0.9
Ks 2 2.8 2.9
Ke 1 1 1
map_Kd logo.png
Ns 2
d 0.999
illum 2


Arguments to the #billboard metastatement may come in any order. Meaning of each:
  • cylinder/sphere -- cylindrical or spherical billboard, respectively. sphere is the default and may be omitted.
  • nodepth -- billboard is drawn in glDisable(GL_DEPTH_TEST) mode so that it is seen through the model as it rotates at any angle.
  • flip -- pertains to cylinder billboard mode only; when specified, it forces an asymmetrical cylindrical billboard to keep its "head" "up" when flipped upside down by model rotation. sphere billboards are always "flippable" and ignore this parameter.
2. Rules to avoid unwanted parallax displacements:
  • Best way to avois parallax is to merge both billboard images together and put the flare image in its proper place and size relative to the logo image on the common image canvas.
  • If not, then if both billboards are sufficiently transparent so as to avoid visible z-buffer fighting, then make the flare image canvas as big as the logo canvas but move the flare particle to the right in its desired place respective to the logo. Then make the Y rotation axes of both billboards occupy the same XZ coords on the model ground plane.
  • If some z-buffer fighting is still seen, then displace the Y axes on the XZ plane just a little and make both billboard materials #alphatocoverage. It's difficult to notice in this mode which of the two billboards is in front of the other.

3. My mods are in the attached mobj.h file. I think you may release v2.0 now.

In the meantime, it seems like I have an idea of how we can have easy and simple GLSL post-processing in both our FFP and PPL setups. The post-processing routines may include vignetting, God rays, possibly bloom, and most importantly, FXAA similar to those I exemplified on this site a while ago.

This is what I am going to get preoccupied with in the nearest future. And after all, I need to merge all our mods with my Objector too, to keep up with its ObjReader brother. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
Re: BillBoard
« Reply #8 on: January 24, 2018, 08:37:18 am »
Mike--

In Mobj.h, at line 1115 you have SETCOLORDIF(1), shouldn't it be indeed SETCOLORDIF(2) ?

I checked the last changes with the billboard mesh project, and that looks exactly to what it should be, perfect!!!
except for the transparency of 3 over 2, when 3 gets in front of 2, or 2 gets in front of 1,
or when the sphere overlap rectangle.
As you wrote, Alphatocoverage seems to solve the problem, then perhaps when using billboard we should always turn it to ON ?
« Last Edit: January 24, 2018, 09:21:22 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: BillBoard
« Reply #9 on: January 24, 2018, 11:42:16 am »
In Mobj.h, at line 1115 you have SETCOLORDIF(1), shouldn't it be indeed SETCOLORDIF(2) ?

Oh yes, of course it should be SETCOLORDIF(2)! It is my copy-paste typo; I did the conversion from plain C to macros in the last minute before posting when I saw the file becoming really huge due to endless clones of similar code...  :-[ Thank you for spotting it!

Quote
As you wrote, Alphatocoverage seems to solve the problem, then perhaps when using billboard we should always turn it to ON ?

Hehe no, I don't think A2C should be hardcoded because i) ordinary alpha looks better (crisper) than A2C; ii) there may be just one billboard in the entire model so there won't be anything it can overlap with; and iii) sooner or later we are going to have real-time dynamic alpha sort working and A2C won't have any real advantage any more except when used for grass and foliage.

Still we can add an optional a2c shorthand parameter to the #billboard meta to avoid having to add an #alphatocoverage meta on a separate line.

I got my idea with render-to-texture working in Objector's FFP and PPL for the purposes of post-processing. But render quality is lower than expected and pixel transfer is harder for the CPU than I hoped. We will have to set up a real hardware FBO (a.k.a. frame buffer object) to get high quality results. Need more time to work on it and get it up and running. Texture animation will have to wait for a while.

Thanks for the giphy animation. It looks nice but as I said, you will have dynamic texture coord transforms soon (in the next version of ObjReader) and then you'll be able to animate your textures in a similar, or perhaps even better, fashion. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
Re: BillBoard
« Reply #10 on: January 24, 2018, 01:51:40 pm »
The new billboard seems to works also with circle mesh...
« Last Edit: January 24, 2018, 02:19:06 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: BillBoard
« Reply #11 on: January 24, 2018, 06:20:10 pm »
The new billboard seems to works also with circle mesh...


Um, exactly what do you mean?  ???
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
Re: BillBoard
« Reply #12 on: January 24, 2018, 06:36:31 pm »
This.. see the c4D attachment.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: BillBoard
« Reply #13 on: January 24, 2018, 06:55:59 pm »
Patrice, the billboard ignores entirely the geometry and texture coords the billboard mesh has hardcoded in the model. Instead, it uses only the geometrical center of the mesh in the world coordinate system to set up its own quad around it, and then draws the billboard texture mapped to the four corners of that quad.

As long as the original billboard mesh is symmetric in its width and height like the OR orb, the differences are not noticeable. But if the orb were elliptic or non-unilaterally quadratic, the image would've been distorted.

And now tell me please, what is the reason to hardcode a 32-segment disk as the orb mesh if the exact same effect may be achieved with a four-corner equilateral quad? ;)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1983
    • zapsolution
Re: BillBoard
« Reply #14 on: January 24, 2018, 07:10:54 pm »
Quote
And now tell me please, what is the reason to hardcode a 32-segment disk as the orb mesh if the exact same effect may be achieved with a four-corner equilateral quad? ;)

Nothing, i just checked with the existing model i had, because i was thinking first to use my 3D chart GLpoint for clipping purpose.
But that was before the new one ;)

BTW i posted the TRON release version, and ONYX...
« Last Edit: January 24, 2018, 07:12:37 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)