How to create a Lambertian (diffuse) sphere

24 次查看(过去 30 天)
Hello everyone, I need to generate the image of a Lambertian sphere in Matlab. A Lambertian surface differes from a specular one by the fact that it reflects light in all directions regardless the angle of incidence.
I saw that exists the function
R = diffuse(Nx,Ny,Nz,S)
where Nx, Ny and Nz are the surface's normal vector components. The problem is that I need to generate a sphere.
The result I want to achieve is the following:
The code I've written is:
[x,y,z] = sphere(100);
figure
h = surf(x,y,z,'FaceColor','w','FaceAlpha',1);
set(h,'edgecolor','none');
axis equal
ax = gca; set(ax,'Color','k');
light('Position',[1 0 0],'Style','infinite','Color','w');
lighting gouraud
but the result I get is:

采纳的回答

Adam Danz
Adam Danz 2020-10-5
There are probably official definitions and methods for a Lambertian diffuse sphere but here's something that looks like it.
[x,y,z] = sphere(100);
figure
h = surf(x,y,z,'FaceColor','w','FaceAlpha',1);
set(h,'edgecolor','none');
axis equal
ax = gca; set(ax,'Color','k');
light('Position',[-1 -2 0],'Style','infinite','Color','w');
lighting gouraud
h.BackFaceLighting = 'unlit';
h.DiffuseStrength = .6;
h.SpecularStrength = 0;
h.AmbientStrength = .07;
Potentially relevant literature

更多回答(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