Jump to content

Color At Point


peship

Recommended Posts

ok, imagine we have object with attatched shader(s).

now we want to get the color ( whay not and alpha ) at any point of the object's surface.

what is the right way to do that ?

thanks

19548[/snapback]

hey hey

i' just want to understand ur question a bit better...

is that at render time? or

would u like to use that info in ur scene? ie point sop

all the best

aracid

Link to comment
Share on other sites

Not 100% sure I follow the question. But in a shader you can do a trace call to find the alpha and colour of a surface. Is that what you want? You can't do that in a sop though you'd have to go with the point attributes only, or bake the texture into a map and then read that via a sop using uv.

Link to comment
Share on other sites

ok, imagine we have object with attatched shader(s).

now we want to get the color ( whay not and alpha ) at any point of the object's surface.

what is the right way to do that ?

19548[/snapback]

Shading values on a surface are calculated by shaders at render time, and so for those values to exist in the first place, you must render the scene. But since you don't make it clear in your post whether the color values you're intending to look up are per-vertex or continuous, then I'll assume you mean for them to be continuous across the surface, and so discard the possibility of using the BakeVEX SOP which only works for parametric surfaces and provides you with per-geometric-point shading values only (i.e: not continuous).

If all of the above is true, then one way to accomplish the lookup would be as follows:

1. Render your scene with the shaders whose values you intend to look up later. This produces an image which we'll call "pass1.tif".

2. Assign the final shaders to your objects passing them, as a parameter, the result of step 1: "pass1.tif".

When the final shaders need to look up the value of pass1.tif they use a texture() function indexed by the NDC transformation of the point being shaded (P) like this:

//...//
// Assuming "pass1.tif" exists, then:
vector  Pndc   = toNDC(P);
vector4 Cpass1 = vector4(texture("pass1.tif", Pndc.x, Pndc.y,
                         "filter","point", "mode","black", "border",{0,0,0,0}));

// Cpass1 will now hold the RGBA of pass1 at the current position P
//...//

Both shaders could be combined into one and other solutions very likely exist, but none of these can be suggested unless you make your question a lot more specific (I'm not being pedantic, it's just the simple truth, sorry).

Hope that helps,

Cheers!

Link to comment
Share on other sites

Thanks for the answer Mario. The texture function did the job - all the time i searched for functions with names containing "*uv*" strings :)

Maybe i wanted too mutch ( to read the whole shader stuff ), simple texture is enough.

EDIT:

Being long time Maya user i got used to all those *Info shading nodes.

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