www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on February 06, 2014, 07:21:37 pm

Title: Per-Polygon Transparency
Post by: AGP 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?
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen 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).
Title: Re: Per-Polygon Transparency
Post by: AGP on February 06, 2014, 07:33:47 pm
So if the splash consists of 200 triangles I have to have 200 Object3Ds per frame?
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen 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.
Title: Re: Per-Polygon Transparency
Post by: AGP on February 06, 2014, 07:44:54 pm
OK, thanks. I don't suppose you have any experience with MaxScript, do you?
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen on February 06, 2014, 07:55:41 pm
No, not even a tiny little bit.
Title: Re: Per-Polygon Transparency
Post by: AGP 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?
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen 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 (http://www.jpct.net/doc/com/threed/jpct/Config.html#glTransparencyMul) and here: http://www.jpct.net/doc/com/threed/jpct/Config.html#glTransparencyOffset (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.
Title: Re: Per-Polygon Transparency
Post by: AGP 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?
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen 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.
Title: Re: Per-Polygon Transparency
Post by: AGP 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?
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen 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... ;)
Title: Re: Per-Polygon Transparency
Post by: AGP 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?
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen 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... ;)
Title: Re: Per-Polygon Transparency
Post by: AGP on February 09, 2014, 10:07:34 pm
Oh, I see. I think I'd rather have the software renderer, though. :- )
Title: Re: Per-Polygon Transparency
Post by: AGP on February 10, 2014, 09:16:45 pm
The texture for these planes are PNGs with an alpha channel (see below). Why, then, are the planes appearing rectangular?

https://dl.dropboxusercontent.com/u/93826015/splash.png
(https://dl.dropboxusercontent.com/u/93826015/TextureAlpha.jpg)
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen on February 10, 2014, 09:19:15 pm
Most likely because you are loading them wrong. You have to use the one of the constructors in Texture that take a boolean for useAlpha and set it to true.
Title: Re: Per-Polygon Transparency
Post by: AGP on February 10, 2014, 09:22:49 pm
Thanks very much, you were right.

Did you see the other guy (in so many days) "complain" about the same thing I did? : -)
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen on February 10, 2014, 09:32:58 pm
Did you see the other guy (in so many days) "complain" about the same thing I did? : -)
Which is... ???
Title: Re: Per-Polygon Transparency
Post by: AGP on February 10, 2014, 09:41:55 pm
That setTransparency(int) is counter-intuitive. We just covered the subject.
Title: Re: Per-Polygon Transparency
Post by: EgonOlsen on February 10, 2014, 09:43:02 pm
That setTransparency(int) is counter-intuitive. We just covered the subject.
No, that's not the point of the other thread. He wants to create some stencil effect by using blending. That's something different.