Question

Here is a Model3D of a tube displayed within Viewport3D element:

enter image description here

The tube is very long so I cut the texture in segments display just one segment to save memory.

To hide little black circle at the end of the finite model tube, I have added a PointLight.

However, no matter which values of ConstantAttenuation, LinearAttenuation and QuadraticAttenuation I choose, the light falls off too quickly and the model is too dark.

I tried adding an AmbientLight, but this immediately makes the end of the tunnel visible and spoils the realism (user should never notice the model is finite - it will shift the texture or camera and keep sime light just around camera).

How to add more light using just PointLight?

I know the attenuation factor formula is:

ConstantAttenuation + LinearAttenuation * D + QuadraticAttenuation * D^2

where D is the distance from light source.

The light intensity is then divided by the computed factor. However, when I use ConstantAttenuation value 1 and set others 0, there should be no attenuation at all (factor is 1 at all points and distance plays no role). Yet the model still shows light falloff...

Code:

this.pointLight = new PointLight
                            {
                                Position = new Point3D(0.0, 0.0, 0.0),
                                Color = Colors.White,
                                ConstantAttenuation = 1.0,
                                LinearAttenuation = 0.0,
                                QuadraticAttenuation = 0.0
                            };
Était-ce utile?

La solution

Your problem will not be related to pointlight probably but to the fact that with growing distance and same normal vectors on your model, the angle at which light hits the surface will be different so less and less light will be reflected so the further meshes will appear darker and darker. Ambient light in contrary to other lights ignores normals thats is why you see your whole model.

Using following code all your meshes will reflect same amount of light no matter how far they are and then you can play with attenuation to make more distant darker.

    meshGeometry3D.Normals.Clear();
    foreach (Point3D point in meshGeometry3D.Positions)
    {
        meshGeometry3D.Normals.Add(camera.Position-point);
    }

Or you can keep your Pointlight setting and adjust normals just a bit.

There is also Range property of the Pointlight but that is used just to limit range of your pointlight directly if you need it so it will not help you.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top