Author Topic: Per-Polygon Transparency  (Read 5077 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Per-Polygon Transparency
« on: February 06, 2014, 07:21:37 pm »
I'm exporting a little particle waterfall splash from 3ds max as a sequence of OBJs. Each OBJ has several triangles with different values for visibility. I have two problems: the first, naturally, is to export these values per-polygon (a simple MaxScript should produce a companion text file describing their visibilty), and the second, of course, is to apply these visibilities per-polygon in jpct (lest I have to have an Object3D per polygon, which seems bizarre memory-wasteful). Is this possible?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per-Polygon Transparency
« Reply #1 on: February 06, 2014, 07:31:49 pm »
I would expect the exporter to export polygons with different transparency as individual objects. They have to be separate objects to be rendered, because transparency and blending modes are render states just like a shader assignment. You can't render polygons with individual transparency in one batch (at least not unless you write a special shader and assign additional vertex attributes).

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Per-Polygon Transparency
« Reply #2 on: February 06, 2014, 07:33:47 pm »
So if the splash consists of 200 triangles I have to have 200 Object3Ds per frame?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per-Polygon Transparency
« Reply #3 on: February 06, 2014, 07:39:30 pm »
Yes. You might be able to group/merge them by transparency, but that's basically how it works. As mentioned, you could create a shader driven particle system that does everything in the vertex shader, but i don't think that this is needed. Personally, i never did that. I always used separate objects for the sake of simplicity.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Per-Polygon Transparency
« Reply #4 on: February 06, 2014, 07:44:54 pm »
OK, thanks. I don't suppose you have any experience with MaxScript, do you?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per-Polygon Transparency
« Reply #5 on: February 06, 2014, 07:55:41 pm »
No, not even a tiny little bit.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Per-Polygon Transparency
« Reply #6 on: February 06, 2014, 08:03:34 pm »
OK, thanks. But a follow-up: how do I even set opacity of these particles? How do I make an Object3D 30% opaque?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per-Polygon Transparency
« Reply #7 on: February 06, 2014, 08:51:36 pm »
The values that you set in Object3D.setTransparency(<int>) will be mapped to 0..1. 0 is fully transparent, 1 is opaque. How this mapping happens this based on a formular described here: http://www.jpct.net/doc/com/threed/jpct/Config.html#glTransparencyMul and here: http://www.jpct.net/doc/com/threed/jpct/Config.html#glTransparencyOffset. The default setting tries to mimic the software renderer. If you are on hardware only, i suggest to adjust the values so that the actual formular gives you finer graduated values.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Per-Polygon Transparency
« Reply #8 on: February 07, 2014, 09:53:06 pm »
I don't even sort of understand that answer. In code, how would you make an Object3D 30% opaque using the OpenGL renderer?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per-Polygon Transparency
« Reply #9 on: February 08, 2014, 04:47:08 pm »
You use setTransparency on that object. If it really has to be exactly 30%, you have to make sure that the mentioned formular gives you 0.3. To dont this, you might have to tweak the config settings that i mentioned. Like setting the offset to 0, the mul to 0.01 and setTransparency to 30.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Per-Polygon Transparency
« Reply #10 on: February 09, 2014, 07:16:50 am »
OK, thanks. I got it now, but does that not sound bizarrely intricate to you for something so relevant? Do you not feel the need for a setAbsoluteTransparency(float between 0f and 1f) or so?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per-Polygon Transparency
« Reply #11 on: February 09, 2014, 12:26:09 pm »
Do you not feel the need for a setAbsoluteTransparency(float between 0f and 1f) or so?
Actually no. I see your point and if i would do it again, i would most likely do it that way...if there weren't the software renderer. The current solution is the way it is because of the software renderer. I agree that it's harder to grasp than [0..1], but on the other hand nobody ever complained about it until now... ;)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Per-Polygon Transparency
« Reply #12 on: February 09, 2014, 09:12:31 pm »
Nobody ever complained to you, anyway. :- )

Why would you do it the same way if there were no software renderer?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Per-Polygon Transparency
« Reply #13 on: February 09, 2014, 09:56:27 pm »
Why would you do it the same way if there were no software renderer?
I wouldn't. That's what i was trying to say... ;)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Per-Polygon Transparency
« Reply #14 on: February 09, 2014, 10:07:34 pm »
Oh, I see. I think I'd rather have the software renderer, though. :- )