BabaJ

BabaJ

About Me

Expertise
Not Specified
Location
Not Specified
Website

Connect

Recent Forum Posts

Control lighting via VEX per primitive Sept. 22, 2017, 4:51 p.m.

I was wondering if it's possible to control lighting on a per primitive or point basis in a wrangle.

Like for a distant light with wrangle set to run over primitives:

int Horizontal_Domain_Range;
int Horizontal_Domain;
float Fitted_Domain;
float Ramped_Domain;

Horizontal_Domain_Range = nprimitives(geoself())/360;

Horizontal_Domain = @primnum/360;

Fitted_Domain = fit(Horizontal_Domain, 0, Horizontal_Domain_Range, 0, 1);

Ramped_Domain = chramp("ramp_intensity", Fitted_Domain);

@light_intensity = Ramped_Domain;


At the moment I'm using the corresponding shader applied instead and its' opacity to get intended effect and replacing last line of the above with:

@opac = Ramped_Domain;

I tried using the attenuation ramp of the light itself, but it seems to introduce some discernable transition patterns(even though controls were set to b-splines for smooth graduations.)

I swore I was controlling the lighting attributes with vex about a year ago when I was working on some project.

Can't seem to find that file, nor any posts here on the forum.

Maybe I remember wrong and was working with just shading all along.

Is this possible in what I wish to do with lights?

VEX setprimgroup Sept. 22, 2017, 3:04 p.m.

Ok…thanks for the confirmation.

VEX setprimgroup Sept. 22, 2017, 2:41 p.m.

Hi,

Although the docs don't say explicitly that you can set ‘value’ to any specific value other than 0 or 1,

It seems that it might be possible but I am not able to do so.

http://www.sidefx.com/docs/houdini/vex/functions/setprimgroup [www.sidefx.com]

The behaviour seems to be that you can actually give it any value you want, it's just that it will convert that value to 1 ( so long as the value is not 0).

Like it's just a ‘true or false’ inclusion - the function giving you the flexibility of not having to convert your values if they are something other than 1 and not 0.

I am wondering though if it is possible to make those values something other than 0 or 1?

I have a function that loops over large number of primitives and have an algorithm that catagorizes their groupings.

What I have done is some string concatenation with a base name and my loop indexing value converted with itoa to get my specific group names that will scale with the number of primitives and/or variations of the algorithm so I don't have to manually changed my groupings.

It works with no problems - but I thought I might be able to simplify my code with something like(simplified for brevity):

for(Count = 1; Count < Main_Loop; Count++)
{
if( (@primnum >= 0) && (@primnum <= 10) )
{
setprimgroup(geoself(), “Group_Intensity”, @primnum, 1, “set”);
}

if( (@primnum >= 11) && (@primnum <= 20) )
{
setprimgroup(geoself(), “Group_Intensity”, @primnum, 2, “set”);
}

if( (@primnum >= 21) && (@primnum <= 30) )
{
setprimgroup(geoself(), “Group_Intensity”, @primnum, 3, “set”);
}
}