Light direction in surfl

1 vue (au cours des 30 derniers jours)
Bobby Fischer
Bobby Fischer le 11 Mai 2021
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])

Réponse acceptée

Walter Roberson
Walter Roberson le 11 Mai 2021
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.

Plus de réponses (0)

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by