Hello
I would like to get as an attribute the light received on a geometry.
Is it possible?
I could achieve it by getting Cd attribute using a texture that was previously baked with the light. However that would be a more tedious and less flexible process.
Getting light received on a geometry, as an attribute
2097 9 1- paulfe
- Member
- 13 posts
- Joined: 6月 2018
- Offline
- jsmack
- Member
- 7837 posts
- Joined: 9月 2011
- Offline
paulfe
Hello
I would like to get as an attribute the light received on a geometry.
Is it possible?
I could achieve it by getting Cd attribute using a texture that was previously baked with the light. However that would be a more tedious and less flexible process.
You could do as others have done and write a renderer in SOPs using VEX.
- protozoan
- Member
- 1642 posts
- Joined: 3月 2009
- Online
- Andy_23
- Member
- 918 posts
- Joined: 3月 2014
- Offline
paulfe
Hello
I would like to get as an attribute the light received on a geometry.
Is it possible?
I could achieve it by getting Cd attribute using a texture that was previously baked with the light. However that would be a more tedious and less flexible process.
What would you do with that attribute? Jsmack and Martin's suggestions are all valid. Yet we don't know what you want out of it.
I'm curious.
- paulfe
- Member
- 13 posts
- Joined: 6月 2018
- Offline
Thank you for the replies and help!
jsmackCould you share with me references or other pointers for how to do that.
You could do as others have done and write a renderer in SOPs using VEX.
protozoanI don't need advanced lighting, this is looking simple and suitable for my application. I will try this technique.
If "simplistic" lighting is enough (like: find out what's approximately in the shadow of a directional light or a point light) you can look at the mask by feature SOP. This won't do "real" lighting though.
Andy_23I am experimenting turning 3D objects into vectorial 2D for a plotter machine. Testing in pointillist or wireframe style, I wish to control the density of the mesh/points based on lights and shadows. Here is a few tests
What would you do with that attribute? Jsmack and Martin's suggestions are all valid. Yet we don't know what you want out of it.
I'm curious.
Edited by paulfe - 2021年12月21日 05:54:08
- Konstantin Magnus
- Member
- 670 posts
- Joined: 9月 2013
- Offline
- Raycast each point towards the camera and towards the light.
- Remove the points if any of their rays intersect with your mesh.
-
Map the angle between point normals and light directions to radii.
- Project the points on a plane perpendicular to the camera.
- Rotate the plane points to the Z-axis.
// PARAMETERS string cam = chs('camera'); string light = chs('light'); float radius_min = chf('min_radius'); float radius_max = chf('max_radius'); // POSITIONS matrix xform_cam = optransform(cam); matrix xform_light = optransform(light); vector pos_center = getbbox_center(0); vector pos_cam = cracktransform(0,0,0,0,0, xform_cam); vector pos_light = cracktransform(0,0,0,0,0, xform_light); vector pos_srf = v@P + v@N * 1e-3; // DIRECTIONS vector dir_cam = normalize(pos_cam - pos_srf); vector dir_light = normalize(pos_light - pos_srf); vector dir_center_cam = normalize(pos_cam - pos_center); // RADIUS float angle = max(dot(normalize(dir_light), v@N), 0.0); float radius = chramp('radius', angle) * radius_max; // RAYCASTING int prim_cam = intersect(0, pos_srf, dir_cam, set(0), set(0)); int prim_light = intersect(0, pos_srf, dir_light, set(0), set(0)); int prim_max = max(prim_cam, prim_light); if(prim_max >= 0) removepoint(0, i@ptnum, 1); // ORIENTATION vector dir_perp = cross(dir_center_cam, dir_cam); vector pos_plane = cross(dir_center_cam, dir_perp) + pos_center; matrix3 m_rot = maketransform(dir_center_cam, {0,1,0}); pos_plane *= invert(m_rot); // ATTRIBUTES v@P = pos_plane; v@N = {0,0,1}; v@up = {0,1,0}; f@mask = angle; f@pscale = radius;
Edited by Konstantin Magnus - 2021年12月24日 13:16:10
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- protozoan
- Member
- 1642 posts
- Joined: 3月 2009
- Online
- mestela
- Member
- 1748 posts
- Joined: 5月 2006
- Offline
- paulfe
- Member
- 13 posts
- Joined: 6月 2018
- Offline
@Konstantin Magnus thank you very much sharing this solution
I look forward trying new drawings using the techniques!
I look forward trying new drawings using the techniques!
protozoanInitially I was doing sketches with openFrameworks or Processing, it's a joy to discover how versatile and efficient Houdini is
Now that's something you don't see often, interesting!
- Konstantin Magnus
- Member
- 670 posts
- Joined: 9月 2013
- Offline
I've updated the file above to get perspective projection instead of orthographic.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
-
- Quick Links