jPCT - a 3d engine for Java => Support => Topic started by: 3d-er on January 24, 2006, 10:01:42 am

Title: Texture plus env map
Post by: 3d-er on January 24, 2006, 10:01:42 am
Fantastic work on the engine!!!  I could not determine from the API if mapping a texture and env map to the same object is possible.  From my trials, it is not.  If it is not possible, would adding that feature be possible?  

Would a monetary donation incent getting it done sooner that later?
If speed is a concern, could a different mode be added to allow it?  The idx3d engine and Jazz3d are good examples.

Thank you in advance.
Title: Texture plus env map
Post by: EgonOlsen on January 24, 2006, 05:54:22 pm
By looking at the examples you've given, i guess you are talking about software rendering here, don't you? If so, it is possible to a degree...
You can "abuse" bump mapping for it like so:

Code: [Select]

      TextureManager texMan=TextureManager.getInstance();
      Texture grey=new Texture("grey.jpg");
      Texture brick=new Texture("brick.jpg");
      Texture env=new Texture("envmap.jpg");
      texMan.addTexture("grey", grey);
      texMan.addTexture("brick", brick);
      texMan.addTexture("env", env);

This blends the bump mapped environment map with the base map. If the bump map is a unicolored texture of RGB 127/127/127, you should get a plain blending without any bumps. Of course, you can add bumps in addition if you want to. The blending is additive. If you were talking about OpenGL accelerated rendering, this option doesn't exist ATM.
Title: Example not working
Post by: 3d-er on January 25, 2006, 07:18:45 am
Correct, I was talking software rendering.  The example provided only shows 100% env map reflection not additive when run.  The brick surface does not show at all and I have used your code exactly with a 127,127,127 gray bump map.  Would it be possible to add the two textures mapping into the rendering pipeline?  I am willing to pay for this feature.
Title: Texture plus env map
Post by: EgonOlsen on January 25, 2006, 08:11:11 am
But i've tried it..it works...example (with a badly placed brick texture, but anyway):


Must be something else... :?:
Title: It works!
Post by: 3d-er on January 25, 2006, 08:29:36 am
After I set blending to true and made my maps the same size it worked, but is extremely slow compared to idx3d.  I'm only getting about 4 fps for 4,000 triangles compared with idx3d doing 18,490 triangles.  I use SAMPLINGMODE_OGSS_FAST because SAMPLINGMODE_NORMAL's quality is too low for my application.

Any ideas if the speed could be improved by eliminating the bump map requirement so only envp map plus texture could render?

Title: Re: It works!
Post by: EgonOlsen on January 25, 2006, 04:50:47 pm
Quote from: "3d-er"
Any ideas if the speed could be improved by eliminating the bump map requirement so only envp map plus texture could render?
Maybe, but i wouldn't expect too much from it. How fast is the rendering without the blending enabled, i.e. with env mapping only? Comparing the performance of IDX3D and jPCT is difficult as jPCT does a lot more and is more accurate in what it's doing. For example, IDX3D has no perspective correction for example and produces lots of gaps between polygons. What exactly is your application? An object viewer? There are some settings tailored for more complex scenes that you may try to adjust and see if that helps.
Title: rendering quality/speed
Post by: 3d-er on January 25, 2006, 11:20:43 pm
Yes, we need texture w/env map w/o bump map that is relatively quick.  The current jPCT rocks for what it does, but I hope to get slightly better image quality that is still useable (anywhere close to idx3d speed would be awesome).  It is an object viewer.

Would making a new method w/o bump mapping speed up the processing?  I am willing to pay for any customizations necessary.

Title: Texture plus env map
Post by: EgonOlsen on January 25, 2006, 11:31:14 pm
I can write you a hacked renderer that does the job. That's not the problem (maybe next monday). But i'm not sure if it's really that much faster. That's why i asked about the performance without the blending (just env mapped).
If it's an object viewer only, you can disable some stuff like:


and maybe (if the object is completely visible anyway)


Are you using dynamic lighting? If not, Config.gouraud=false may also help.

Not sure how much you can gain from these settings, but it's worth a try.
Title: Thank you
Post by: 3d-er on January 26, 2006, 06:03:39 am
Thank you, I will try your suggestions.
I would be very interested in a hacked renderer!  All it should do is combine transparency, texture and env maps with gouraud shading.  No bump mapping needed.  

Specifically if there are some speed optimizations that can be made, such as bit shifting where possible, avoiding if/then statements in the pipeline and avoiding new object creation at any cost (member vars for all objects rather than creating new int[], etc. in loops) and also avoiding any up or down casting such as collections work.  Is there a way to render in 32 bits?  That way any transparency ops will be handled by hardware using argb.  I believe that is one of the secrets of idx3d.

Obviously there are places where this is necessary.  Any collections work in any loop could be replaced with arrays or a hand-made collection (I can provide this to you) that returns the proper type of object w/o casting such as 3d_vector or poly (I'm sure you know arrays approach c++ speed  especially when pre-allocated).
The application I hope to create will help many people.
Title: Texture plus env map
Post by: EgonOlsen on January 26, 2006, 09:06:09 am
The secret of IDX3D is not hardware acceleration of alpha, because a 1.1VM doesn't support it and there is no hardware support even in 1.4+ for images where you are explicitly setting single pixels in their int[]-array of pixels. The "secret" is, that it's doing the rendering much simpler. It's not doing the texel filtering, it's not subpixel/subtexel/subcolor correct. It has no perspective correction for neither textures, colors or zbuffer (requires 3 muls every 16 pixels). Your hints about performance are all true, but are  all in jPCT. There is not a single generic Collection used in the engine, it's full of bit shifting, no object creation in loops, reuse of objects etc.
To make you believe, here's an inner loop of the renderer. If you can suggest something that'll make it faster, i would appreciate it:

Edit: Opps, i had accidently posted the no-z-buffer version. Here's the correct one:

Code: [Select]

 for (int tx=x+yPos; tx<=end; tx++) {

  if (zbuffer[tx]>iz) {





Title: speed up
Post by: 3d-er on January 27, 2006, 07:57:16 am
Hm... remove perspective correction and there is no need for texeling and the maps look distorted especially close to camera such as seen with idx3d.

So with your tight code and the dependency of persp. correction on texeling, per your previous suggestions, it doesn't appear there is a way to speed it up.  

SAMPLINGMODE_OGSS_FAST seems to be a tradeoff of speed/quality that I may be able to make work.  Thank you so much for your timely and well thought through responses, your time for looking into it and most of all, the great engine.

Best regards,
Title: Texture plus env map
Post by: EgonOlsen on January 30, 2006, 06:38:40 pm
Here's the hacked file: http://www.jpct.net/download/hacks
To use it, you have to use the SoftGLRenderer in exactly the same way as you would with "normal" blending enabled, i.e. you also have to assign the bump map in the proper format, but with a don't-care-content (use a dummy texture of any kind for this, not one of the actual textures because bump maps will be pre-processed). The difference to the normal renderer is, that the bump map isn't used anymore for blending and that transparency works in combination with blending.
Hope this helps.