Jump to content

export occlusion per light


MENOZ

Recommended Posts

hi.

I'm trying to modify a shader so that I can export a ambient occlusion pass.

the problem was that if I have a geometry with alpha textures mapped on it, I can't simply substitute with a constant shader and use a environment light for the occlusion pass, because I would loose my opacity.

so I thought to export a parameter that mantain the opacity from the texture map, with a constant color. Precisely what I though was to use an illuminance loop so that i could use the light color to color my object. this was meant to use with the environment light only, so it would be a good occlusion pass.

it.. works, but I cannot find a way to use only the environment light in that pass. In the illuminance loop there is a "light exports" parameter that is not documented. I tried with light mask input, and with light mask in the mantra output extra image planes, but it doesn't seem to work..

if something isn't clear ask please..

Link to comment
Share on other sites

Are you trying to export ambient occlusion or an environment light pass?

What doesn't work when you do the light mask?

i'm trying to export the environment light pass.

this is the color pass with a point light and environment ilght post-1766-130925190628_thumb.jpg

if I set the light mask in the mantra node it create a new channel in the exr file but it's screwed.post-1766-130925192417_thumb.jpg

If I use only one env light (just to have only env color) and don't use light mask the render is ok.post-1766-130925193037_thumb.jpg

I'm not a master of illuminance loop, for now i only can add multiple lights influences just to make the loop works, but still i don't know how to cast shadows. for now this shouldn't be a problem because i only need one environment light that computes occlusion.

Link to comment
Share on other sites

i'm trying to export the environment light pass.

this is the color pass with a point light and environment ilght post-1766-130925190628_thumb.jpg

if I set the light mask in the mantra node it create a new channel in the exr file but it's screwed.post-1766-130925192417_thumb.jpg

If I use only one env light (just to have only env color) and don't use light mask the render is ok.post-1766-130925193037_thumb.jpg

I'm not a master of illuminance loop, for now i only can add multiple lights influences just to make the loop works, but still i don't know how to cast shadows. for now this shouldn't be a problem because i only need one environment light that computes occlusion.

ok for the shadow there is a "shadow" node that needs to be plugged in the light color inside the illuminanceloop.

I think I have to export my lights in some way, but I don't understand how should I do that in VOP. I see the help talks about "lightexport keyword argument", that it's the same that i find in the illuminance loop VOP node. how should i use it? maybe this is the reason why i get screwed render with light export on in the mantra node.

I suppose that directlighting node from wich i can export others default passes has embedded inside the lightexport function in some way, but i'm not shure of how this works.

Link to comment
Share on other sites

Normally when I need an occlusion pass I just do the occlusion in the shader the I won't use a light ... attached a scene to show you what I mean.

I'm not really understanding what you want to do with the illuminance loop, is it just so that you can get the light colour from the env light?

I would just ditch the light and do it in shader, and link all of the colour and intensity setting on the shader to a null....

maybe somebody else can shed some light (heh) onto this.

shaderOcc.hipnc

Link to comment
Share on other sites

I think if you put a Parameter node inside the illuminance loop, then add that to your mantra node and tick "export per light" it might work?

That screwed up result looks like an undefined variable thing ...

edit:

So.. you can do 2 illuminance loops - one for direct lights and one for the env lights.

From memory, if you want to export per light, you need to make your own illuminance loop and export the variable in there. Since you have to make an illuminance loop, you might as well just make two and forget about the per light export.

Edited by sam.h
Link to comment
Share on other sites

Normally when I need an occlusion pass I just do the occlusion in the shader the I won't use a light ... attached a scene to show you what I mean.

I'm not really understanding what you want to do with the illuminance loop, is it just so that you can get the light colour from the env light?

I would just ditch the light and do it in shader, and link all of the colour and intensity setting on the shader to a null....

maybe somebody else can shed some light (heh) onto this.

my scenario is:

i have many delayed load objects, each with a different shader with different textures with alphas. I can't replace everything with a constant ambOcclusion shader, because i would loose all my alphas informations. So i thought to use a digital asset material for all my objects that takes into account the opacity from the texture map, and export in a separate plane the occlusion pass.

Now, if i embed a occlusion calculation into each shader, I can't modify it when I delay_load my objects.

