Author Topic: ObjReader FBO & PP  (Read 28814 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #45 on: May 07, 2019, 09:08:45 pm »
:o

!!! WATCH THE FLOOR SEAMS AS THEY GO HEAVILY BLURRED IN THE DISTANCE IF THE FLOOR TEXTURE ANISOTROPY IS NOT CORRECTED !!!

(Please also answer my other suggestions in earlier messages. Hopefully you haven't yet lost interest in ObjReader. ;))
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: ObjReader FBO & PP
« Reply #46 on: May 07, 2019, 09:11:40 pm »
Quote
1. GDImage.cpp, ZI_MakeMultipleTexture(...), line 8842:

// MLL: _MIPMAP_LINEAR cannot be used for _MAG_FILTER as per OpenGL Specs !!!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR GL_LINEAR);
Obviously we do not have the same source  :o

ZI_MakeMultipleTexture is at line 9467 by me, and the code is rather different than the one used in Mobj_makeMultipleTextures  :o

Here is the code i have:
Code: [Select]
void ZI_MakeMultipleTexture (IN ZGLTEXTUREX* mt, IN long mtCount) { // dllexport
    if (mtCount> 0) {
       long K, OkDelete = 0;
       long* Texture = new long[mtCount];
       memset(Texture, 0, sizeof(long) * mtCount);
       for (K = 0; K < mtCount; K++) {
           Texture[K] = mt[K].Texture; if (Texture[K]) { OkDelete = -1; }
       }
       if (OkDelete) { glDeleteTextures(mtCount, (GLuint*) Texture[0]); }
       glGenTextures(mtCount, (GLuint*) &Texture[0]);
       long nRet = glGetError();
       if (nRet == 0) {
          for (K = 0; K < mtCount; K++) {
              BYTE* lpArray = NULL;
              long xSize = 0, ySize = 0;
              gl_TexAlpha(0, 1); // 05-10-2015 to detect if we are using an alpha channel
              if (ZI_CreateGLTextureFromFileEX(mt[K].FullName, xSize, ySize, lpArray, mt[K].Square)) {
                 mt[K].Texture = Texture[K];
                 mt[K].alpha = gl_TexAlpha(0, 0); // 05-10-2015 to detect if we are using an alpha channel
                 GL_BindTexture(GL_TEXTURE_2D, Texture[K]); nRet = glGetError();
                 if (nRet == 0) {
                    if (mt[K].Square == 4) { // MipMapping in ZI_CreateGLTextureFromFileEX
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
                        gluBuild2DMipmaps(GL_TEXTURE_2D, 4, xSize, ySize, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
                    } else {
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                        glTexImage2D(GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
                    }
                    nRet = glGetError();
                 }
                 free (lpArray); //zizi
              }
          }
       }
       delete [] Texture;
    }
}
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #47 on: May 07, 2019, 09:18:42 pm »
This is because I have very old pandora as far as GDImage is concerned. ;D

See below:

void ZI_MakeMultipleTexture (IN ZGLTEXTUREX* mt, IN long mtCount) { // dllexport
    if (mtCount> 0) {
       long K, OkDelete = 0;
       long* Texture = new long[mtCount];
       memset(Texture, 0, sizeof(long) * mtCount);
       for (K = 0; K < mtCount; K++) {
           Texture[K] = mt[K].Texture; if (Texture[K]) { OkDelete = -1; }
       }
       if (OkDelete) { glDeleteTextures(mtCount, (GLuint*) Texture[0]); }
       glGenTextures(mtCount, (GLuint*) &Texture[0]);
       long nRet = glGetError();
       if (nRet == 0) {
          for (K = 0; K < mtCount; K++) {
              BYTE* lpArray = NULL;
              long xSize = 0, ySize = 0;
              gl_TexAlpha(0, 1); // 05-10-2015 to detect if we are using an alpha channel
              if (ZI_CreateGLTextureFromFileEX(mt[K].FullName, xSize, ySize, lpArray, mt[K].Square)) {
                 mt[K].Texture = Texture[K];
                 mt[K].alpha = gl_TexAlpha(0, 0); // 05-10-2015 to detect if we are using an alpha channel
                 GL_BindTexture(GL_TEXTURE_2D, Texture[K]); nRet = glGetError();
                 if (nRet == 0) {
                    if (mt[K].Square == 4) { // MipMapping in ZI_CreateGLTextureFromFileEX
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR GL_LINEAR); // MLL: ZUZU :D
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
                        gluBuild2DMipmaps(GL_TEXTURE_2D, 4, xSize, ySize, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
                    } else {
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                        glTexImage2D(GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
                    }
                    nRet = glGetError();
                 }
                 free (lpArray); //zizi
              }
          }
       }
       delete [] Texture;
    }
}
« Last Edit: May 07, 2019, 09:23:26 pm by Michael Lobko-Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: ObjReader FBO & PP
« Reply #48 on: May 07, 2019, 09:19:22 pm »
Quote
!!! WATCH THE FLOOR SEAMS AS THEY GO HEAVILY BLURRED IN THE DISTANCE IF THE FLOOR TEXTURE ANISOTROPY IS NOT CORRECTED !!!
YES, using my computer glasses i see it now  (i was wearing my distant glasses)
And 16 looks the better to me, but i can live with 8 ;)
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: ObjReader FBO & PP
« Reply #49 on: May 07, 2019, 09:20:52 pm »
Quote
This is because I have very old pandora as far as GDImage is concerned.
No, i sent you the latest version two weeks ago  :-\
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #50 on: May 07, 2019, 09:36:31 pm »
No, i sent you the latest version two weeks ago  :-\

That's correct; my bad.

I opened up an old CPP dated  12/14/2018...

It's line 9489 in CPP dated 4/19/2019 with TGA and DDS code.

(I'm keeping a history of pandoras but opened the oldest copy for no apparent reason... :-[)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #51 on: May 07, 2019, 09:39:04 pm »
... i can live with 8 ;)

So be it! :D

(Still, what about moving Wireframe and Point cloud menu elements over to the Renderer menu?)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: ObjReader FBO & PP
« Reply #52 on: May 07, 2019, 09:56:36 pm »
Yes, that would be easier to move them into the "Render" menu, rather than having first to select "View" then "Render mode control"
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #53 on: May 08, 2019, 11:44:38 am »
Thanks for responding! I'll include the new layout in the nearest coming test build for you to evaluate.

Quote
... the code is rather different than the one used in Mobj_makeMultipleTextures  :o

The GDImage original code was too basic and simple to be used in OR as-is. We had to follow a much more elaborate scheme to decide on the fly if the current texture needed and/or allowed clamping and/or mipmapping at load time. So we extended the ZI_MakeMultipleTexture code into a dedicated Mobj_makeMultipleTextures function leaving out the GDImage original altogether.

That also enabled me to maintain the code of this very sensitive stage in OR's model loading process independently, without having to ask you to reveal much of GDImage internals every time we had an issue to resolve.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #54 on: May 16, 2019, 04:10:49 am »
OK, I just want you to see what I'm working on.

These are 5 fully debugged 1-pass production quality 2D PP shaders:
  • hue/saturation (in one shader)
  • brightness/contrast (ditto)
  • sepia
  • vibrance (that's sort of selective saturation that affects only insufficiently saturated colors)
  • vignette.
All are fully and smoothly controllable. They are also very lightweight; the heaviest one, vignette, incurs blur but still costs not more than about 2% FPS on a 32x MSAA/8x aniso canvas.

There are more to come. But those 5 are already sufficient to start merging them into a conditionally compilable composite  PP shader that will allow us to use any number of such PP effects in any combination with only a minimum loss in the FPS rate.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: ObjReader FBO & PP
« Reply #55 on: May 16, 2019, 10:31:33 am »
Quote
OK, I just want you to see what I'm working on.

Thanks!

I shall have to see them in context, to see how they can permanently enhance the rendering of the existing models.

On my side, i shall try to work back on the UV's undo/redo problem.  ::)
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #56 on: May 16, 2019, 10:42:32 am »
...i shall try to work back on the UV's undo/redo problem.  ::)

What about developing a WYSIWYG material editor for a change? :) You know, all those material balls, matcolor and opacity sliders and stuff, rather than a primitive text editor for .MAT contents... 8)

Though even the text editor with MAT syntax highlighting and real time update of the already loaded model (only the MAT file reloadable to actualize the mods) would be a great plus...

Re. PP, I'll send you a working build with separate shaders later today. I have urgent real life matters to attend to first. :)
« Last Edit: May 16, 2019, 10:45:28 am by Michael Lobko-Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: ObjReader FBO & PP
« Reply #57 on: May 16, 2019, 02:09:30 pm »
Quote
What about developing a WYSIWYG material editor for a change? :) You know, all those material balls, matcolor and opacity sliders and stuff, rather than a primitive text editor for .MAT contents... 8)

Though even the text editor with MAT syntax highlighting and real time update of the already loaded model (only the MAT file reloadable to actualize the mods) would be a great plus...

To say the truth, about the text editor, the only thing really useful to me, is the hability to create a transparent UV's map, that i could use as a guidance for my PSD texture work.
The main problem with Tor, is not the undo/redo, but saving the changes to the obj file  :-\

Something else …
I would like to see in OR the use of animated "shadertoy" backgrounds, to bring the models to life.
« Last Edit: May 16, 2019, 02:21:28 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: ObjReader FBO & PP
« Reply #58 on: May 16, 2019, 08:34:06 pm »
To say the truth, about the text editor, the only thing really useful to me, is the hability to create a transparent UV's map, that i could use as a guidance for my PSD texture work.
I knew you'd be clutching to your existing and familiar toolchain as tight as you only could. But do you realize how much of your precious lifetime you spent waiting for the model to reload when working with e.g. Blenderman's materials? Why you wouldn't want to have all the material editing facilities directly in OR is a mystery to me... ::)

Quote
The main problem with Tor, is not the undo/redo, but saving the changes to the obj file  :-\
The main problems with Tor are, alas, its low resolution, general blurriness, and shallow zoom. :-\

Quote
I would like to see in OR the use of animated "shadertoy" backgrounds, to bring the models to life.
That's on my to-do list.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: ObjReader FBO & PP
« Reply #59 on: May 16, 2019, 09:06:33 pm »
Quote
The main problems with Tor are, alas, its low resolution, general blurriness, and shallow zoom.

How would remove bluriness when zooming the existing texture background, this is a mistery to me, because you have either to remove or add extra pixels, and the only way to get a better quality is to use bicubic interpolation but this algo is too slow to edit things in real time.

Also remember that we are working in 32-bit composited mode and conventional memory.

The only solution would be to work with a back buffer, and bypass the GDImage zoom control, to manipulate just the part matching the view port.

The current bluriness is the exact same thing you got in Photoshop when working with the transparent UVmap and multiple layers.

For me, i keep saying that the main issue is to save the changes into the OBJ file.
Patrice
(Always working with the latest Windows version available...)