Welcome to the Poser Forum

Forum Moderators:  Kendra, wheatpenny, Jules53757    Forum Coordinators:  darknewt, gmm2

Poser F.A.Q (Updated: 2019 Jan 31 1:28 pm)

 Subject: surface imperfection material shader

iikuuk opened this issue on Jun 06, 2005 · 21 posts

Top of Forum Print

  iikuuk    ( ) ( posted at 2:40AM Mon, 06 June 2005 · edited on 4:59PM Tue, 07 June 2005

Hi I was about to make it perfect, but now i see i need some help with a shader node. I was trying to do a surface imperfection node, which is somehow shows areas on the object's geometry where its bends(convex) more then 'normal'. The problems i found: - you cannot use du dv nodes (bugreport already sent) in P6 - dPdv and dPdu nodes show only the direction where the geometry tends, but nothing about if it changes. - dNdu and dNdv nodes contain the information we need, but since these dont change inside one vertex, you get only semi results, which should be fed into a further shader (i.e. dNdu and dNdv will be the same in one vertex). I would be interested if anyone can show me a nice way to 'smudge'/blur any result in a P6 shader... (see attached shader node) From the shader: The way it works is pretty easy, it adds the length of the partial differentials of the normal vector, then transfers the values into a 0-1 interval. Last it checks if thats over a predefinied value. Although im a mathematician (kinf of), i didnt look too much for the correct equation, but if you have some advice, im defenitly curious.

  iikuuk    ( ) ( posted at 2:42AM Mon, 06 June 2005  · @2290130

Same shader step->diffuse render

  iikuuk    ( ) ( posted at 2:42AM Mon, 06 June 2005  · @2290131

smoothstep->basic colorramp

  iikuuk    ( ) ( posted at 2:43AM Mon, 06 June 2005  · @2290133

original sh node

  iikuuk    ( ) ( posted at 2:43AM Mon, 06 June 2005  · @2290134

high quality render original node

  iikuuk    ( ) ( posted at 2:45AM Mon, 06 June 2005  · @2290138

'The Corroded Four'.

  Ajax    ( ) ( posted at 4:50AM Mon, 06 June 2005  · @2290222

Niiiiice work! This is excellent. [and you're welcome :-) ] How did you choose the number 50 in the transform step? Was it just a matter of trying different values until you found one that gave the right effect?

View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message

  iikuuk    ( ) ( posted at 4:54AM Mon, 06 June 2005  · @2290225

Well, thats something like 'how far is far' value, but you really have to try the real value, because it depends on the size of the facets, the point of view, and the geometry. For normal human poses and polygons the 50 was a nice value.

  stonemason    ( ) ( posted at 5:33AM Mon, 06 June 2005  · @2290247

very cool! :)

Cg Society Portfolio

  Mec4D    ( ) ( posted at 7:10AM Mon, 06 June 2005  · @2290300

Yes very nice work! top idea

  dlfurman    ( ) ( posted at 10:55AM Mon, 06 June 2005  · @2290496

Whoa! Very nice work!

"Few are agreeable in conversation, because each thinks more of what he intends to say than that of what others are saying, and listens no more when he himself has a chance to speak." - Francois de la Rochefoucauld

Intel Core i7 920, 12GB RAM, 9800GTX 512MB video, 2 x 1TB HDD W00T!
Poser 7 SR3:Inches, PoserPro 2010 SR1:Inches, PoserPro 2012: Inches

  Rothrock    ( ) ( posted at 3:38PM Mon, 06 June 2005  · @2290822

Does anybody know a good tutorial that explains how to "read" a shader like this? I did the real skin shader tutorial and what is going on makes sense to me. (Okay, not perfect sense, but enough!) But I still am not quite seeing how to convert mathematical ideas into this kind of node language. Or how to go the other way to run into something like this and be able to come up with an idea of what it is doing.

  face_off    ( ) ( posted at 4:36PM Mon, 06 June 2005  · @2290876

This is exceptional! I wonder it a similar concept could be done for skin (but in reverse - so the more "imperfect", the higher the red content). I need to check out these new P6 nodes you are using. You are right....these things can't be blurred - one pixel on the render can't get material room info on another pixel (not through nodes anyway). But some ideas....in this case you've got obtuse (is that the right term) angles that you are trying to effect the color of. /If/ they were accute, you could use an AO node to determine if other polys were in the vacinity (use it in conjuction with the diffuse node). Also, have you tried using the gather node. It has a parameter to gather from a specified angle - if you plug in 360degrees it might be a way for you to detect what the nearby polys are doing.

Creator of PoserPhysics
Creator of OctaneRender for Poser

  Ajax    ( ) ( posted at 4:45PM Mon, 06 June 2005  · @2290889

You probably need to know a little about vector calculus for this one, which is something that's rarely learned outside a maths or physics degree. The first thing is that dNdv and dNdu are 3 dimensional vectors representing the amount the normal vector changes as you travel accross the surface of the model in the v and u directions respectively (those are the same u and v you get in a UV map). In order to figure out how strongly curved the surface is at any point, we want to know how long those two vectors are. A 3D vector is usually expressed as a set of 3 values like this: "(x,y,z)" or "(component0, component1, component2)". To find out how long the vector is, we get the square root of the sum of the square of each of the three components: Sqrt(comp0^2 + comp1^2 + comp2^2) That's what iikuuk is doing in those two top right columns of nodes. The component funtions extract those three values, the power functions square each of them, then they are added together. The top two nodes over on the left get the square roots (two, since there are two vectors). At this point we have a measure of the curvature of the surface, but we really want a measure that's always going to be between 0 and 1, rather than a measure that could conceivably be any positive value, so we have to do a little trick to convert our measure to a measure between 0 and 1. What iikuuk does with the next couple of nodes is this: newmeasure=oldmeasure/(oldmeasure+50) This is always smaller than 1 and could be as small as zero but no smaller. The rest is really just about choosing a suitable cutt off point - how big does your measure need to be before you decide to chip the paint off? A few general observations: * This relies on having a good UV mapping. It needs to be a low distortion mapping to work well. * This won't work on models where the vetices have been split to create hard edges. You need a model with continuous, unbroken mesh across those sharp edges. * You can cut down the number of nodes used by adding dNdv and dNdu together (use a color math node rather than a math node) and calculating the magnitude of the result rather than adding the magnitudes of the two separately. It'll give slightly different results but does essentially the same thing and is arguably a more "correct" approach.

View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message

  Rothrock    ( ) ( posted at 7:42PM Mon, 06 June 2005  · @2291042

Ajax thank you for that. I actually do understand vectors and calculus I need little refreshers now and then, but in general I get it. So your walk through is great. I'm guessing I just need more practice to be able to "read" it the way you did. I haven't ever really figured out about UV. When I look at a flattened out UV map, I'm guessing that one of those is equivalent to X and the other to Y, but since each of them will really be wrapped around in space "they" gave them different designations to avoid confusion? Again, I really appreciate the guidance. If you know of any further places where I can get into the math a bit it might really help me understand what is going on.

  odf    ( ) ( posted at 10:10PM Mon, 06 June 2005  · @2291173

This is outstanding. Great idea! Now we need someone to write a Python program for converting formulae into shader networks and vice versa. Oh, or maybe a math shader node which accepts a formula. HINT - HINT - SR2 - HINT - HINT :-)

Have you met Antonia?

I did not jump. I made a tiny step and there conclusions were. (Buffy the Vampire Slayer)

  iikuuk    ( ) ( posted at 2:43AM Tue, 07 June 2005  · @2291403

Thanx and welcome :) I hoped someone with a more decent english knowledge will do some tutorial from the pure nodes i made ;) And yes, Ajax was right about the restrictions of the geometry , but as always there is no general solution for a shader problem like this; since only a geometry built up from fractals would be perfect(which is mostly true for the real world(...)). About the last adviced restriction, im not quite sure if the difference will be just a small amount. I have to look at it more since i didnt think about a shorcut like that, but as far as i feel know it wont be a better result, but will be quicker by far. Since its a bit more comlex than just say something vaguely, ill check and let you know about the result. (And yes that requires more from those nasty vector calculus.)

  obm890    ( ) ( posted at 5:41AM Tue, 07 June 2005  · @2291532

Wow! Very interesting indeed! Thank you iikuuk for posting this, and thank you Ajax for the illuminating commentary. I re-created this network just to see if I could get my head around what it is actually doing (alas, my head doesn't seem to stretch that far). That was before Ajax posted the explanation which helps a great deal. There's something truly exciting about feeling way out of one's depth but at the same time hungry to learn. I felt that way about 3D modelling, then about mapping and rendering, then figure creation, and now about this stuff. And the learning is made so much easier by people like you who share your mastery so generously here on the internet - "the university of the third age". Thank you Ob

  iikuuk    ( ) ( posted at 6:15AM Tue, 07 June 2005  · @2291542

LOL i dont consider myself as a guru :) but thanx. (if it was to Ajax, i agree :) Ok, back from the math papers, if you do add dNdv and dNdu AND do the calculation afterward you will not have the right result. The reason is pretty ease, if you add those vectors, its like you transform one to the other, hence the lenght will be smaller (or equal), then the original |dNdu|+|dNdv|. Furthermore if dNdu and dNdv points absolutely in the opposite direction (and thats not uncommon), the proposed addition will show a small value, which will not reflect the change of the surface. If only you could do a "normals forward" on_that_node, or call an abs function of the vector's axis', would you get 'similar' values, but even then there would be a difference (and would lose its extra speed).

  stewer    ( ) ( posted at 11:10AM Tue, 07 June 2005  · @2291749

"You are right....these things can't be blurred - one pixel on the render can't get material room info on another pixel (not through nodes anyway)." That's a feature (!) of the REYES rendering algorithm (the one that FireFly, PRMan or 3Delight are based on). The benefit is that since no shading point depends on other shading points, they can be calculated in parallel on vector computers or SIMD instruction sets and that the renderer can discard things it already rendered from memory (because it won't need them again).

  Ajax    ( ) ( posted at 4:59PM Tue, 07 June 2005  · @2292181

Thinking it over again, I agree with you iikuuk. It's better to keep the two partial derivatives separate and add their magnitudes afterwards.

View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message

 To create a post you must first sign in or register an account.

Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.