简体   繁体   中英

Proper way to illuminate a 2D surface in 3D space?

EDIT: I've solved the issue below the tilde line -- the missing chunks -- by fixing an elementary error in my for-loop dealing with calculating face normals. I now have a new problem though: strange, unwanted shadows on the surface itself. Some areas appear darker than others... See the next picture for the current issue.

I have an omni light added to my scene's root node as well as a directional light added in the same manner. For some reason I can't seem to light the underbelly of the surface otherwise. Notice the strange shadow on the inside of the concave surface (it's more pronounced when I remove the subdivision effect as I have done here) -->

在此处输入图片说明

Here is the surface from above -- notice how some areas seem strangely darker.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a concave surface.

在此处输入图片说明

I have these smooth, curved planes in 3D space. Right now, they look rather cartoonish -- I would like to utilize some form of lighting to make them look more "3D-ish."

I have tried various combinations of ambient lighting, omni lighting, and default lighting, but nothing seems to work right. I get something quite strange when I apply something like a basic omni light --

在此处输入图片说明

Here is another look at a better angle using omni lighting. Looks like someone took a bite out of it --

在此处输入图片说明

Am I overlooking a specific type of light or lighting strategy?

I'd like to avoid used baked lighting, because the scene is rather simple. Thanks.

I'll outline my steps for the bold.

1: I specify the vertices for each of the four faces of a pyramid-like shape. Like this (apologies for my lack of artistic ability) -->

在此处输入图片说明

2: I specify the indices for the face, ie, [0,1,2, 0,2,3, etc.]

  1. I create a dictionary mapping each vertex to the sum of that vertex's adjacent, normalized face normals.

  2. I append each of these summed up normalized per-vertex normals to a vector.

  3. I combine the vertices, indices, and vector of normals to create an SCN Geometry.

  4. To get the rounded look, I increase the subdivision count.

  5. Pray that it works.

I'm new to the 3D world, so I could be way out in left field and not even know it.

This should give you a reasonable result with minimal effort and the least possible need to understand 3D lighting.

Open the Fox game example/sample from Apple:

https://developer.apple.com/library/prerelease/ios/samplecode/Fox/Introduction/Intro.html

Delete everything from the level.scn Scene Graph other than Lights, Camera and the Mountain.

And then add your geometry object to a node at the bottom, where I have the sphere highlighted at the bottom of the Scene Graph....

苹果Fox SNK示例中level.scn的场景图

Now the material needs a bit of work, to make it useful.

Select the Mountain by clicking on it in the View, and goto the material editor and make it look like this, just keep checking against this image until yours matches the few (weird) changes I've made. And trust me this will work out fine:

材料设置

When you want to get that lovely red you have, you simply change this property: DIFFUSE : It's right at the top of the Material settings.

Now you have a material and lighting setup that gives a reasonable approximation of curvature in a 3D space.

Applying this material to your object is a little weird, and unintuitive, you go here, and click on the add button, and pick the material with the same name as the one in the above image, that's on the mountain.

将材质应用到另一个对象:

You can improve this by adding two more lights in what's known as a “3 point lighting setup”, google this phrase to see it explained.

Further, you can add off screen (out of camera) placards, usually white, to manage key reflections to further assist in users getting a feel for what's being presented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM