How to create a Lambertian (diffuse) sphere

12 views (last 30 days)
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:

Accepted Answer

Adam Danz
Adam Danz on 5 Oct 2020
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!