NormalmapGenerator icon indicating copy to clipboard operation
NormalmapGenerator copied to clipboard

Ideas for 3D preview

Open Theverat opened this issue 8 years ago • 22 comments

This is a collection of ideas and possible features for the 3d_preview branch.

Usability:

  • ~~Show a message when OpenGL 4.x is not supported by the system~~ Done: 55e80fe02ca72c5821b66f543730b366f2be8f95
  • ~~Navigating with WASD and moving the light with IJKL is overly complicated in my opinion. I think it would be enough if the user can rotate the cube with the mouse, camera and light don't need to be movable.~~ Done.
  • ~~Rename "partition frequency" to "mesh resolution"~~ Done.

Features:

  • ~~It should be possible to disable the influence of each map (for example to study only the normalmap influence without any displacement)~~ Done.
  • ~~The preview should start when the first map is generated, it should not require all three maps~~ Done.
  • ~~I think the background should be black or grey, because currently it doesn't match the lighting in the scene (there's no purple environment light as far as I can tell)~~ Done.
  • Smooth shading on the mesh possible?
  • Use a shading model like Phong, or even PBR?

Bugs:

  • ~~When a new image is loaded, the old maps are still used in the preview (they are only replaced when new maps are generated)~~ Done.
  • ~~There are huge differences in lighting between enabled and disabled normalmap, maybe there's a bug in some vector transform?~~ Done.

Theverat avatar Apr 20 '17 18:04 Theverat

Navigating with WASD and moving the light with IJKL is overly complicated in my opinion. I think it would be enough if the user can rotate the cube with the mouse, camera and light don't need to be movable.

In which case (static light, static camera, ability to rotate cube) user will not have any opportunities to see how looks not illuminated sides of the cube. I think, rotating camera using mouse around static cube with static light, would be the better way. Though it's technically harder.

All the features about influences of particular maps are on point. But before taking care of it i'll enable influence of specular map, that's won't take long. So after i can make these features for all the generated maps.

Smooth shading on the mesh possible?

i've just read about this technique, and will be interesting to try it. But likely after other items on this list.

arcashka avatar Apr 21 '17 08:04 arcashka

Hello =) There's a lot things about light which are very relative to some parameters. For example: Applying specular map need at least two parameters:

  • float number that controls the brightness of reflection.

  • float number that controls amount of pixels for which specular influence will be calculated.

I don't want to complicate project too much, but hardcoding this part doesn't seems good idea. So maybe best option is to add "light options" button to viewer and give possibility to user to change this constants.

arcashka avatar Apr 22 '17 08:04 arcashka

Hm, I thought the brightness of reflection is controlled only by the pixels in the specular map (0 -> no reflection, 1 -> full reflection). And isn't the amount of influenced pixels simply all of them? Or maybe all minus those where the specularity map is 0? Would this cause a performance hit?

~~Do you have a link for the kind of shader you are referring to so I can better understand where these parameters come from?~~ Didn't see that you already commited it.

Another note: do you plan to take the fresnel effect into account for the specular shading? It's not something we have to do right away, but since most renderers today are using physically based shading it would be useful if the preview takes that into account, too.

Theverat avatar Apr 22 '17 09:04 Theverat

Well, I commited hardcoded version.

This "brightness" It's like depth value for displacement map 0.0 2 1.0 3 10.0 1

About "amount of influenced pixels" i just couldn't express myself correctly i meant this: float cosAngle = max(0.0, dot(surfaceToCamera, reflectionVector)); float specularCoefficient = pow(cosAngle, light.MatShines); so cosAngle lies between 0 and 1 and exponentiation will reduce radius of affected pixels.

this constant 10.0 4

and same constant = 30.0 5

About fresnel Yes, i will try to do this.

arcashka avatar Apr 22 '17 11:04 arcashka

so cosAngle lies between 0 and 1 and exponentiation will reduce radius of affected pixels.

So it's basically the roughness?

Theverat avatar Apr 22 '17 11:04 Theverat

i guess it's not, or it's and i just couldn't understand you. But just to be sure i will try again.

in this screenshots color of every pixel was made just from specular influence

10.0 6

30.0 7

It's called roughness?

arcashka avatar Apr 22 '17 11:04 arcashka

Looks a bit like it, but I'm not sure. We can add a slider for it and see if it's useful. Here's an example how roughness usually works in renderengines: http://dragengine.rptd.ch/wiki/lib/exe/fetch.php/gamedev:chart_roughness.png

Theverat avatar Apr 22 '17 11:04 Theverat

Thank you for example. Yea, it looks close. And what about brightness?

arcashka avatar Apr 22 '17 11:04 arcashka

For now we can also add a slider for it. But in the end I think we can choose one value that works good and hide the slider. By the way, I don't think all of this stuff has to be perfect, after all people are using this tool with all kinds of renderengines, so the preview will never be accurate for all of them.

Theverat avatar Apr 22 '17 12:04 Theverat

I pushed a commit to display an error message when the shaders failed to compile. I hope this doesn't cause merge conflicts at your end.

Theverat avatar Apr 22 '17 12:04 Theverat

That caused, but seems like it's fine for now.

arcashka avatar Apr 22 '17 12:04 arcashka

without normal mapping image

with normal mapping image

i had no idea, normal mapping was this important!

arcashka avatar Apr 22 '17 15:04 arcashka

The difference is very strong here because of the flat shading.

Theverat avatar Apr 22 '17 19:04 Theverat

Your last images look very different in lighting, notice how there are very bright faces in the top image, but only dull grey in the bottom image. I think there's a bug in the normalmap apply code somewhere, maybe some vector transform is wrong. I added example images in the first post that also show the problem.

Another thing I noticed: If I understand it right we are currently using the normalmap only for diffuse lighting, right? Specular lighting is taking the geometry normal, without the normalmap: https://github.com/Theverat/NormalmapGenerator/blob/3d_preview/shader.frag#L66 Maybe we can write a function that returns the normal and use it for both diffuse and specular lighting.

This tutorial could be helpful: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-13-normal-mapping/

Theverat avatar Apr 23 '17 10:04 Theverat

Another thing I noticed: If I understand it right we are currently using the normalmap only for diffuse lighting, right?

That's correct. I'll try to fix it in few hours.

arcashka avatar Apr 24 '17 06:04 arcashka

I saw your latest commits, great stuff. Meanwhile I tried to implement smooth shading, more precisely Phong shading, but I'm failing hard. Most of the GLSL specifics are gibberish to me, it seems there are thousands of ways to specify input and output variables and other weird stuff. Do you know a beginner tutorial that explains this shader stuff by chance?

Theverat avatar Apr 24 '17 13:04 Theverat

Thanks! Yea, there a lot of information. And honestly i don't remember if i have seen any beginner tutorials not about "drawing colored triangle".

arcashka avatar Apr 24 '17 14:04 arcashka

After searching a bit longer, I found a tutorial that explains the syntax pretty good: http://www.lighthouse3d.com/tutorials/glsl-tutorial/glsl-core-tutorial-index/

Theverat avatar Apr 24 '17 18:04 Theverat

Hello there! How is it going with smooth shading? maybe can i help?

arcashka avatar Apr 28 '17 17:04 arcashka

Sorry, the last days were busy so I could not work on this project. If you like you can start yourself.

Theverat avatar Apr 28 '17 17:04 Theverat

I probably will make camera control next. Was just asking if i could help you with opengl and shaders stuff :)

arcashka avatar Apr 28 '17 17:04 arcashka

Thanks, I'll ask if something comes up. But until wednesday next week I can't do much because I'll be travelling.

Theverat avatar Apr 28 '17 18:04 Theverat