Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ideas for 3D preview #23

Open
Theverat opened this issue Apr 20, 2017 · 22 comments
Open

Ideas for 3D preview #23

Theverat opened this issue Apr 20, 2017 · 22 comments

Comments

@Theverat
Copy link
Owner

Theverat commented Apr 20, 2017

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: 55e80fe
  • 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 Theverat mentioned this issue Apr 20, 2017
@arcashka
Copy link
Collaborator

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
Copy link
Collaborator

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.

@Theverat
Copy link
Owner Author

Theverat commented Apr 22, 2017

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
Copy link
Collaborator

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
Copy link
Owner Author

Theverat commented Apr 22, 2017

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

So it's basically the roughness?

@arcashka
Copy link
Collaborator

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
Copy link
Owner Author

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
Copy link
Collaborator

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

@Theverat
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link
Collaborator

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

@arcashka
Copy link
Collaborator

without normal mapping
image

with normal mapping
image

i had no idea, normal mapping was this important!

@Theverat
Copy link
Owner Author

Theverat commented Apr 22, 2017

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

@Theverat
Copy link
Owner Author

Theverat commented Apr 23, 2017

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
Copy link
Collaborator

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
Copy link
Owner Author

Theverat commented Apr 24, 2017

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
Copy link
Collaborator

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 arcashka reopened this Apr 24, 2017
@Theverat
Copy link
Owner Author

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
Copy link
Collaborator

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

@Theverat
Copy link
Owner Author

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

@arcashka
Copy link
Collaborator

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

@Theverat
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants