Jump to content

linking shader with cameradistance


Recommended Posts

hi again,

is it possible to link a shader attribute , brightness for example to a parmater wich defines the distance between camera and points with a smooth falloff. Something like z darken in post

controld with shading process?

Both the distance from the camera origin to the shadepoint (== length(P)) and the distance from the viewing plane to the shadepoint, aka "depth" (== Pz) are available to the shader. Then it's a matter of modelling your attenuation based on one of those two (you'd typically pick Pz).

Here's a quick outline:

surface blah (
	  float darken_start = 5;  // units away from cam to start darkening
	  float darken_end   = 10; // units away from cam to full darkness
   )
{
   // distance-based attenuation (many different ways to do this)
   float brightness = 1 - smooth(darken_start,darken_end,Pz);

   // continue shading, then multiply final output by brightness
   vector final_output = 1; //...actual shading goes here

   Cf = final_output * brightness;

}

Cheers.

Link to comment
Share on other sites

thx a lot ... do you have a little more advice for me where i can enter the code and how the a final op network could look like... i m completly new to this

Sure, but the question is still vague, so I'm not sure what to suggest, exactly...

Should I say: "do it in a surface shader!" when maybe you intend the effect to apply to all the objects in the scene, at which point I would either say "just do it as a fog (atmosphere) shader!", or "Nah, real men write Pz to a separate layer and pass the job along to the comp department!".

...and from the other corner: "True ninja users would write a Python script to automagically assign a point attribute matching the name and type of any shader parms you want to control, relative to any camera you want, to every single point in your scene; and all at the touch of a button (conveniently located in a custom shelf) sporting a unique and distinctive shiny icon designed to convey all of what I just said".

pssst.... just do it in comp if you can.

Link to comment
Share on other sites

:lol: ok .... thx mario .... i d like to archive the effect for all my objects in the scene ...

i m not really shure which parameter i d like to tweak. May an option to darken only the highlights with the same falloff in depth would be nice...

currently i got my falloff in z with a colorattribute from a grid in the background... now a solution with camera z movement would be nice...

i ve no diffusion in my scene only highlights....

Link to comment
Share on other sites

so a little more specific...

i wanna darken the areas which are blured by my cameras DOP settings... no post solution i d like to set it up with my shader...

please explain for someone whos new to VEX and VOPs

(becoming a ninja might feel better than getting one :lol: bad english here :()

thx a lot!

Edited by hatrick
Link to comment
Share on other sites

so a little more specific...

i wanna darken the areas which are blured by my cameras DOP settings... no post solution i d like to set it up with my shader...

please explain for someone whos new to VEX and VOPs

(becoming a ninja might feel better than getting one :lol: bad english here :()

OK, then; if depth-of-field is involved, there may be issues in a compositing solution... maybe.

Perhaps you're looking at a fog shader solution...

But just before you jump into that whole thing, better make sure that a comp solution will categorically *not* work in your case, because it really iis the most flexible.

Here's a quick framework to do some of your own testing. A Mantra ROP which is set up to output Pz (depth) as an image layer is used by a RenderCOP (just for demo purposes -- in the real world you'd save to file and load into cops, of course), then this depth layer (I'm labeling it "Depth" in this example) gets used by a VOPCOP to attenuate the original RGB by the values of a ramp.

So... Before you dismiss COPs, have a look at this and see if it's not something that could work in your case.

example_cops.hip

post-148-1240030005_thumb.jpg

Link to comment
Share on other sites

thanks a lot for your explanation...

...currently i use a grid surface in the background parented to my camera which darkens and grades my objects in z direction with a colorattribute... somehow that looks better to me than for example a zdarken ore grade solution in comp (only the flashes in the background are generated with zcomping )....

there are some more questions

1) my problem with the colorattribtransfer is that i can't really get a smooth enough falloff ... is there a way getting softer results?

2) i ve played around with the athmosphere object do you mean this way with fog shading ?

3) currently i ve set up an isosurfacevolume with a smokeshader to get some fog...can i create a densityfalloff in depth with an expression for the isosurface?

4) The ideo to link a shaderattribute with my camera is mainly for learningpurposes :) ... for example: i use the new constant ramp (kind of xray) material for all my objects

Is it possible to link only the bright ore outer colorvalue to my cameraposition ?

5) how can i mix constant value of my falloff material with an diffuse behavour... when i turn on diffuse contribution... the glowish look disapears and is overwriten by an diffuse look

how to set that up within the shader ?

i would be very greatful for some more tips

syn_cos_5.mov

Edited by hatrick
Link to comment
Share on other sites

i know .... a lot of questions ...

No problem. I've just been a little busy lately so it may take me a while to respond.

Attached is an example using an atmosphere shader. This approach has the advantage that it will work well with motion blur and/or depth of field.

Unless you're looking for a lit volume (as opposed to an unlit "darkening" fog) I wouldn't recommend rendering an actual volume. This atmosphere shader does not need any true volume primitives -- it operates on depth-to-surface only.

example_fog.hip

post-148-1240236902_thumb.jpg

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...