Author Topic: Applying multitexture to single poly in object  (Read 9886 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Applying multitexture to single poly in object
« Reply #15 on: January 10, 2006, 01:01:43 am »
Just wanted to let you know that your problem is not forgotten. I'm working on it and i have an alpha version of it running for the "normal" OpenGL renderer. I'll start working on the AWTGLRenderer on wednesday (at least i hope so).

Offline rolz

  • float
  • ****
  • Posts: 280
  • Technocrat
    • View Profile
Applying multitexture to single poly in object
« Reply #16 on: January 10, 2006, 09:14:38 am »
Thanks for the support, hope to see this feature working soon.

 Regarding fullscreen opengl renderer - I would like to ask for your guidance.
 The problem is that i am still getting reports of compatibility issues with AWT+opengl on some gf2mx cards. The user either gets the blank screen (with only 2D interface) or the performance is about 10 fps on pretty good hardware, which makes me thing something is wrong.

  I am concerned this is some weird bug with lwjgl/AWT/drivers combination, and chances are i just won't be able to solve it.  I am not sure what is the best solution for this cause, actually i had 2 things in mind:

 - stick with AWT/GL combination, with no guarrantee that problems will be solved
 - switch to regular LWJGL renderer which works, but then i would have to redo all 2d, and probably lose so much desired AWT flexibility.

What would you recommend ?
Regards,
Andrei

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Applying multitexture to single poly in object
« Reply #17 on: January 11, 2006, 12:03:30 am »
I would stick with AWT and concentrate on the game play itself. I'm not sure what causes the problem with the MX, but it could be anything. Java in all its flavours is still having problem with AA enabled in the drivers for example. I've tested Techno on a GF2MX under Linux and it was quite slow due to the CPU (PII-450), but it was playable. With current drivers, the MX should behave like any other outdated GeForce card (in theory...). If it's better in windowed mode, i think that this is a good solution for a game like Techno.
Switching to native LWJGL will cause you a lot of work but with an uncertain success. Maybe it will run better on some of these systems but fail on others. Too bad that i can't contribute with experiences from Paradroidz, which does native LWJGL fullscreen...i assume that i'm just getting no feedback from people where it doesn't work.
The other pro of the AWTGL-stuff is, that you'll largely benefit from dual cpu/core setups. I haven't tested this myself, but i once published a benchmark and the fps increased up to 80% on dual cpu machines with the  AWTGLRenderer.

P.S.: Adding multi pass texturing is a pain... :wink:

Offline rolz

  • float
  • ****
  • Posts: 280
  • Technocrat
    • View Profile
Applying multitexture to single poly in object
« Reply #18 on: January 11, 2006, 09:27:46 am »
Helge,

Thanks for the reply, I wouldnt consider switching from AWT GL to native lwjgl without good reasons. ;)


Regarding multitexturing - Terrain decorations and shadows were redesigned to use multitexturing - and they really look awesome now:  
*Removed*
« Last Edit: November 07, 2010, 10:58:56 pm by EgonOlsen »
Regards,
Andrei

Offline rolz

  • float
  • ****
  • Posts: 280
  • Technocrat
    • View Profile
Applying multitexture to single poly in object
« Reply #19 on: January 11, 2006, 08:16:30 pm »
more teasers

*Removed*
« Last Edit: November 07, 2010, 10:59:23 pm by EgonOlsen »
Regards,
Andrei

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Applying multitexture to single poly in object
« Reply #20 on: January 11, 2006, 08:20:41 pm »
After adding more new bugs than features, here's a version that will hopefully  work well enough to test multi pass rendering: http://www.jpct.net/download/beta/jpctapi110_pre2.zip

There are some drawbacks/problems with multi pass compared to one pass multi texturing. This affects the areas of transparency, fogging and accuracy.
I'm not sure if this approach is suitable for what you have in mind...well, we'll see...here's how the OpenGL pipeline handles one pass multi texturing:



As you can see, it's pretty straight forward. The texture in stage 1 is modulated with the vertex colors, then blended together with the one in stage 2...n. Then, the blending with the screen is done (which means applying transparency in this case) and the results are fogged.

Here's how the multi pass approach works:



The textures are applied in multiple passes now, which means that they are blended with the screens content one after the other. This has some problems.

Transparency: Can only be applied to the first texture, because it's the only one that won't be blended with the screen anyway because of the texture blending that's needed. But you can only do one blending, either the alpha blending for transparency or the color blending for the textures. Result: Transparency on multi pass polygons is there but much less than on single pass ones. And writing to the depth buffer has to be turned on for transparent multi pass polygons. For single pass, it's turned of by jPCT.

Fogging: You can either apply fog after each texturing pass (which is what i did) or just after the first or just after the last. In each case, you'll never get the same results as you would get with a single pass. Either the fogging will be too intense (my choice for the moment) or not intense enough (with both other options). So fogging multi pass textured polygons is a problem...maybe shifting the fog's starting position away in combination with no additional shadows (from characters or whatever) but the environment ones from that position on is an option?

Accuracy: That isn't much of a problem, but current hardware does the blending with a higher internal accuracy than the framebuffer provides. That means that you'll lose some color information by writing into the framebuffer for each pass. That's most noticable when using MODE_ADD. BLEND and MODULATE shouldn't be affected that much (if even).

How to enable multi pass: You don't have to. jPCT will use it on polygons that need it (i.e. that have a higher texture layer count than the hardware can render in one pass) automatically. There are some new settings in Config: maxTextureLayers, glMultiPassSorting and glOverrideStageCount.

Offline rolz

  • float
  • ****
  • Posts: 280
  • Technocrat
    • View Profile
Applying multitexture to single poly in object
« Reply #21 on: January 12, 2006, 10:11:51 am »
Just downloaded the patch - works great, except the fogging problem.
I have a couple ideas how to overcome it:

- switch to vertex fogging (looks less realistic than pixel but it works)
- restrict camera to z rotations only - this will prevent player from seeing borders of visibility area (which are not completelly hidden with vertex fog) and stick to classic RPG izometriс view (as in Diablo, BG, NWN)

so far, it looks like this:
*Removed*

And, thanks again for prompt responce !  Great job, btw. Exactly same thing as i had in mind.
« Last Edit: November 07, 2010, 10:59:37 pm by EgonOlsen »
Regards,
Andrei

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Applying multitexture to single poly in object
« Reply #22 on: January 12, 2006, 07:34:24 pm »
Quote from: "rolz"

- switch to vertex fogging (looks less realistic than pixel but it works)
- restrict camera to z rotations only - this will prevent player from seeing borders of visibility area (which are not completelly hidden with vertex fog) and stick to classic RPG izometriс view (as in Diablo, BG, NWN)
Vertex fog works fine for exactly one fog color: black! I'm not sure if it's really a good looking option. Maybe limiting the visible area is the best solution....:?:
The screen shot looks cool. Great that the extension seems to work that well.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Applying multitexture to single poly in object
« Reply #23 on: January 16, 2006, 08:25:12 pm »
A new version that fixes a bug in 2D blitting (the AWTGLRenderer doesn't seem to be affected by this, but it was wrong anyway) and adds support for the alpha channel of transparent objects:
http://www.jpct.net/download/beta/jpctapi110_pre3.zip