Problem with transparency


(Bastakompisar) #1

I have used two separate materials for logo and model. Though the jug looks quite ugly with all drawing-errors.
What have I done wrong?

See the attached file.


(Nukearts) #2

Hi @bastakompisar!

Did you try to change the option below "Face Rendering" from "Double Sided" to "Single Sided"?
Sometimes help.


#3

@Nukearts - that's the first thing I tried too, not quite good enough frowning

@bastakompisar - could you try separating the inner and outer pieces of glass into different meshes/materials? I think it might be a transparency draw-order problem. Maybe you could split it around the top edge?


(Bastakompisar) #4

@Nukearts Yes I tried that, thought it would help but it didn't.

@james I will try it and update how successful it was!


(Bastakompisar) #5

@james Tried to separate the mesh as you suggested. Got this now, I didn't bother masking for logo at this point.


(Bastakompisar) #6

@james I uploaded a standard sphere to see if there was something wrong with my mesh. But got these slices in the sphere. I am using the uploader script for 3ds max.


#7

@bastakompisar - does the sphere have two surfaces / submeshes? (i.e. an inner and outer layer) I can't quite tell from that screenshot.

I think it's being caused by draw-order problems between those submeshes.


#8

@paul_sketch @stephomi any suggestions?


(Bastakompisar) #9

@james No this is just a standard sphere with default subdiv from 3ds max. If I checked single side it does "solve" the problem, though by the cost of realism in my opinion.

I uploaded another mesh with different setup and the results were promising to say the least. I can live with a little draw problem, one can't really expect more from a real time web renderer, but the other example was really making me question the application value for us.

Here is the other mesh and it looks alot better. No idea why, perhaps because it has less curved surfaces?


#10

@bastakompisar - Yes, that one look much better. I'm not sure either, it could be thanks to the flatter surface, hmm.


(Bastakompisar) #11

@james What I have been able to find out it seems that way. In this particular case the re-upload with more meshes than just the jug helped somehow. Maybe I'll investigate further, if so I'll update you of my results. For now I'm satisfied with the model as is. Many thanks for responding and helping me out.


(Shaderbytes) #12

I did some tests again yesterday , On the mesh I was getting the cube artifacts like in the first image in this thread, I triangulated manually before using the exporter. This removes the ugly cube artifacts and then rather gave me the "disk" thing happening in the sphere example on this thread. Which is much more acceptable.

I also built several test models with varying curves , varying gaps etc.. what I found was that I could not consistently reproduce the bug which was actually very annoying to the "developer" side of my mind haha


(Bastakompisar) #13

@shaderbytes Yeah I guess the disk artifacts are the lesser of two evils. My qualified guess is that this resides in the way the engine draw surfaces.


(Shaderbytes) #14

After my tests yesterday I can confirm the artifacts are from a single mesh using double sided. As mentioned in my previous post at least manually triangulating the mesh before export ( from blender at least ) it gets rid of the horrible cube artifacts and then has the disc artifacts.


(Shaderbytes) #15

@james but also could not reproduce it everytime .. here is a sample mesh I built to try test with. I diid not triangulate anything , used a single material and yet got no errors .. this mesh is very dense though so maybe my next tests will try look at less dense geometry being the cause..

Alpha test 2 by shaderbytes on Sketchfab


(Shaderbytes) #16

some more observations :

This is a single mesh and the geometry is mirrored, mostly quads ( with some triangles on the edges etc )

  1. It only has the rendering issue where it is self occluding , ok this might be an obvious observation but anyway wink

  2. What is bizarre is that the right side artifacts are in a perfect checked pattern (perfect whole quad faces alternating) and the left side has random triangles. I placed two annotations from both sides, the lighting and darkening obviously is reversed according to sort when viewed from either side .. but the checked pattern and random triangles remain constant to the sides mentioned. ( there is a sort of other diagonal pattern going across from top to bottom on both sides worth mentioning )

I made the material color lighter and alpha slightly weak to pronouce the error in this test .. It occurs in both PBR and legacy engines :

alpha test 10 by shaderbytes on Sketchfab


(Shaderbytes) #17

here is the exact same mesh , where I manually trianglated the faces before exporting to sketchfab.

hth

alpha test 11 by shaderbytes on Sketchfab


#18

@shaderbytes @bastakompisar thanks for the continued thorough testing!

This is getting a bit beyond me...I'll poke the devs wink


(Stephomi) #19

In order for the blending to work, the transparent geometries have to be sorted farthest to nearest.
It's because the blending equation uses a substraction which is a non commutative operation (basically a-b is different than b-a).

For example for the ugly "quad/triangle pattern". It means the "incorrect quad/triangle" were drawn with two or more triangles drawn the wrong way round.

Why did it happen?
Because we sort the geometries between them but we don't sort the triangles themselves (too costly obviously because it can't be done by the gpu).

We can be more robust by doing OIT : http://en.wikipedia.org/wiki/Order-independent_transparency.
I can't tell you if we are going to do it or not but we are aware of the problem :D.


(Shaderbytes) #20

@stephomi its all because the color calculation is non commutative! Im wondering why GPU hardware does not have a separate 3 dimentional z-buffer for transparency to store each pixel and calculate the sorted color value after the buffer has been completed. Its kind of a two step process .. but its at the hardware level.

edit: ok my exmaple is too simple since z-buffer only stores depth.. so it has to store the pixel and the depth somehow wink

edit 2 : these guys wrote a paper on such an addition to hardware they named the "k buffer" which only requires a single pass an a small amount of extra memory wink http://www.sci.utah.edu/~csilva/papers/i3d2007.pdf