Jump to content
Sign in to follow this  
Madeliefste Oh

Checkerboard distortion.. about phong reflection

Recommended Posts

I'm working on a cognac glass. At first glance all looks okay when I upload. But when I add the texture (with alpha channel) you see a checkerboard pattern distortion in the glass (1).

My first idea was that is was caused by the triangulation, I had let that done during the upload procedure. When I do the triangulation and then upload the mesh, the problem seems to have gone (2). However when I rotate the model, I still have this destortion in the foot of the glass.

CheckerboardProblem.png

To me it seems is has to do something with the phong shading. Or am I wrong, should I search the cause of this error somewhere else? How can it be prevented?

 

Share this post


Link to post
Share on other sites

I've seen this on a few other transparent objects with advanced lighting model active.  It seems like the shaders being used in the client don't like smooth shading anything seen THROUGH a transparent surface.  

 

It's the newest variation of the alpha-blending bug rearing its ugly head!

 

Share this post


Link to post
Share on other sites

Indeed, I had the advance lightning enabled.

But then I experimented a bit further with the phong shading. You can set that to different degrees. First I set a higher degree, but that made the distortion even worse. Then I set it lower, still distortion but with a different pattern. Then I deleted the phong shading completely, that deleted the smoothness and gave hard corners in the glass.

Then by trial and error I changed the degrees of the phong bit by bit and came to the next result. It seems this is the best I can get out of it, In the foot it is completely gone now, there just one little tiny spot at the top of the leg, but you can only see it when you look at the glass form this specific angle.

Phong-Angle.png

So far I discovered that you can influence how advanced lighting is received by the object, by finetuning the phong angle.

But in my 3D program I cannot see the effect of it, because the distortion does not appear there. Only when I upload a model with a different angle to SL, I can see the difference.

But is someone with more knowlegde can explain what 'phong' actually is, I would be grateful.
Tips and tricks are also welcome.

Share this post


Link to post
Share on other sites

I noticed this on a chandelier with specular material. I dont know if it was due to the same cause or not, but it was like the item had doubles (but it did not) and if I dragged the texture (which I had already applied to the entire mesh) specifically to the lighter color triangles, they seemed to "take" the texture in the same way as the darker colored ones.  It was like they had two materials -- but did not.

 

 

Share this post


Link to post
Share on other sites

When the item has doubles, its more a kind of flickering effect I see in my viewer. I'm sure there were no doubles, neither are there surfaces from the inside peaking through the outside.

So far I had only heard about the term 'phong shading', but in the meanwhile I learned that phong can have to do with shading or with reflection. In my 3d program (Cinema 4D), it is an object property that it simply called 'phong'. (I guess the smooth function in Blender is the same thing).

With what I observed in SL, I see that phong in SL is not so much about shading but has to do with reflection. Phong defines how the reflection (specular) is shown on the object. It is specially usefull in round or cylindrical objects.
But when you have a round or cylindrical object, there are a lot of angles from which the light can reflect. And the default settings of the phong reflection in your 3D program, do not always match with the way the advanced lighting model SL show the phong refection. This causes that on certain points in the model SL doesn't bend the light correct, and that shows breaks at the edges of your planes. At least that is my theory, until someone who understands this material better and can explain more clear, comes around the corner.

But most important is of course the solution. Set the phong angle to a different degree, and find out by trial and error which degree works best for a specific model.

 

Share this post


Link to post
Share on other sites

Just to clarify for Madeliefste, 'Phong Shading' refers to a specific algorithm for determining the size and tightness of the specular highlight when shading a polygonal model in 3D rendering.  It was a major improvement from 'Gourad Shading', which used face normals to calculate the specular reflection (and resulted in banding.)

 

The Phong shading model uses vertex normals, and interpolates across the faces between the normals.  This produces a much more accurate highlight (compared to Gourad shading, though less accurate and flexible than Blinn or several later models).  It was a little more computationally expensive than Gourad, but easily optimized.  It was noted for making everything look a bit 'plastic', the hallmark of early CG work.

 

Share this post


Link to post
Share on other sites

I made some wine glasses:

• Prim glass
• Low poly mesh glass
• High poly mesh glass

