Light direction in surfl

1 回表示 (過去 30 日間)
Bobby Fischer
Bobby Fischer 2021 年 5 月 11 日
回答済み: Walter Roberson 2021 年 5 月 11 日
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 Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by