PBR reflection stange behaviour - opengl

I've implemented a PBR rendered using OpenGL in my deferred rendering engine.
The problem is that there are strange signs on my object as the roughness increases.
You can see this on these images:
I've found out that the problem is with the filtering. Using LINEAR_MIPMAP_LINEAR gives the results shown above, but when I use NEAREST_MIPMAP_LINEAR the strange seams aren't present but when the surface is more rough you can see the pixels of the texture (as you can see on the image below).

As Robinson mentioned in his comment, reading the article he posted showed me the answer: i just needed to enable GL_TEXTURE_CUBE_MAP_SEAMLESS on my cubemap texture.

Related

what is multisample per pixel in directx11 DXGI_SAMPLE_DECS

I was reading documentation about DXGI_SWAP_CHAIN_DESC and i came across with DXGI_SAMPLE_DESC
Count
Type: UINT
The number of multisamples per pixel.
now what exactly is multisamples per pixel?
DXGI_SAMPLE_DESC as you surmised is for specifying Multi-Sample Anti-Aliasing (MSAA).
That said, you should be aware that the SwapChain support for MSAA is not something you should use anymore. As such, just always set DXGI_SWAP_CHAIN_DESC.SampleDesc.Count = 1; and DXGI_SWAP_CHAIN_DESC.SampleDesc.Quality = 0;.
Instead, to use MSAA you should explicitly create your own MSAA render target and explicitly resolve the result yourself as part of your presentation of the results to the single-sample SwapChain. For details on why and how, see this blog post series.
Note that you can use MSAA SwapChains for DirectX 11 with the older DXGI_SWAP_EFFECT_DISCARD and DXGI_SWAP_EFFECT_SEQUENTIAL flip-effects, and the DirectX 11 runtime will do the resolve automatically. Per the blog post, this is NOT supported for DirectX 12 or the use of modern DXGI_SWAP_EFFECT_FLIP_DISCARD or DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL swap effects. This is really a 'toy' setup as any production rendering will do additional processing after the resolve from multi-sample to single-sample before putting it into the swapchain for display.
As you are likely new to DirectX 11, you may want to look at DirectX Tool Kit. I have a tutorial that covers MSAA.
ok it is anti-aliasing (my bad i didn't know that)
Anti-aliasing is a technique used by users to get rid of jaggies that form on the screen. Since pixels are rectangular, they form small jagged edges when used to display round edges. Anti-aliasing tries to smooth out the shape and produce perfect round edges.

OpenGL triangle strips have artifacts (missing triangles)

I am using a nice little line rendering library that utilizes GL_TRIANGLE_STRIPS to make smooth lines (described here). The lines look great EXCEPT that there are random missing triangles. See image at below link.
Since I have not seen any other complaints on the blog for this software, I am thinking there might be something wrong with my OpenGL state that is causing this, but I don't know what. Disabling GL_CULL_FACE had no effect (though my understanding is that all triangles in a strip must face the same way anyways) and I am low on ideas.

Google sketchup objects transparent in opengl?

I have made two objects in googlesketchup.
link1
.On the link you can see a picture of the model. I just made two rectangles and then used push and pull, later I used paint bucket to paint the textures on.
I export this file as .obj and then imported in opengl. The weird thing is that you can see one object through the other object. There is a picture.
link2
Any ideas how to make the objects non-transparent?
It looks to me a depth test problem.
You can notice it by rotating the model view matrix and you will notice that the transparency will follow an odd behavior.
Try to enable the DEPTH test in your code by adding the following code line:
Using C:
glEnable(GL_DEPTH_TEST);
Cheers
Forgot to enable depth testing? (glEnable(GL_DEPTH_TEST);)

UV Coordinates Not Correct

I am using Cheetah3D if it mattters.
The UV coordinates I am reading in my object made in Cheetah3D are NOT between 0 and 1 like the example model I was provided with the 3DS model object loading code.
Some go above 1 as high as 1.56 or so while others go below 0, as far as -4.56. This is causing extreme abnormalities when trying to map the texture to the object.
Any ideas? Should I contact the Cheetah3D folks or is there a way to fix this in code myself dynamically? (The reason for posting on SO).
Well without seeing screenshots the only thing that comes to mind is that the texture cords should be wrapped but you're clamping them. See the documentation for glTexParameter* on how to change that setting. A screenshot of a SIMPLE model would really help here.

OpenGL: Enabling multisampling draws messed up edges for polygons at high zoom levels

When im using this following code:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 6);
and then i enable multisampling, i notice that my program no longer cares about the max mip level.
Edit: It renders the last miplevels as well, that is the problem, i dont want them being rendered.
Edit3:
I tested and confirmed that it doesnt forget mip limits at all, so it does follow my GL_TEXTURE_MAX_LEVEL setting. ...So the problem isnt mipmap related, i guess...
Edit2: Screenshots, this is the world map zoomed out a lot and using low angle to make the effect shown the worst possible way, also there is rendered water plane under the map, so theres no possibility to take black pixels from anywhere else than map textures:
alt text http://img511.imageshack.us/img511/6635/multisamplingtexturelim.png
Edit4: All those pics should look like the top right corner pic (just smoother edges depending on multisampling). But apparently theres something horribly wrong in my code. I have to use mipmaps, the mipmaps arent the problem, they work perfectly.
What im doing wrong, or how can i fix this?
Ok. So the problem was not TEXTURE_MAX_LEVEL after all. Funny how a simple test helped figure that out.
I had 2 theories that were about the LOD being picked differently, and both of those seem to be disproved by the solid color test.
Onto a third theory then. If I understand correctly your scene, you have a model that's using a texture atlas, and what we're observing is that some polygons that should fetch from a specific item of the atlas actually fetch from a different one. Is that right ?
This can be explained by the fact that a multisampled fragment usually get sampled at the middle of the pixel. Even when that center is not inside the triangle that generated the sample. See the bottom of this page for an illustration.
The usual way to get around that is called centroid sampling (this page has nice illustrations of the issue too). It forces the sampling to bring back the sampling point inside the triangle.
Now the bad news: I'm not aware of any way to turn on centroid filtering outside of the programmable pipeline, and you're not using it. Do you think you want to switch to get access to that feature ?
Edit to add:
Also, not using texture atlases would be a way to work around this. The reason it is so visible is because you start fetching from another part of the atlas with the "out-of-triangle" sampling pattern.
Check also what have you set for the MIN_FILTER:
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ... );
Try the different settings ( a list is here ).
However, if you're dissatisfied with the results of gluBuild2DMipmaps I advise you to look at alternatives:
glGenerateMipmap/glGenerateMipmapEXT (yes, it works without FBO's)
SGIS_generate_mipmap extension (widely supported)
Especially the latter is highly customizable. And what was not mentioned, this extension is fired up by setting GL_GENERATE_MIPMAP to true. It is automatical so you don't need to do recalculation if data changes.
You should enable multi-sampling through your application, not the nvidia control panel, if you want your rendering to always have it. That might even fix your issue.
As for the GL_TEXTURE_MAX_LEVEL setting being ignored when using the control panel multisampling, it sounds like a driver bug/feature. It's weird because this feature can be used to limit what you actually load in the texture (the so-called texture completeness criteria). What if you don't load the lowest mipmap levels at all ? What gets rendered ?
Edit: From the picture you're showing, it does not really look like it ignores the setting. For one thing, MAX_LEVEL=0 is different from MAX_LEVEL=6. Now, considering the noise in your textures, I don't even get why your MAX_LEVEL=6/MS off looks that clean. It should be noisy based on the MAX_LEVEL=16/MS off picture. At this point, I'd advise to put distinct solid colors in each mip level of your diffuse texture (and not rely on GL to build your mips), to see exactly which mip levels you're getting.