Per-Polygon Transparency

Started by AGP, February 06, 2014, 07:21:37 PM

Previous topic - Next topic

AGP

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?

EgonOlsen

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).

AGP

So if the splash consists of 200 triangles I have to have 200 Object3Ds per frame?

EgonOlsen

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.

AGP

OK, thanks. I don't suppose you have any experience with MaxScript, do you?

EgonOlsen


AGP

OK, thanks. But a follow-up: how do I even set opacity of these particles? How do I make an Object3D 30% opaque?

EgonOlsen

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.

AGP

I don't even sort of understand that answer. In code, how would you make an Object3D 30% opaque using the OpenGL renderer?

EgonOlsen

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.

AGP

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?

EgonOlsen

Quote from: AGP on February 09, 2014, 07:16:50 AM
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... ;)

AGP

Nobody ever complained to you, anyway. :- )

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

EgonOlsen

Quote from: AGP on February 09, 2014, 09:12:31 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... ;)

AGP

Oh, I see. I think I'd rather have the software renderer, though. :- )