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

Material/light parameters are backward, should be swapped #173

Open
m-7761 opened this issue Dec 17, 2021 · 2 comments
Open

Material/light parameters are backward, should be swapped #173

m-7761 opened this issue Dec 17, 2021 · 2 comments

Comments

@m-7761
Copy link

m-7761 commented Dec 17, 2021

MM3D has a lighting set up that makes no sense, it's especially bad in the texture view where lighting pretty much washes out completely so it's as if there's none.

I noticed that when a new material is made it has 20% ambient and 80% diffuse, which is not how materials work. It should be 100% on both, and the lighting should be 20/80.

I'm going to try to reverse this relationship and see if it still looks the same or not. I'm making this issue to have a URL to cite.

@m-7761
Copy link
Author

m-7761 commented Dec 17, 2021

Here's the numbers with 100/100 default material. I recommend disabling GL_LIGHT_MODEL_AMBIENT to make things simpler, even though it might cause things to appear black in debugging. I had to use glLightModelfv with a pointer to zero it.

GL_LIGHT_0 (modelviewport.cc)

	GLfloat ambient[]  = { 0.2f, 0.2f, 0.2f, 1.0f }; //(0.8+0.2)*0.2
	GLfloat diffuse[]  = { 0.72f, 0.72f, 0.72f, 1.0f }; //0.9*0.8

GL_LIGHT_1 (modelviewport.cc)

	GLfloat ambient[]  = { 0.2f, 0.12f, 0.12f, 1.0f }; //(0.4+0.2)*0.2
	GLfloat diffuse[]  = { 0.72f, 0.4f, 0.4f, 1.0f }; //0.5*0.8 

The added 0.2 term is GL_LIGHT_MODEL_AMBIENT. Edited: Note it's important the lights don't sum to 100% so wire frames remain visible over polygons.

@m-7761
Copy link
Author

m-7761 commented Dec 17, 2021

BTW this does look much better in texture mode, and the red face selection is visible (as long as the texture isn't red) for a change. I have to get used to seeing models darker with lighting, but it looks correct.

EDITED: In texwidget.cc the material preview uses 0.8 for ambient because it's compensating for GL_LIGHT_MODEL_AMBIENT which defaults to 0.2. I also felt that texture mode was a bit too dark because of the need for the solid mode to not overpower the wireframes (which is still a problem in texture mode for untextured materials, or very bright textures) so I had the modelviewport.cc code to add 0.1 ambient to GL_LIGHT_MODEL_AMBIENT. Not sure if that's best since it still leaves diffuse down around 90% but it looks alright for materials with high to 100% ambient. I'm thinking about adding a something to control the lights and background color. The bright background is too strong working with additive blending modes.

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

1 participant