# Is there a way of finding how much light gets projected onto face of a patch?‏

3 views (last 30 days)
Emmin on 7 Feb 2016
Commented: Shurui Zhang on 15 May 2019
Hi,
Is there a way of finding how much light/intensity gets projected onto a face of a patch?
I am attempting to plot a surface, then convert each surface into a patch. I am introducing a light source at a certain position. Based on the plots, the faces exposed to light change color, while the faces that are not exposed to light get shaded. I am trying to find how much light/intensity each face gets from the source.
I have tried the code below. It seems that based on the colormap of each face, each face gets light equally, which doesn't seem to be the case when looking at the plots. Is there a way of finding how much light/intensity gets projected onto each face of a patch based on the location of the lighting?
[x,y,z]= cylinder([1 1],40);
cylinder1=surf(x,y,z);
surf_info = findall(cylinder1,'Type','surface');
fv = surf2patch(surf_info.XData,surf_info.YData,surf_info.ZData,surf_info.CData);
patch(fv,'FaceVertexCData',fv.facevertexcdata,'FaceColor','flat');
light1=light('Position',[2 2 2],'Style','local');
lighting flat
color_per_face = fvcdata(fv.faces(:,1));
color_map = colormap;
figure,plot(color_map)
color_per_face_2= fvcdata(fv.faces(:,2));
color_map_2 = colormap;
figure,plot(color_map_2)

Walter Roberson on 7 Feb 2016
What is fvcdata() ? That does not appear to be a routine defined by Mathworks.
Emmin on 7 Feb 2016
oh, it's a variable. I was using it interchangeably..
fvcdata = fv.facevertexcdata;

Walter Roberson on 7 Feb 2016
The data that you can fetch from the patch are all input values, not the values after modification for lighting. There is no obvious way to extract the lit values short of rendering to image and reading out from the image.

#### 1 Comment

Shurui Zhang on 15 May 2019
Hi Walter,
I came across the same question where I need a model to light my face patch in different angles. However, the lighting seems to be only a "post-processing" way for plot view and I cannot get my patch with altered brightness. I wonder how I can process my data with the same effect instead of just a visualization effect?
Thanks!
Shurui