zturtleman / mm3d

Maverick Model 3D is a 3D model editor and animator for games.
https://clover.moe/mm3d
GNU General Public License v2.0
110 stars 22 forks source link

What is m_shininess range? OBJ goes over GL_SHININESS (0-128) and MM3D sliders range is (0-1) #157

Open m-7761 opened 3 years ago

m-7761 commented 3 years ago

I'm hitting a glGetError on GL_SHININESS because OBJ file range for this is 0-1000 whereas OpenGL's is 0-128. This is just an exponent, i.e. pow(x,y) so it makes sense to clamp the OBJ loader. But I wonder if MM3D should go over 1 too? Or is that just not a realistic setting?

EDITED: I should note, I didn't even set up shininess for the OBJ file exported from Blender, so it's apparently defaulting to something like 225 I think it was? Is that an astronomical setting? If not MM3D is probably low-balling by limiting to 1.0 maximum. To my mind MM3D is not letting it be a power function as opposed to square-root style fractional exponent.

EDITED: Never mind (I guess?) the materials property window scales the value to 0-1 from 0-100.

zturtleman commented 3 years ago

I don't know anything about shininess to be honest.

m-7761 commented 3 years ago

Fortunately it's very simple. In the specular computation there's a pow function, so shininess is just pow(x,shininess). Edited: It's also called the "specular exponent" and the error that can arise (repeating OP) is OpenGL hits an error if the exponent is higher than 128 for some reason. Clamping it is all that's required. (MM3D's valid range seems to be 0 to 100. 28 less than OpenGL's.)

m-7761 commented 3 years ago

Actually that reminds me. If there are valid reasons to use an exponent less than 1, I think the Qt setup I saw yesterday may be limited to 100 ticks. Probably a value can be inputted by hand to under 1, but the ticks would only allow 0 or 1 and not anything between. Anyway the code I looked at divided the slider value by 100.