I applied exactly the same materials to all of them in SL:

• Bluish diffuse map with alpha
• Blank (white) specular map

In Second Life only the prim glass looks ok. Both of the mesh glasses have that strange checkerboard look. In Blender the mesh glasses look ok (the rendering on the right was done with Cycles).

I wonder what's up with those mesh glasses in SL? I cannot get rid of the checkerboard effect on them. With opague diffuse texture they do look smooth and nice, but with glass texture not.

Wine Glass test 2.jpg

Share this post


Link to post
Share on other sites

You should be able to get rid of the artefacts with marking some edgeloops sharp. Make the two edgeloops on the very top of the glass sharp, for example. The inner and the outer edgeloop on the bezel.

Share this post


Link to post
Share on other sites

It's long ago you I have used Blender, but I think you should experiment with the auto smooth option in the proporties.

blender-autosmooth.png

Set the angle to different degrees here. Then upload and see how the distortion changes.

I had the best result with ca 80 degrees, but I worked with another 3D program. And my model was different as well. I guess its just a matter of trying, and see what comes out best.

Please show your results if you manage to get them better.

Share this post


Link to post
Share on other sites

Ok, I did some more tests. I noticed that in the viewer mesh upload window there is a setting "Generate Normals" and beside it "Crease Angle". I checked selected "Generate Normals" - with the default Crease Angle of 75, I still got the faceted look. Then I experimented with different Crease Angle values.

I got good result with Crease Angle = 45. Problem solved! :matte-motes-big-grin:

Wine Glass test 3.jpg


I have never used Blender's "Auto Smooth". Maybe I might experiment with that one also.
Thank you all for the hints about what to try out.


[Edit]
The glass with crease angle of 45 looks smooth also when Advanced Lighting Model is off.
Naturally without the specular highlights.

[Edit 2]
Corrected Grease Angle to Crease Angle  :matte-motes-bashful-cute: :smileytongue:

  • Like 1

Share this post


Link to post
Share on other sites

Yes. Generate normals has a similar effect to using the edge split modifier. So i'ts something to do with the interpolation of normals around the edges of vthe glass. Why that should have the effect so far from the edge, I can't imagine. It seems to only happen with the double-walled object. Making a glass with no inside (horrible of course) there was none of this artefact.

ETA - note, it is "Crease", not "Grease".

Share this post


Link to post
Share on other sites

Another thing to note: It's not the angle that counts. Although there is a checkbox next to the Crease angle spinner, it doesn't do what you would expect. It only changes whether you can change the spinner. Even if you check it, if you don't also change the spinner, you will not get generated normals. If you change it to 75.1 and then back to 75.0, you will get the generated normals and lose the artefact, even if you then uncheck the checkbox! Crazy or what? You can see whether the generate normals is active by looking at the vertex count. When some of the edges get sharpened (which is what this does), the vertex count increases. Then it doesn't go back when you unxheck the box!!!

This is just not how it should be. Originally there was no checkbox, and the function was activated only by changing the angle. A checkbox was requested, and they put it in, but it's not working as it should - turning the function on and off. It's just turning the spinner on and off!!! This was leadimng you to the wrong conclusion. When you left it at the default 75.0, it was not using it at all, even though you checked the box. I will have to make a new jira! (Done).

Share this post


Link to post
Share on other sites


Drongle McMahon wrote:

Even if you check it, if you don't also change the spinner, you will not get generated normals. If you change it to 75.1 and then back to 75.0, you will get the generated normals and lose the artefact, even if you then uncheck the checkbox! Crazy or what?

 

I will have to make a new jira!

Indeed. I tested again with Crease Angle of 75 like you suggested. The glass indeed looks good without the artefacts. This surely is very confusing how it works. Ufff...

 

 

[Edit]

Corrected Grease Angle to Crease Angle

(The correct term was staring at me, and I wrote wrong!) :matte-motes-agape:

Share this post


Link to post
Share on other sites


arton Rotaru wrote:

Yeah, this leaves it with hard edges on the bezel as well.

