Theverat / NormalmapGenerator

A simple program that converts images into normal maps
GNU General Public License v3.0
416 stars 51 forks source link

Ideas for 3D preview #23

Open Theverat opened 7 years ago

Theverat commented 7 years ago

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

Usability:

Features:

Bugs:

arcashka commented 7 years ago

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 commented 7 years ago

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:

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.

Theverat commented 7 years ago

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.

arcashka commented 7 years ago

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.

Theverat commented 7 years ago

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

So it's basically the roughness?

arcashka commented 7 years ago

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?

Theverat commented 7 years ago

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

arcashka commented 7 years ago

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

Theverat commented 7 years ago

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 commented 7 years ago

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.

arcashka commented 7 years ago

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

arcashka commented 7 years ago

without normal mapping image

with normal mapping image

i had no idea, normal mapping was this important!

Theverat commented 7 years ago

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

Theverat commented 7 years ago

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/

arcashka commented 7 years ago

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.

Theverat commented 7 years ago

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?

arcashka commented 7 years ago

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".

Theverat commented 7 years ago

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/

arcashka commented 7 years ago

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

Theverat commented 7 years ago

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

arcashka commented 7 years ago

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

Theverat commented 7 years ago

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