Light direction in surfl

1 次查看(过去 30 天)
Hi, I don't understand why it is not centered.
x = -1:.1:1;
y = -1:.1:1;
[X,Y] = meshgrid(x,y);
z = X.^2 + Y.^2;
surfl(x,y,z, [0 0 1])

采纳的回答

Walter Roberson
Walter Roberson 2021-5-11
The bright area is mostly because of the specular lighting that is being introduced.
doc specular says
R = specular(Nx,Ny,Nz,S,V) returns the reflectance of a surface with normal vector components [Nx,Ny,Nz]. S and V specify the direction to the light source and to the viewer, respectively. You can specify these directions as three vectors[x,y,z] or two vectors [Theta Phi (in spherical coordinates).
The specular highlight is strongest when the normal vector is in the direction of (S+V)/2 where S is the source direction, and V is the view direction.
The S that is used is the one you pass in, [0 0 1], but the V that is being used is being calculated by taking view() of the axes. In a new axes that has not had anything drawn in it yet, the default view is [-37.5, 30] . And if you do not have hold on in effect, then the newplot() that is automatically done resets the axes to this view.
You have two main choices here:
  1. clear the axes, view() as appropriate, and do hold on before doing the surfl() so that the specular values are calculated according to your desired view; OR
  2. when you call surfl(), pass in the optional 5th parameter, k with a low value in the 3rd component ks so that the specular lighting is not given much weight.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by