upbge
upbge copied to clipboard
Environment Map with LOD Bias Acts as Flat Shaded
When having LOD bias with environment maps in nodes, the normals seem to be broken. The result is similar to flat shading. Basically, you can see seams in reflection between any 2 triangles, unless they're reflecting the same pixel. This breaks a whole set of functionality for the LOD bias slider (e.g. reflection roughness).
Image:
File: http://pasteall.org/blend/index.php?id=48468
Edit. An option to force a certain mipmap level to be used would also work well.
Just wanted to ask - is it just me who thinks that this is quite important bug? This is like the No1 thing that prevents me from creating cool materials and effects in nodes (No2 being difficulties when using lamp data for shading input). And this issue has been there since the cubemaps got added in UPBGE. Please, fix it! :pray:
This is similar to https://github.com/UPBGE/blender/issues/531.
The normals should be normalized in the vertex shader before passing them to the fragment shader through the varying. Also, just to make sure everything is right, normalize it before using it in the fragment shader as well.
@panzergame Oh, I forgot I already told this.
I think that a solution could be being able to specify one of the mipmap textures to be used (instead of offsetting the LOD bias).
Being able to access a node that uses textureLod(sampler, coords, lod) instead of texture(sampler, coords, lod_bias) would solve this. Maybe another node called Texture LOD would do the trick? Shouldn't be that hard to make either. I'll look into it and maybe make it on my own.
A node is fine for using textureLod, you just have to treats cases for cube map and 2d map, else for material texture it is harder because you have to replace any call to texture2D in normal/parallax functions.
I just tried implementing, but got stuck at textureCubeLod() throwing this error:
error C7558: OpenGL does not allow profile specifiers on declarations
Seems to be something to do with OpenGL/GLSL profile core versions.
Just made a patch that adds a Lod Color output to texture nodes. This allows to use Lod Bias slider to access individual mipmap levels of texture. A .diff here: https://pastebin.com/ajSQ3NnA (sorry for being this messy, forgot that I would be better off by making my own branch and adding pull request)