Viewing Angle Logic?

Is there any way to get an object to become invisible (or flat out not rendered at all) or not depending on the angle from which the currently rendering camera is viewing that object from? Rendering trickey, scripting, anything? I know I could just turn visibility for that object on or off manually as needed, but I'm really hoping for some automation to make life easier for me.

If there isn't a way to do viewing angle stuff like that, is there a way to have certain things get hidden/obscurred by a wall that is otherwise invisible to the camera and anything else that isn't specifically intended to get hidden by that invisible wall? I could use invisible walls like that to fake having a script that hides things based on viewing angle, but obviously only if that's possible.

«1

Comments

  • Richard HaseltineRichard Haseltine Posts: 102,244

    Are you wanting this to vary depending on the angle with which the vir strikes the surface, so parts that were flatter on would remain visible (which is probably doable via Sahder Mixer in Iray; it's certainly doable in 3Delight) or are you wanting the whole object to be hidden regardless of the incident angle on its surface?

  • edited April 2021

    If I understand you right, I want the first situation you said. I drew a picture now to try to explain.

    Suppose I have 2 flat sprites, intended to represent the sides of a statue (its a very simple statue), arranged in a cross such that their centers are in the same place but one sprite is turned 90 degrees from the other. I want one or the other to be visible, depending on which one is being viewed "flatter on" (that's a good descriptor. I'm gonna remember/borrow/steal that one).

    pictureexplaination.png
    906 x 686 - 7K
    Post edited by ZaeZodTheToonCrafter on
  • Richard HaseltineRichard Haseltine Posts: 102,244

    Well, I think it could be done in Iray but it would be a bit sledgehammer to crack a nut. It might be simpler to write a script to work out the camera angle to the nodes and hide the one at the sharper angle, though you'd then have to runit each time (so not so useful if this is for an animation).

  • I was actually hoping to eventually do animations. Not immediately, but I'm a slow learner sometimes so it'd be best for me to use the method that's compatible with future projects though I'm not animating yet. And I'm no stranger to overkilling a problem. Sledgehammering a nut is fine.

    So, Iray can do it?  Any specific guidance on how?

  • ebergerlyebergerly Posts: 3,255

    Hmmm....I'm not quite sure exactly what you're asking, but here are some thoughts...

    It kinda sounds like you're asking for what's called in some 3D apps "backface culling". You basically tell the renderer, for every face/polygon on every object, which side of the polygon is "front" and which is "back". Then if the camera is looking at the back side of the polygon the renderer treats it as invisible, but if it's looking at the front it's visible. But that pretty much fixes the angle of view at 90 degrees, and you can't really adjust it. And I don't think Iray has that feature.

    But there is an Iray feature called "section planes", which is basically an infinite plane you can move and rotate, and it slices the objects in your scene so that everything on the camera side of the plane is invisible and everything on the far side is visible. I'm wondering if you could parent one or more of those to the camera, thereby defining a viewing angle where stuff is invisible? Again, not really sure what you're trying to accomplish, but that might be a start. 

    The challenge, from your description, is that objects are often comprised of many faces, and you'd somehow have to define that angle or angles of each of those faces that make the face visible or invisible? Makes my head explode trying to figure that one out... laugh

  • edited April 2021

    Well, so far, I'd only be hiding 2D things. So only 2 faces there. The 2D things will be parented to 3D things eventually, but at no point will I be trying to turn the 3D things invisible.

    Section planes is a neat feature I'm glad you told me about and will likely be very useful later, but it looks like it can't do parenting trickery to hide only certain things. (I might be wrong though. Still trying.)

    I did more researching, and found that what is being done in this link here https://blender.stackexchange.com/questions/77171/possible-to-hide-mesh-texture-at-a-perpendicular-viewing-angle is pretty much what I'm trying to do, except I'd like to do it in Daz instead of Blender.

    Post edited by ZaeZodTheToonCrafter on
  • Okay, I did even more research. I still don't know if what I want to do can be done with just Daz Studio, but some reading I've done suggests that I might be able to do it if I also use the Octane Render add-on/plug-in thing for Daz too. Maybe. I'm still reading. The documentation I've found so far is...not as good as the documentation for other things I've used in the past.

    If I understand everything correctly so far, what I'd need to be able to do is to replicate the node setup I got from the Blender StackExchange in the Octane Render node system. Or at least make something similar to it. Which I guess would require there to be equivalent nodes in Octane Render for each of the nodes in the Blender example?

  • Okay, so, I'm stumped. For today, at least. I just found out Octane isn't the only node based render thing that Daz can use (forgive me, I'm new...to actually using Daz. Had an account for forever though.). But I can't figure out if any of the renderers that Daz can use can replicate the node setup I found that worked in Blender. I should mention that I genuinely don't mind what renderer I end up using for this part of the project, just as long as it can make 2D things disappear based on what angle its being viewed from. I'll get back to researching and watching this thread tomorrow, but for tonight I must sleep.

  • ebergerlyebergerly Posts: 3,255

    I'd like to help, and I'm very familiar with Blender and have written many scripts, but honestly I can't figure out exactly what you're trying to accomplish. Like I said, every face has two sides, front and back, and each side faces at opposing angles. So if the front of a polygon is facing at say 45 degrees relative to the camera view angle, the back face is at 135 degrees relative to the camera angle. So if you're going to say "well I want all faces that are greater than 45 degrees to the camera angle to be invisible", do you mean front faces or back faces? 

    The image below shows a bunch of polygons/faces, and the front and back faces are different colors. So the question comes down to "which of those faces do you want invisible and which do you want visible?".

     

    Angle.JPG
    1145 x 646 - 48K
  • Sorry about the long gap between posts, I became unexpectedly busy for a bit. The idea right now is to replicate what the blender example I found did, except in Daz. That means the scene has 3 plane primitives centered around the same point and at angles to each other. Then I try to make a material that turns the a plane invisible when I get close to viewing that plane on edge from either side. Really, I'm mostly experimenting. There could be some interesting uses for this effect if I can figure it out, but everytime I try to explain one of those uses it ends up sounding silly or useless. Not that they actually are, just that I'm really bad at explaining these sorts of things.

    From the looks of the Blender Example and what little I know about Daz, I'm guessing for this experiment I should create a plane type primitive and use the shader mixer to try to create a replica of the blender node setup. I suppose if Daz doesn't have the nodes I need by default, I might be able to find them on the market?

  • edited April 2021

    Wow, there's a lot of node/brick types in the shader mixer! But no search function? surprise I've managed to find the equivalent Daz Brick for a few Blender nodes, but I still need to find the Daz Equivalent of the following Blender nodes: Diffuse BSDF, Transparent BSDF, Vector Transform (including the settings in the node as seen in the picture in the Blender example), Camera Data, Camera Data, and Texture Coordinate. Anybody know which those would be?

    Post edited by ZaeZodTheToonCrafter on
  • Making progress. Slowly. A little bit worried about that transparent bsdf (is that more a case of using an if/then/else brick to set the opacity of the surface output brick to (255, 255, 255) or (0,0,0) depending on the output of a "greater than" brick that checks the angle between the two vectors?). Found the equivalent of Blender's Vector Tranfsorm (Daz's Transform Vector...probably). Haven't found a way to reference the camera vector (might need to make a custom brick for that? I really hope not, it seems so fundamental) or the...other vector coordinate space things yet. Found two different Diffuse BSDF bricks (no idea which is the direct equivalent of Blender's Diffuse BSDF).

    Encouragingly, I also found this thread (https://www.daz3d.com/forums/discussion/15484/) which might offer clues. Maybe. Unfortunately, as best as I can tell, what I need is buried in obfuscating variable names that I have no idea how to find the meanings of. Things like "N" or "P" or "E" and so on that go in the settings of "Variable [Fixed]" bricks. What are those and/or how do I find a lookup table/list of them?

  • edited April 2021

    Getting there. I really hope this can be done. I think all I'm lacking is how to get the Camera vector. I tried using "Face Forward" and "Calculate Normal" but that didn't seem to work. (Is there really no documentation on those two?) I suspect what I'm looking for is buried in "Variable [Fixed]" but without a list of what each variable it can access is, I'm basically stuck.

    gettingthere.PNG
    1223 x 818 - 100K
    Post edited by ZaeZodTheToonCrafter on
  • Almost there! Figured out the variable names were Renderman's Reserved Symbols (probably? Maybe? Stilll not 100% sure). Which led me to discover Renderman's pxrFacingRatio (https://renderman.pixar.com/resources/RenderMan_20/PxrFacingRatio.html), which is exactly what I need to put before the absolute node/brick/thing. Except I can't find that in Daz Studio's unsearchable list of bricks/nodes/whatever. Where do I look for it?

  • ebergerlyebergerly Posts: 3,255

    I'm still unclear on what you're trying to accomplish. Are you trying to do this in Iray/MDL or with 3Delight/RSL? It looks like your node/brick graph is mixing RSL and MDL nodes. And you're referencing DAZ Studio discussions from the pre-Iray days (I think) when they were referring to 3Delight/RSL. 

    If you're trying to do this in Iray I suggest you look into the MDL capabilities. You can search for the NVIDIA Material Definition Language Handbook. Also there's a discussion from last year where someone interested in doing some possibly (?) similar stuff in D|S was discussing with some devs on the NVIDIA Developers Forum, and the response was "In MDL you dont have access to the camera position or space directly. you would need to make the camera position and orientation a parameter of your material and feed it in manually, then compute a transformation."

    Here's the link to the discussion: https://forums.developer.nvidia.com/t/calculating-normals-in-perspective-space/156379

     

  • I'm just trying to recreate the example I found for Blender in Daz. And I guess I'm making it with 3Delight/RSL. I wasn't really trying to pick one or the other before. Thanks for telling me that it would be really hard to do camera stuff with Iray/MDL. I redid my nodes as best I could to remove any MDL nodes, but it looks like the "Greater Than" node works in both MDL and RSL. The only node I need now is RSL's PxrFacingRatio (https://renderman.pixar.com/resources/RenderMan_20/PxrFacingRatio.html). If I connect that node to the X Input of the "Greater Than" node then this material should work perfectly. But I can't seem to find it. It should be possible to add it though, right?

    just1nodeshort.PNG
    1105 x 677 - 54K
  • ebergerlyebergerly Posts: 3,255

    Are you sure you want to do this in 3Delight/RSL? If you haven't already, you may want to try a render in 3Delight and see if that changes your mind. laugh

    Also, if you're happy with the Blender/Cycles node graph solution, have you considered just moving your scene (or parts of it) to Blender and rendering there? Or maybe just the elements you want to do your viewing angle renders on, and composite them with the D|S renders? Blender's compositor is really amazingly good, and works great with D|S render canvases. 

  • Sven DullahSven Dullah Posts: 7,621
    edited April 2021

    Are you sure you want to do this in 3Delight/RSL? If you haven't already, you may want to try a render in 3Delight and see if that changes your mind. laugh

    Was that really necessary?

     

    Post edited by Sven Dullah on
  • Sven DullahSven Dullah Posts: 7,621
    edited April 2021

    zaezod5_f1afeef8ca said:

    I'm just trying to recreate the example I found for Blender in Daz. And I guess I'm making it with 3Delight/RSL. I wasn't really trying to pick one or the other before. Thanks for telling me that it would be really hard to do camera stuff with Iray/MDL. I redid my nodes as best I could to remove any MDL nodes, but it looks like the "Greater Than" node works in both MDL and RSL. The only node I need now is RSL's PxrFacingRatio (https://renderman.pixar.com/resources/RenderMan_20/PxrFacingRatio.html). If I connect that node to the X Input of the "Greater Than" node then this material should work perfectly. But I can't seem to find it. It should be possible to add it though, right?

    Hi! I'm  pretty sure you won't find that RSL brick in SM. Did you look into Shader Builder? Not sure, but if you find it there it may be possible to import it to SM. Or you might have to make a custom brick, possibly. You could try asking for advice in the 3DL Laboratory thread if you still need that brick.

    Post edited by Sven Dullah on
  • Richard HaseltineRichard Haseltine Posts: 102,244

    For 3delight in the past I have used a dot product Maths brick to combine the eye vector and the surface normal - the greater the magnitude the closer they are to parallel/antiparallel, which (since it's the normal, sticking up at right-angles to the surface) would mean it was facing towards or away from the viewer. Doing it quickly in my head I think you'd want the magnitude to be greater than 1/square root of 2, but check that carefully.

  • ebergerlyebergerly Posts: 3,255

    Richard Haseltine said:

    For 3delight in the past I have used a dot product Maths brick to combine the eye vector and the surface normal - the greater the magnitude the closer they are to parallel/antiparallel, which (since it's the normal, sticking up at right-angles to the surface) would mean it was facing towards or away from the viewer. Doing it quickly in my head I think you'd want the magnitude to be greater than 1/square root of 2, but check that carefully.

    I get the dot matrix of the two vectors as an indication of 0 to 90 degrees, and that's pretty straightforward for a single plane/polygon. But how does that work for, say, a curved mesh with many faces/polygons? Does RSL somehow take like an average of the normals of all the faces that have that material applied, and compare that to the camera vector?  

  • Doesn't look like PxrFacingRatio is in Shader Builder the either. I'll ask the 3Delight Labs thread about getting/making/begging for a PxrFacingRatio brick. Meanwhile, I did actually also think about trying to use Eye Vector-based calculations earlier, but I couldn't find any explicit statements on what brick to use for that. Is it "Variable [Fixed] (type I)"? That one gives me a P type output though, not a V type output. (I have no idea what P stands for. Maybe Point? And I'm guessing V is for Vector?) Is there a list somewhere of each Variable? I found this (https://renderman.pixar.com/resources/RenderMan_20/risAOVs.html), but it doesn't seem to list what I'm looking for. Or does it? I'm still learning.

  • Richard HaseltineRichard Haseltine Posts: 102,244

    ebergerly said:

    Richard Haseltine said:

    For 3delight in the past I have used a dot product Maths brick to combine the eye vector and the surface normal - the greater the magnitude the closer they are to parallel/antiparallel, which (since it's the normal, sticking up at right-angles to the surface) would mean it was facing towards or away from the viewer. Doing it quickly in my head I think you'd want the magnitude to be greater than 1/square root of 2, but check that carefully.

    I get the dot matrix of the two vectors as an indication of 0 to 90 degrees, and that's pretty straightforward for a single plane/polygon. But how does that work for, say, a curved mesh with many faces/polygons? Does RSL somehow take like an average of the normals of all the faces that have that material applied, and compare that to the camera vector?  

    The normal is local, each point oin a curved surface would have a different surface normal (and a variety of geoemtry normals). But in the case under discussion the geometry is a set of planes, so each will have a single, uniform, normal.

  • Richard HaseltineRichard Haseltine Posts: 102,244

    zaezod5_f1afeef8ca said:

    Doesn't look like PxrFacingRatio is in Shader Builder the either. I'll ask the 3Delight Labs thread about getting/making/begging for a PxrFacingRatio brick. Meanwhile, I did actually also think about trying to use Eye Vector-based calculations earlier, but I couldn't find any explicit statements on what brick to use for that. Is it "Variable [Fixed] (type I)"? That one gives me a P type output though, not a V type output. (I have no idea what P stands for. Maybe Point? And I'm guessing V is for Vector?) Is there a list somewhere of each Variable? I found this (https://renderman.pixar.com/resources/RenderMan_20/risAOVs.html), but it doesn't seem to list what I'm looking for. Or does it? I'm still learning.

    Yes, it givs a P for point - but you can treat it as a vector (normalise it for safety). Ng will give the geometry normal, E as I recall is the eye vector.

  • My Vector Mathematics must be rusty or something. What's wrong with the attached node network thing? When I use it, the primitive plane I'm testing is always completely transparent.

    justmakeseverythingdisappear.PNG
    1618 x 642 - 97K
  • Richard HaseltineRichard Haseltine Posts: 102,244

    zaezod5_f1afeef8ca said:

    My Vector Mathematics must be rusty or something. What's wrong with the attached node network thing? When I use it, the primitive plane I'm testing is always completely transparent.

    I don't know, but mine was pretty much the same and also gave a constant result.

  • Richard HaseltineRichard Haseltine Posts: 102,244
    edited April 2021

    My fault - I can't recall what E is, but the one I should have pointed you to for the eye vector is I. Edit: E is the camera location, so a literal point rather than a vector.

    Post edited by Richard Haseltine on
  • I maybe have something that works (node network attached), but I need to learn how to make an animation (with a camera that moves) to be sure.

    thismightbeworkingbuticanttestit.PNG
    1652 x 685 - 101K
  • ebergerlyebergerly Posts: 3,255

    Thanks for the "I" info. I was searching trying to find the camera "pointing" type vector, since E is just the camera position. 

    Also I wasn't sure what the "Toon" brick was so I just replaced it with a color variable (red) and that seems to work fine. Also I don't think the two Value bricks providing black and white to the If-Else are needed are they? I just set black and white colors internally in the If-Else. 

    So yeah, that brick graph seems to work fine. 

  • That's great to hear, but while I can get still images that show the material in action, I can't seem to get an animation to also have the effect. Does an animation of this material work properly for you? If not, I suspect a gotcha (a funny programmiing technicality) to be at fault here. Perhaps "I" does not update during animations? Or could it just be the fact that I only learned how to do animations (badly) in the last 15 minutes?

Sign In or Register to comment.