Yes, with Crease Angle of 45 the bezel looks as if there was no thickness in at all. I tried again with Crease Angle of 75 (like Drongle suggested). Well, then there is thickness on the bezel but it lost its smooth circular look, the bezel looks like polygon, not a smooth circle - same with the edges of the round foot part of the glass. But all over elsewhere the glass looks smooth with no artefacts.

 

 

[Edit]

Like in earlier posts, Grease Angle corrected to Crease Angle  :smileyvery-happy:

Share this post


Link to post
Share on other sites

If you use the Edge split modifier, with explicitly marked sharp edges instead of an angle setting, you have the greatest possible control of which edges are sharp. It's possible you might be able to get what you want bthat way. However, since I don't inderstand the source of the shading artefact, I don't know what will and what will not work. I thinkn the artefact should be cinsidered a bug anyway, If we can get it more acurately tied down, a jira might be worth trying.

Share this post


Link to post
Share on other sites

This doesn't explain the artefacts, it's just basic explanation of what the crease angle is actually doing.

On that image below are 2 polygons which have a 90 degree angle to each other. If you set a crease angle smaller than  90°, it will leave the edge hard/sharp.

CA89-01.jpg

 

If you set the crease angle >= 90°, the polygons will be smooth shaded across the edge.

CA90-01.jpg

 

So on that glass, the polygons on the bezel have an angle about 85° or something like that, to the polygons on the walls. If you decrease the crease angle below that threshold, it will make all edges hard/sharp which have an angle which is greater than 85° to each other. So it's best to make only those edges sharp which you want to be sharp. And have a crease angle of what ever you like. In 3ds Max this is done with smoothing groups. In Blender it is done with the Edge Split modifier and marked the edges as sharp, as Drongle suggested. That way you can have the rest of the glass as smooth as you like and just the bezel edges hard. Which should fix the shading artefacts.

CAHE-01.jpg

Another fix could be to add supporting edgeloops very near to the bezel.

Share this post


Link to post
Share on other sites

While looking at the conditions where this artefact happens, to prepare a jira, I found a different workaround that doesn't give the hard edges. You just make the inside and outside of the glass different materials. You can still set them up with the same texture and specular settings. Here is a picture, left with one material, right with a separate material inside.

glassartefact1.jpg

I am guessing this is a manifestation of the alpha sorting bug. It seems to happen only where all four alpha surfaces overlap. I think it depends on the order the triangles are presented to opengl, and that the viewer sends all triangles for one material, then all for the next material. (That doesn't seem to explain the effect of the edge split though.)

  • Thanks 1

Share this post


Link to post
Share on other sites


Drongle McMahon wrote:

While looking at the conditions where this artefact happens, to prepare a jira, I found a different workaround that doesn't give the hard edges. You just make the inside and outside of the glass different materials. You can still set them up with the same texture and specular settings.

That looks like a perfect easy solution to overcome the artefact problem. No need to scratch one's head with all kinds of settings. I will try that one on my glass to see how it turns out. Thanks Drongle.

  • Thanks 1

Share this post


Link to post
Share on other sites

Ok, I did the test on my glass with 2 different materials, one inside and the other one outside. I got the same result as Drongle did - the glass looks perfect without artefacts.

No need to set the Crease Angle in the upload window, and no need to tweak with any other settings in Blender. This is looks like a perfect solution.

  • Thanks 1

Share this post


Link to post
Share on other sites

I have been using the multiple material trick for a long time without knowing there is another alternative like the one described here using the creasing feature, there are some complex items I would like to leave the faces free for different reasons and use the crease method instead, however, I have tried using the split edge modifier (blender) or the crease on upload window without success, maybe something has changed on recent viewer versions?

Share this post


Link to post
Share on other sites

I just tested with the latest LL release viewer [3.8.5 (305531)], and both the edge-split and the two material solutions still worked on my hemispherical cup example. So did the crease angle on upload. I think the edge split (or crease angle split) needs to completely separate the inside and outside to work fully, although only splitting half of the rim did  reduce the artefact a lot.

 

Share this post


Link to post
Share on other sites

Thanks for your time Drongle, sadly I haven't had success with the crease, even setting it to 45 using the lastest viewer, maybe it's my graphic card (I'm on a mac) or i'm not doing it correctly. :( 



 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...