Getting light received on a geometry, as an attribute

   2096   9   1
User Avatar
Member
13 posts
Joined: 6月 2018
Offline
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.
User Avatar
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.
User Avatar
Member
1641 posts
Joined: 3月 2009
Online
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.
Martin Winkler
money man at Alarmstart Germany
User Avatar
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.
User Avatar
Member
13 posts
Joined: 6月 2018
Offline
Thank you for the replies and help!

jsmack
You could do as others have done and write a renderer in SOPs using VEX.
Could you share with me references or other pointers for how to do that.

protozoan
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.
I don't need advanced lighting, this is looking simple and suitable for my application. I will try this technique.

Andy_23
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.
I 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
Edited by paulfe - 2021年12月21日 05:54:08

Attachments:
PXL_20211220_205802812.jpg (3.4 MB)

User Avatar
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

Attachments:
lit_2d_dots.hiplc (201.3 KB)
mesh_2D_triangles.png (361.5 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
1641 posts
Joined: 3月 2009
Online
paulfe
I am experimenting turning 3D objects into vectorial 2D for a plotter machine.

Now that's something you don't see often, interesting!
Martin Winkler
money man at Alarmstart Germany
User Avatar
Member
1748 posts
Joined: 5月 2006
Online
Suepercool stuff from both Konstantin and Paulfe!
Edited by mestela - 2021年12月22日 22:22:43
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
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!
protozoan
Now that's something you don't see often, interesting!
Initially I was doing sketches with openFrameworks or Processing, it's a joy to discover how versatile and efficient Houdini is
User Avatar
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