BennyQBD / 3DEngineCpp

It's like the 3D Game Engine, except in C++
Apache License 2.0
301 stars 84 forks source link

lights have a sharp edge #17

Closed Haeri closed 10 years ago

Haeri commented 10 years ago

Pointlight casting light on a spherical object, leaves a very sharp edge at the projection edge. Clearly I am throwing around words that I don't understand so here have a picture: bug See the sharp edge from the orange light behind the object? Maybe one could solve this with something similar to what you did with the shadows.

And a very similar thing happens with the selfshadow(Don't know if this word exists in English but I mean the shadow produced on the own geometry) bug2

Oh and please add this to freeMove.cpp:

if (input.GetKey(m_upKey))
    Move(GetTransform()->GetRot()->GetUp(), movAmt);
if (input.GetKey(m_downKey))
    Move(GetTransform()->GetRot()->GetDown(), movAmt);

it makes life easier xD

PseudoFreak commented 10 years ago

I don't think this is an issue with the game engine code, could you please post the object file? This could be an issue with the normals used by the model.

Haeri commented 10 years ago

The first time I imported the object, it looked really jacked up. So I went into blender again and let the normals recalculate. But here have a look. (I got the model from Blend Swap)

http://n.ethz.ch/student/lukal/Other/Download/human.zip

PS: There are still some sharp angles exp: eyecracks and earholes, which are still "black".

BennyQBD commented 10 years ago

Thanks for the mesh! It really helped track down the issue. Try now, everything should work fine.

Haeri commented 10 years ago

Yup its fixed. Thank you! It's a bummer you didn't add the Z-movement like described in OP. But well.

Oh and thank you for the response on Youtube. I figured it out now how to rotate things.. But I still don't understand why you decided to go with a 4 value input(which is hard to control) and not with a simple vector3f input where every value stands for a rotation degree in that axis... Butt I am sure you had your reasoning which I would never understand xD

Some other inputs I would like to give: I can't wait for the OpenGL GUI tutorial, but I actually meant something much simpler and dirtier like a quick c++ windows form with 3 buttons to access the position of objects (It is really hard trying to set up a scene.. adjust by 0.6, build exe, adjust 0.3, build exe, adjust by 0.42...)

Another thing is that for some reason the objectmesh has holes. Mostly where there are sharp edges like on the edge of the eye and at the ears.. I thought it was because of the normals but recalculating them doesn't seem to fix it... bug3

Another small thing. I think the normalmap reader is inverted. I generated a normalmap with the NVIDIAplugin and here is how it looked. The normal.png was what it generated by default and norma_inv.png is with all the values inverted. bug4

Here a link for the human.obj with all the textures: http://n.ethz.ch/student/lukal/Other/Download/human.zip

And one last thing. I found this incredible site. Its about optics. http://www.cs.ubc.ca/labs/imager/tr/2012/PolynomialOptics/ There is a source code provided, but I can't figure out how to make it work. I am just hinting that this as depth of field in your engine.... I would die! (But if someone has any clue how I could turn this into a simple image "editor", (Basically input image-path, run algorithm, export image with beautiful bokeh) please tell me!)

Sorry for such long posts :S

BennyQBD commented 10 years ago

I actually didn't see that part about the Z rotation. If you like, it's easy enough to add yourself. I might add it at some point as well, who knows?

A Vector3f with Euler angles is only simpler when you're working with one of the 3 global axes. As soon as you start trying to rotate around more than 1 axis, it becomes very difficult and awkward to get the orientation you want, because rotating around 1 axis affects how you rotate around all the other axes. In fact, this actually makes it completely impossible to rotate into certain orientations. I made a blog post about this, which you can read here if you're interested: http://thebennybox.blogspot.com/2014/03/the-perils-of-euler-angles.html

I won't be using a "quick and dirty windows GUI" because that only works on windows. The engine is cross platform, so there's no point in making a system that only works on one platform when you can make a system on all platforms. (Is there even such a thing as a quick and dirty windows GUI? I mean my word, have you seen how complex the windows windowing API is? But I digress...)

The reason the mesh has holes in it is because the mesh actually has holes in it. If you open it up in a 3D modeling program like Blender or 3DS Max, you can zoom in and see those holes are really there. The reason the engine seems to see through it is because our engine doesn't render back faces, so the interior of the mesh is transparent. There's a good chance that wherever you're seeing a hole, you're actually seeing a polygon that's facing away from the camera.

I'm planning to cover depth of field at some point, don't worry. I don't know for sure if I'll use their algorithms or not, but I'm going to do it in some form or another.

With that said, I'd appreciate it if you keep the issues section focused on issues with the engine. If you want to talk to me about something else, I'm more than happy to discuss it with you either on youtube (comments or inbox) or in email (thebennybox@gmail.com).

So with that, I believe this particular issue is resolved. If no one has any objections, shall we close this?

Haeri commented 10 years ago

Everything works fine and dandy. Thank you!

pythoneer commented 10 years ago

@Haeri regarding the "inverted" normal maps https://github.com/BennyQBD/3DEngineCpp/issues/5 and here is the video at the exact position benny talked about it. http://youtu.be/dF5rOveGOJc?t=24m20s

Haeri commented 10 years ago

@pythoneer Thank you. Should have searched it first.