If i would have a different scenario where i only have many materials and many objects, not delayed loaded, I should link all the materials parameters related to my occlusion parameters, to some spare parameters into a null node. it this that you mean by "link all of the colour and intensity setting on the shader to a null" ?

if I use an environment light i can use it to modify my amb occlusion shading when I use delayed load. this is what i thought... I don't know if it's the correct way.

can you explain me what parameter should I put inside the illuminance loop? what should it be its imput? what its name? should I connect a string parameter or constant to the input of my illuminance loop? :\

Link to comment
Share on other sites

oh using light mask in that way works.

but I can't change the name of the mask once the object is delay_loaded. so the name of the environment lgiht should be "hadcorded".

I think exporting light is the way to go.. but I can't make it works.

Link to comment
Share on other sites

oh using light mask in that way works.

but I can't change the name of the mask once the object is delay_loaded. so the name of the environment lgiht should be "hadcorded".

I think exporting light is the way to go.. but I can't make it works.

almost there...

I put the parameter that export the color inside the illuminance loop. before it was outside. now the light export in mantra node works. I have environmente and point light exports in image planes that comes out of my illuminance loop.

BUT, the environment light pass takes the illumination contribution of the point light also. with his shadow. If I use the light mask at vop level and not in mantra light export it works correctly. why this?

Link to comment
Share on other sites

here is a test scene.

I think there is something wrong.

if you launch the render you will see that the light passes aren't correct.

ok, solved.

the parameter to export was after the add operator that add the lights loops together. now it works.

so it seems that if I use the light mask at the shader level it effectively masks out the lights in the illuminance loop.

If I set the light mask in the mantra light export the loop is computed for all the lights, so my constant variable where I put the sum of oll the lights is not resetted after each loop, and it export the light passes meanwhile the loop is proceeding.

does it works like that?

anybody knows how to use the light export parameter in the illuminance loop? i didn't used it in the end..

thank you!!

Link to comment
Share on other sites

Hi,

For a long time I have been under the belief that you cannot export the occlusion generated from an environment light.As exporting only works when the occlusion is calculated via a surface shader.If things have changed with this I would be interested in seeing a working example.

Rob

Link to comment
Share on other sites

Hi there,

I've only stuck my node in this thread now and I'm sorry to TL;DR it, but I assume you cannot use PBR, right?

Why I ask is that the per-light export of the direct_ and indirect_shadow export variables will give you occlusion per light.

anybody knows how to use the light export parameter in the illuminance loop? i didn't used it in the end..

Yes, I've done in a couple of years ago. I'll dig up old functions.

I assume you've read about this "lightexport" variadic parameter in the meantime -- which is very important, especially if you have several illum loops in a shader: http://www.sidefx.com/docs/houdini11.0/vex/functions/illuminance

Here is an example from our library. Note how we assign Ks at the end of the illum loop:

vector luz_Specular(vector Nf, V;float Roughness; vector specular_surface_color, Ks)
{
	vector clr = 0;
	vector Cf = 0;
	//Ks = 0;
	illuminance(P, Nf, "lightexport", "Ks")
	{
		//shadow(Cl);
		vector ll = normalize(L);
		clr = specular_surface_color * Cl * specularBRDF(ll, Nf, V, Roughness);
		Cf += clr;
		Ks = clr;
	}
	return Cf;
}

Link to comment
Share on other sites

:lol:

jason what do ou mean with "..I'm sorry to TL;DR it..", expand it please ^^

well, my goal for now was to find a method using the standard rendering modes. pbr works a bit differently and I would need to wrap my head around it again to see for example how it uses the illuminance loop.. for example from what I remember you have to disable the "higlight" because it's related to the material itself, it's calculated automatically taking into account the energy conservation, and things like that.

I saw that you could export various variables but some of them I guess are only for pbr, and i didn't investigated.

i tried the direct diffuse, but it seems to be the color multiplied by the color of light. So the direc shadow for env_light give me a black and white occlusion pass? and it takes into account all the shaders transparency and stuff like that i gues..

the help says that pbr is useful when you have to do soft shadows using the sun light, or environment light. why? it's faster? is it still raytracing no?

I read the lightexport, but it's in VEX. I don't understand how to use it in VOP..

rob, i'll try to post a quick example of what is my solution not using pbr.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...