Forum: Poser


 Subject: Help with Brick Shader

lesbentley opened this issue on Aug 06, 2011 · 29 posts


  lesbentley ( posted at 1:33PM Sat, 06 August 2011 


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.

  lesbentley ( posted at 1:42PM Sat, 06 August 2011 


Here is what the shader renders like at the moment. I trying for the impression of a dark and rough, cheap quality brick.

  lesbentley ( posted at 1:54PM Sat, 06 August 2011 


(click image for larger view) 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.

  PhilC ( posted at 1:56PM Sat, 06 August 2011 

See if this will help.

  lesbentley ( posted at 2:35PM Sat, 06 August 2011 

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.

  nruddock ( posted at 3:38PM Sat, 06 August 2011 

Attached Link: http://www.runtimedna.com/forum/showthread.php?23612-Matmatic-Bricks&p=240354

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

  bagginsbill ( posted at 4:41PM Sat, 06 August 2011 

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.  


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  lesbentley ( posted at 4:51PM Sat, 06 August 2011 

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

  lesbentley ( posted at 4:59PM Sat, 06 August 2011 

Cross posted with BB. I think bagginsbill has come up with a solution I can use. Thanks BB.

  lesbentley ( posted at 6:25PM Sat, 06 August 2011 


(click image for larger view) Thanks again bagginsbill. I think this is a huge improvement.

  bagginsbill ( posted at 6:48PM Sat, 06 August 2011 

That looks good. The double-node solution applies to other things, too, such as tile, wood, etc.


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  lesbentley ( posted at 7:53PM Sat, 06 August 2011 


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?

  Acadia ( posted at 8:12PM Sat, 06 August 2011 

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


  lesbentley ( posted at 8:21PM Sat, 06 August 2011 

To answer my own question, lowering the min shading rate to 0.2 seems to do the trick.

  Mark@poser ( posted at 10:20PM Sat, 06 August 2011 

Cold you post an image of your final shader?   Thanks

  lesbentley ( posted at 2:28AM Sun, 07 August 2011 

> Quote - Cold you post an image of your final shader? I will post the mt5. I'm still trying to iron out a few bugs, but will post it in a day or two, bugs or not.

  shuy ( posted at 8:37AM Sun, 07 August 2011 


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

  shuy ( posted at 8:39AM Sun, 07 August 2011 


and here you have shader

  SamTherapy ( posted at 6:45AM Mon, 08 August 2011 · edited on 6:45AM Mon, 08 August 2011

I made myself some brick shaders a while back, which you're all welcome to share.  I'll post 'em to this thread in a bit.

Coppula eam se non posit acceptera jocularum.

My Store

My Gallery

  bagginsbill ( posted at 11:19AM Mon, 08 August 2011 

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)


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  bagginsbill ( posted at 11:19AM Mon, 08 August 2011 · edited on 11:20AM Mon, 08 August 2011


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.


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  bagginsbill ( posted at 11:21AM Mon, 08 August 2011 


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.


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  bagginsbill ( posted at 11:22AM Mon, 08 August 2011 


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.


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  bagginsbill ( posted at 11:28AM Mon, 08 August 2011 · edited on 11:28AM Mon, 08 August 2011


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.


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  bagginsbill ( posted at 11:35AM Mon, 08 August 2011 


Zoom in a little and all the detail pops into place.


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  bagginsbill ( posted at 11:46AM Mon, 08 August 2011 

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.


Renderosity forum reply notifications have been wonky in the past. I'm testing the waters to see if it's working now. If you ask me something and I don't come back, it probably isn't. (Updated January 17, 2017)

  SamTherapy ( posted at 7:21PM Mon, 08 August 2011 


Here's my brick shader.  Change the extension from txt to mt5 to use.

Coppula eam se non posit acceptera jocularum.

My Store

My Gallery

  SamTherapy ( posted at 7:22PM Mon, 08 August 2011 


And here's a quick render to show it in context.  It's mapped to the one sided square here.

Coppula eam se non posit acceptera jocularum.

My Store

My Gallery

  ThunderStone ( posted at 6:56PM Tue, 09 August 2011 

@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
Renderer: LuxRender

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

 

  SamTherapy ( posted at 7:27AM Wed, 10 August 2011 

You're welcome, ThunderStone.  Have fun. :)

Coppula eam se non posit acceptera jocularum.

My Store

My Gallery