- 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
- 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.
Light direction in surfl
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Bobby Fischer
il 11 Mag 2021
Risposto: Walter Roberson
il 11 Mag 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])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/615070/image.png)
0 Commenti
Risposta accettata
Walter Roberson
il 11 Mag 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:
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!