2

I am experimenting with a dds texture and cubemap mip maps. When changing the bias in textureCube() i get really nasty normal artifacts. I have no idea what is causing this and cant find much reference on the bias parameter.

Live: (need to switch to uv and turn off normal)

http://dusanbosnjak.com/test/webGL/new/poredjenjeNM/poredjenjeNormalaBias.html

Screen:

enter image description here

More Screens: enter image description here

Bias 4

enter image description here

edit

Also of note, when you orbit around at say bias 6, you can clearly see the cubemap looking more or less correct (there is an edge seam between the faces) these normals breaking seem to be a different issue.

enter image description here

pailhead
  • 5,162
  • 2
  • 25
  • 46
  • 1
    Where are the "really nasty normal artifacts"? What should it look like? What are the blue lines identifying? – WestLangley Apr 10 '14 at 04:12
  • 1
    Hi West. If you turn off the normal maps, and switch to say normal screen you will see where the seams actually are in the mesh. If you turn on "uv" with the normals turned off, you will see a very smooth transition between the rest of the faces that are smooth and interpolated. When increasing the bias value (3rd argument of textureCube) additional seams will apear. Almost all of the triangles break up. – pailhead Apr 10 '14 at 04:34
  • 1
    Yes, I knew what screens to look at. I just do not see the artifacts you are referring to... unless you mean this: http://imgur.com/maNHzQO, which appears at mip bias = 5. – WestLangley Apr 10 '14 at 04:58
  • 1
    I'm not sure how to explain this. I marked it up. I dont know how to better feature this, maybe without bluring the map but keeping the mip levels so the different sides can clearly be seen. Normals seem to look just fine. – pailhead Apr 10 '14 at 05:18
  • OK, so far so good. The cube map seams are not what is bothering you. I was hoping that was it. :-) It's the yellow line that is the problem... Do you get similar problems with other geometries -- say a sphere? – WestLangley Apr 10 '14 at 05:27
  • Yeah, I also thought he meant the cubemap seams :) – mrdoob Apr 10 '14 at 05:29
  • I think it is just discontinuities in the vertex normals: http://imgur.com/nRYjmhf – WestLangley Apr 10 '14 at 05:36
  • switch the output to normal, there are no discontinuities there, but soemthing with the cubemap causes it. – pailhead Apr 10 '14 at 05:51
  • I have updated the example, it now featuers a sphere. It's slightly less noticable, but it's there. – pailhead Apr 10 '14 at 05:59
  • It seems to be related to trilinear filtering, but i'm unable to 'solve' it. I wonder if i'm even doing this correctly. – pailhead Apr 10 '14 at 07:27
  • Is this cubemap used for normals? Normals curve across the polygon, as you decrease the resolution you lose the curve, hence the seam? – gman Apr 10 '14 at 07:27
  • I'm not sure if i understand what you mean by that. I'll post another update, with different min filtering settings i get some funky stuff going on, but i cant quite make sense out of it. I basically just wanted to try and sample one mip level explicitely, but that is not happening. – pailhead Apr 10 '14 at 08:01
  • [Debug Cubemap, NearestMipMapLinearFilter](http://dusanbosnjak.com/test/webGL/new/poredjenjeNM/poredjenjeNormalaFilter.html) – pailhead Apr 10 '14 at 09:01
  • 1. I referred to discontinuities in the vertex normals -- actually, it's the derivative of the vertex normal... 2. You are indexing into the cubemap with the reflection vector and see what happens. There is clearly a discontinuity in the selected texel. Experiment with using the surface normal instead of the reflected vector. 3. Make sure the vectors are of unit length ( That might not matter, please advise. ). 4. Either the sphere or the tire appears to be reflecting the scene upside down. Check your vector math. (This comment refers to your original demo.) – WestLangley Apr 10 '14 at 13:42
  • Desktop OpenGL (3.x+) has seamless cubemap sampling to solve many discontinuity issues like these. Since it is not supported by D3D9 era (SM 2.0/3.0) hardware you can also implement it at the shader level if you fix-up your texture coordinates ***before*** GL has a chance to do any clamping of its own. [This article](http://www.altdevblogaday.com/2012/03/03/seamless-cube-map-filtering/) may prove useful if this is indeed your problem. You have to take the Shader Model 2.0/3.0 approach because WebGL is based on GLES 2.0. – Andon M. Coleman Apr 10 '14 at 16:55
  • It is still not a proper solution to the fundamental problem (inability to blend texels from different cubemap faces during sampling), but it does a pretty good job of hiding it. And as the article explains mipmap LODs make avoiding the problem convincingly even more difficult. – Andon M. Coleman Apr 10 '14 at 17:03
  • West, the link just above your post has the sphere sampling with a world normal. I guess this cannot be done this way, and textureCubeLod is most likely needed? 3. this, surprisingly does not seem to affect anything, i've been scaling the vector both up and down, and nothing would change (uniform scale though) – pailhead Apr 10 '14 at 17:45
  • Hi Andon, that's not so much of an issue (well more or less, i'd like to fix that as well). If you take a look at the marked up image at the bottom, the yellow seam was problematic, and i couldnt figure out why it appeared. Since it seems highly unlikely that this will do what i wanted, are there any other suggestions? would it make sense to blend between two cubemaps manually? – pailhead Apr 10 '14 at 17:49
  • [Just to note, all sides of the cubemap are painted the same](http://dusanbosnjak.com/test/webGL/new/poredjenjeNM/poredjenjeNormalaFilter.html), goes red 128, blue 64, green 32, yellow 16, pink 8, cyan 4 – pailhead Apr 10 '14 at 17:52
  • Andon could you link to the articles mentioned? Are you referring to the Ignacio Castaño thing for solving the cubemap seam? Different issue, but id like to take a look at it :) – pailhead Apr 11 '14 at 08:45
  • @pailhead I just realized that, for some reason, I am not always being notified of comments, so I was unaware of your recent posts. Andon may be having the same problem... In any event, I am looking forward to your future posts in the event you get to the bottom of this... – WestLangley Apr 15 '14 at 08:16
  • @pailhead Oh, man. You have been using a 5-month-old version of the library. In the current dev branch is [this commit](https://github.com/mrdoob/three.js/commit/dfe59fa5d037d199aff2516fe33561e7dcaddfad). If you don't want to upgrade, at least review recent changes so you know what you are missing. – WestLangley Apr 16 '14 at 15:16
  • Right, :\ because of the binormal stuff and the crude hack, i remain on the old version. Would be cool to figure out how to map attributes correctly from the material :) I think i actually got it to work, or at least appear just fine, but i didnt quite understand where it all went, – pailhead Apr 16 '14 at 20:27

1 Answers1

1

So, i've omitted the bias part, and added a sampler. This is what it looks like with 8 samples samples:

http://dusanbosnjak.com/test/webGL/new/pbr/poredjenjeNormalaBias.html

The last parameter multiplies the spec map (it's almost black on the tire) and mipbias (has nothing to do with mips, need to change the name) will actually blur it.

I tried to randomize things a bit by using a noise texture and by putting the sampling pattern in the texture but im not really sure what the implications are.

With the textureCubeLod a lot of this noise could be removed?

pailhead
  • 5,162
  • 2
  • 25
  • 46