lesbentley opened this issue on Aug 06, 2011 · 29 posts
I am a total dunce when it comes to poser material nodes and shaders, but through trial and error, and help from tutorials, I have managed to come up with a brick shader that I quite like. It's made in P6, based on the Poser 'Brick' node. I'm looking to improve it further by using displacement, or bump, to recess the mortar slightly into the wall. I'm wondering if there is some node based way to generate the displacement from the set up I have already, rather than having to use an image file for the displacement? Like I said, I'm a dunce with shaders, so any instructions need to be idiot proof. Better still, edit the attached file and show me.
Thanks Phil. The problem I am looking at is this, I can scale the shader, putting more or less bricks into a given surface area. If the mortar was nice and straight, I guess I could use a tiled image map and scale it up or down with the bricks, but the mortar is not straight, and it's generated procedurally. I don't know if the pattern tiles, but if it does, I have no idea of the frequency. I was hoping to be able to generate a procedural displacement for the mortar, without the use of an image map.
> Quote - Here is what it looks like in the Material Room. I would not be surprised if it is more complex than it needs to be, but it seems to get close to what I wanted. It's quite simple compared to the ones that can be generated using Matmatic. The real trick is to generate masks to control/seperate effects for the mortar and bricks.
Use a monochrome (black and white) brick node for displacement. If you want that to be driving the color, run that into a blender. If you want a separate brick node for color, then use two brick nodes at identical scale.
> Quote - The real trick is to generate masks to control/seperate effects for the mortar and bricks. Well yes, I guess that is at the heart of my question. How do I grnerate the masks? In a vague way, I suspect that if I can take the output of my current shader, turn it to grey scale, perhaps increase the contrast, and negative the result, I should be able use that as input for the displacement. Only problem is, I don't have the faintest idea how to do any of that.
That looks good. The double-node solution applies to other things, too, such as tile, wood, etc.
Now that I know the answer it seems so obvious, and I could kick my self for not thinking of it, but to tell the truth it might have taken me months, or even years to think of it myself. I was so fixated on the idea that I had to do something to convert the output. Next problem. When I render the "wall" with the camera at an acute angle, I get gaps in the vertical grouting. Any suggestions?
Bagginsbill's Matmatic would be ideal for you! Find links in the "Material Room and Bookmarks" thread stuck at the top of the forum.
"It is good to see ourselves as
others see us. Try as we may, we are never
able to know ourselves fully as we are, especially the evil side of us.
This we can do only if we are not angry with our critics but will take in good
heart whatever they might have to say." - Ghandi
> Quote - Next problem. When I render the "wall" with the camera at an acute angle, I get gaps in the vertical grouting. Any suggestions? This is most problem with tiles and bricks nodes. I always have the same problem. Decreasing min shading rate should helps. If I still have problem with "broken lines" I create texture on cloth plane. Put bricks + shape (turbulence, noise wtc) node to alternate diffuse without any light nodes (clay diffuse specular. Later render it using "From Top" camera. Rendered image can be used as texture. Here you have my bricks procedural pattern.
I'm not sure if folks here want to dig this deep into shader stuff, but there is a large (and rather old, actually) body of work relating to procedural texture antialiasing. Have a look at this article: [ http://graphics.stanford.edu/lab/soft/purgatory/prman/Toolkit/AppNotes/appnote.25.html](http://graphics.stanford.edu/lab/soft/purgatory/prman/Toolkit/AppNotes/appnote.25.html) I have slowly been coming to grips with the use of Du and Dv nodes for reducing procedural artifacts due to high sample spacing. (A high "Min shading rate" or MSR in Poser)
Here is a closeup of a procedural wood floor. I have placed a baton on the floor so you know which spot to look at when I zoom out. Observe the tightly packed stripes. These are going to be a serious problem when zooming out.
Here we go - big trouble. The texture pattern has features that are smaller than a pixel. Thus, coloring an entire pixel based on one local sample of the wood texture creates stripes that simply don't exist.
But by using the Du and Dv nodes to find out how far apart each pixel sample is, I adjust the procedural texture so that the stripes are more blurry when viewed from farther away. The result is that the artifacts are greatly reduced. They're still there, but not at all so obvious.
And now that the shader is helping with the problem, a reduction in MSR is very effective. Here I dropped MSR from 1.0 to .25.
Doing this by hand with nodes is very tedious. But it's quite trivial with matmatic. Here's what I did. I had my wood pattern in a variable called "p" already, expressed as a numerical value from 0 to 1. Farther downstream in the shader I used p to look up colors for the wood grain. How I did that is not important - what matters is that "p" represents any pattern, and that high frequency changes in that pattern cause trouble. The paper talks about a number of approaches, but I took the easiest one. I was going to use Du and Dv to reduce variation in p - to blend it with a constant. How much to blend? Well that is a little tricky. In my case, first I had to convert UV coordinates into distances, so I could understand how much space is being covered by a pixel in real-world units. I already had in my shader a notion of rate of change of position per unit u and unit v, in variables ppu and ppv. So to create my antialias factor, first I need the larger of the dimensions I was dealing with. aad = Max(DU * ppu, DV * ppv) And then I need a function that will drive my blend from full use of p all the way to a constant value. I used this function. I don't know that it has a name. I just know it has some very nice properties. aa = aad / (k + aad) For positive aad, this function always yields something between 0 and 1. The control parameter, k, selects a sensitivity. When aad is the same as k, then aa = .5. So I can adjust where the half-blend point is by choosing a value for k. Experimentally then, using test renders, I determined that the best value of k for my wood shader was .05. So the equation was: aa = aad / (.05 + aad) All that remained was to drive p to some constant, C, according to aa. p = Blend(p, C, aa) Because of the nature of my wood grain ramp, I found the best value for C was .4, so: p = Blend(p, .4, aa) However, when gamma correction is on, that .4 (expressed as a color) is going to get modified, so I wrapped it in a math node so it would not. p = Blend(p, Add(.4), aa) That is all it took to correct the jaggies in my wood grain.
@SamTherapy, That's nice!!!! Thanks! @shuy, Thanks... Now I've got 2 shaders to pick apart. @bb, you realize that people are going to pick at you to produce now a glossy wooden floor??? You really have outdone yourself, even with a quick and dirty wood shader.
OSes: Windows 10 64-bit
Poser: Poser Pro 2014, Pro 11...... Units:inches meters
Bryce: Bryce Pro 7.1.074
Image Editing: Photoshop CS2
Reality: Reality 4.2.1 for Poser and DAZ3D Studio
9/11/2001: Never forget... 11/9/2016: Always REGRETS
Smiles are contagious... Pass it on!
Today is the tomorrow you worried about yesterday