Vex lighting without using a single light

   2375   3   0
User Avatar
Member
1007 posts
Joined: 4月 2017
Offline
Hi!

here's my latest Houdini achievement! This is a viewport screenshot using absolutely NO LIGHTS!

I created vectors from each point on the geo connecting to each points at the top left corner of the image. I check what hits and doesn't hit anything (black or white) and make an average(gives soft shadows). I also check if the surface is facing or perpendicular to the light source to change the brightness. I used the inversed square law (at least I think I did) to affect light decay. The SSS was achieved by simply using the blur sop with different values on the R, G and B components.

Attachments:
area_light_intersect_01.jpg (466.0 KB)
area_light_intersect_02.jpg (283.9 KB)
area_light_intersect_03.jpg (1022.3 KB)
area_light_intersect_04.jpg (204.8 KB)

User Avatar
Member
1007 posts
Joined: 4月 2017
Offline
Here's the vex code. Input 0 is the geometry (rubber toy and squab!) and input 1 are the light points. I scattered the light points on a grid to simulate an area light.

int lightCount = npoints(1);
float lightmult = pow(chf("exposure"), 3);
vector rayN, hitpos, lightpos;
int hitprim;
float u, v;
float lightmap = 0;
float rayOffset = chf("ray_offset");
vector geoPtpos = @P + (@N * rayOffset);

float angleToLight;
float lightDist = 0;
for(int i=0; i<lightCount; i++)
    {
    lightpos = point(1, "P", i);
    rayN = lightpos - @P;
    hitprim = intersect(0, geoPtpos, rayN, hitpos, u, v);
    if(hitprim == -1)
        {
        lightDist = distance(@P, lightpos);
        angleToLight = degrees(acos(dot(@N, normalize(rayN))));
        angleToLight = fit(angleToLight, 0, 90, 1, 0);
        lightmap += ((1 / sqrt(lightDist)) ) * angleToLight;
        }
    }

@Cd = lightmap / float(lightCount);
User Avatar
Member
474 posts
Joined: 7月 2005
Offline
Hi,

nice , but it looks like “lightmult” is missing at the end.
User Avatar
Member
1007 posts
Joined: 4月 2017
Offline
Thanks!

Ah! It should actually not be in that wrangle. At first I wanted to control the intensity of the light in that wrangle but everytime I changed the exposure, it recalculated everything! Instead, I move that line in the wrangle right after. Now I can change the intensity in real time.

-Olivier
  • Quick Links