YOUR ACCOUNT

Login or Register to post new topics or replies
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
I've been at this for hours now and can't get this filter to work like I need it to. I got the perfect look going for this damage layer filter but when I took a closer look I realized that the size slider was not at fullsize- when I slid it back everything went to heck. I need the slider to be at fullsize because I'm going to be using gradients in this. I know there's probably some fancy proportional gradient thing that might work but I don't want a band-aid fix like that. I'm going to be doing a bunch of renders with this so I need this to be run as quickly as possible. Is anyone willing to take a look and see if they can get the lead preset look while the size is maxed out? I think the issue is the noise I've got- something has gone wierd because it's size is maxed out as well...

Anyhow, sorry for the blunt request- I totally know that nobody owes me anything, I'm just frustrated is all.

smile:(

helpmeplease.ffxml
  Details E-Mail
Carl
c r v a

Posts: 7289
Filters: 82
Kg try this quick fix , you'll have to fine tune but with a bit of a fiddle you should get similar [ does need adjusting ] you can change thickness of plaster roughness and texture of b/g to be lighter and rougher etc smile:)

helpmeplease2.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
This might also do it.

I ripped out everything but the components that were actually in use, so you may wanna copy/paste this into your original filter if you want to keep the rest (If this works for you).

helpmeplease3.ffxml
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
You guys really really rock.

Carl- I love the way you did that filter, I'm probably going to go with ThreeDee's one because it's a bit closer to the original. I'm tweaking it right now and am pretty pleased with the results. I'll post some examples (maybe the final filter) later to explain what I'm doing smile:D
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34



Allright guys- huge thank you for getting this far. I got a real nice result that does exactly what I was hoping. (See top image)

So I did stumble into another problem and to save from spamming the forum with my "difficulties" I'll just post it here. I suppose I can keep this topic going for my random questions smile;)

Now the real tricky part begins: I assembled a normal map in very much the way I used to do it manually in photoshop- see the large screenshot for an idea of what I did. The problem I've now run into is that while that image works fine as just a plain normal map (rendered from a simple filter) it isn't actually a "height map" which I can input into the height part. Does anyone know of a way to convert a normal map into a height map so I can blend it properly and reconvert into a normal map? I know, seriously obscure but I thought I'd ask.



  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Fullsize image link: http://img183.imageshack.us/img183/91...mapso0.png

(Sorry for the quadruple post)

Basically what I'm trying to do is mix this: http://www.ultimateuploader.com/files/7228ji.jpg (the output from my damage filter)

with this: http://www.ultimateuploader.com/files/9656jijijiji.jpg (the output of that manually created normal map to generate something like this:


(I used "crazy bump" to blend the above files. It works totally fine but I would really like to do this all within filterforge.)

That last image is like 100% gold. It's exactly what I'm looking for.
  Details E-Mail
Lady Fayre
Lady Fayre

Posts: 100
Filters: 33
Very nice filter KGtheway2B smile:) I really like the colours
"Its a far better thing"

~*~Lady Fayre~*~
  Details E-Mail
Carl
c r v a

Posts: 7289
Filters: 82
Quote
KGtheway2B wrote:
Carl- I love the way you did that filter, I'm probably going to go with ThreeDee's one

I'd do the same TD's is much closer smile:)
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
KGtheway2B wrote:
Does anyone know of a way to convert a normal map into a height map so I can blend it properly and reconvert into a normal map?


I haven't had any use for normal maps so I don't know exactly how they are constructed and whether the can be reverse engineered back to a bump map or not. But just for the heck of it, you could try running your normal map through high pass at the settings Contrast: 50 and Radius: 10 and use that as a "bump" map. It ain't gonna be accurate but perhaps it will give you something to work with.
  Details E-Mail
Kraellin
Kraellin

Posts: 12749
Filters: 99
if i remember correctly, you simply desaturate a normal to make it a bump, though the two are normally used differently and therefore not a straight conversion type thing that applies really well. normals are more for lighting where bumps are more for height/depth.
If wishes were horses... there'd be a whole lot of horse crap to clean up!

Craig
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Yeah, it's an interesting issue. I think the problem is that I've actually created an "impossible" surface with that combination of normal channels. It works fine in-game (actually looks quite nice) but I don't think I will be able to get filterforge to do a normal map with that specific output. What I'll try to do next is take my existing height map and convert it to a "normal map" manually (I'm hoping this filter: http://www.filterforge.com/filters/1477.html will do what I need) then I'll find out a way to combine the two (you're not supposed to "blend" normals) and have it spit out the normal map through the diffuse output. Wonky as heck but if it does the job I'm happy.

In the meantime (before I'm able to go home and try the aforementioned filter), can anyone attest to the accuracy of that filter, and if it is lacking- propose any other possible solutions?

Thanks again everyone, it's awesome to have the support from you guys.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Well, I don't know the exact mathematics of the normal map, so I can't say, but it has at least one problem, which is how the gradient seam gets offset into the image.

I made some experiments along this line earlier and made this filter that I thought was creating a normal map, but that is just reverse engineering from how one looks, not through any actual math. It uses refraction instead of offset which seemed more correct, IMO. It also has a shrink/enlarge routine that seeks to avoid the seam problem. And I gave it a few more controls for other purposes.

So, I can't swear on the accuracy of either, but there's another possibility.

normal map.ffxml
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
UPDATE: I tried the aforementioned normal map filter (by Richard Bartlett) and it didn't work that well. smile:cry:

However ThreeDee came to the rescue with his awesome attempt! It's amazing you just "eyeballed" this...

ThreeDee, apologies for the late response I was away this weekend and didn't have a chance to give your filter a spin. I had a chance to try it out tonight and I'm VERY impressed!! Here's what I found-

When I compared the plain renders there were a few issues- the first and most glaring issue was the lack of a proper blue channel. Other than that the Blue and Red channels need to be inverted (although toggle switches would be ideal for this to match other render programs)



I did a few adjustments in photoshop, flipped your RED and GREEN channels, did some slight contrast adjustments (I don't think the contrast is necessary, it probably makes things less accurate) and added the proper BLUE channel and was amazed at how close your filter got to the original.



I looked around a little bit at your guts but I've gotta sleep now. I think you should do those last few tweaks (good luck on the blue channel) and release that filter, even if it's a normal map approximation it's a damn good one and I'm sure could come in handy for others. And again, thank you so much for your help!

NOTE: Forum is shrinking those images, open them in a new window if you want fullsize.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Oh good, that seems to work fine.

Do you know what the heck that blue channel is supposed to represent? I get what the read and green ones are, in that they give you the x and y directions of the surface normals, but I don't quite get what the blue is supposed to do. The logical answer would of course be the z component of the surface normal. If that is it, I could probably do something that resembled it. I guess I could read about it somewhere if I really wanted...
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Blue is some sort of z depth. I've never seen it go beyond 50% gray. And I'll agree, it seems a little strange to me, but yeah that's what it does.

If you're curious about normals:

http://www.bencloward.com/resources_tutorials.shtml

(I've gotta refresh myself actually, it's been a while)
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
I really hate to be naggy like this but have you had a chance to try that blue channel ThreeDee? You had such a solid start with the first two I think you ought to wrap it up, release a snippet, and crown yourself normal map king. smile:pimp:
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
KGtheway2B,

Back when you posted a response to Richard Bartlett's "Normal Map Channels are Offset Maps", I posted a reply with a normal map assembler close to FF's (Here). Have you checked that out? (attached it here again)

You can easily plug in the height input in the empty blue channel and get the Z normal into the map too. If you do that, you can also ditch the final "deassembling" step too (it really just resets the blue channel to 100% blue).

Normal map Assembler.ffxml
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Hey Sphinx! I'm so sorry I totally missed your earlier response. I'm experimenting with it right now and it's looking really promising thanks!
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
KGtheway2B,

I have been doing other things for a bit, but just came back here to see what was going on. Thanks for the references. I also found a good, brief explanation of exactly what the RGB channels in a normal map are, which made it totally clear, as part of this tutorial:
http://planetpixelemporium.com/tutori...ormal.html

While I currently have no use for normal maps, I might just do it for fun.

TD
  Details E-Mail
rgoer
Posts: 46
A few things to keep in mind with normal maps:

The r and g channels of normal maps are usually stored "packed" into 0..1 space (the X and Y components of a normal vector are in -1..1 space). The b channel is not packed, it is in 0..1 space to begin with. To go from (color) texture.rgb to (vector) normal.xyz, the conversion is: normal.xy = color.rg*2-1; normal.z = color.b. For each pixel value in a normal map, the (unpacked) r, g, and b channels form a single [R G B] vector, whose length is exactly 1.0.

FF offset maps work similarly to "packed" normal maps. Offset maps are in 0..1 space, but get "unpacked" behind the scenes. A value of 0 in an offset map is treated like -1, and 0.5 is treated like 0. I'm sure everybody already knows this stuff, but I figured I would put it out there in case it does somebody some good.
  Details E-Mail
rgoer
Posts: 46
btw, if you have the red and green channels "perfect", here is how you would get a valid blue channel:

1. x^2 + y^2 + z^2 = 1
2. z = sqrt(1 - x^2 + y^2)
3. x = r*2-1
4. y = g*2-1
5. z = sqrt(1 - (r*2-1)^2 + (g*2-1)^2)
6. b = z*0.5+0.5 (you can take b = z since z is always positive, but you lose precision)

Of course, to implement this in FF, we would need support for unclamped values (both negative values and values greater than 1) AND the ability to do a proper square root... smile;)
  Details E-Mail
rgoer
Posts: 46
If unclamped math worked, this filter would give a correct blue channel I think.

You can check the (not-quite-accurate) results by toggling between render maps "diffuse map" and "normal map"

Normal Map mtook a stab at blue channeld.ffxml
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
That's gnarly rgoer.

So tell me if I'm interpreting this properly:

Are you doing ALL of b = sqrt(1-(r*2-1)^2 + (g*2-1)^2) *.5 + .5 ?

Linear burn acts as a multiplier.

Multiply with 100% adds. (and multiplying with 50% gray is analogous to adding .5?)

From linear dodge onward I'm lost.

smile:?:

Take a look- I uploaded some example pics and my modified version of the filter. Just thought I'd mention it- but the lower level example is what I'm actually in need of so if you know where to add the slider for "height" that acts the same as the surface height one in filterforge definitely keep that in mind.

http://www.filedropper.com/stuff_6
  Details E-Mail
rgoer
Posts: 46
Take a look at http://dunnbypaul.net/blends/ it is a great site which explains Photoshop-style blend math (which I assume FF is using).

Let's take the "Extract RGB" red channel as a starting point (we'll call it "r"). From that point:

1. We have a "linear burn" (100% opacity) blend node with r as both foreground and background. The blend math page tells us that "linear burn" is (base + blend - 1), which in FF is (foreground + background - 1). If foreground and background are both r, (foreground + background) = 2*r. Which means that (foreground + background - 1) = 2*r-1. Let's call the output of this linear burn blend node "2*r-1".

2. The next node is a "multiply" blend (100% opacity), with 2*r-1 as both foreground and background. Multiply blend returns (foreground * background), which means we are getting (2*r-1)*(2*r-1), which is (2*r-1)^2. Let's call the output of this multiply blend node "(2*r-1)^2".

3. We do the same stuff for the "Extract RGB" green channel... so let's call the output of the other multiply blend node "(2*g-1)^2".

4. The next thing we have is a "linear dodge" blend with "(2*r-1)^2" as the foreground and "(2*g-1)^2" as the background. The blend math page tells us that "linear dodge" is (base + blend), which is just (foreground + background). So let's call the output of the linear dodge blend node "(2*r-1)^2 + (2*g-1)^2".

5. Next we have an invert node, which just returns (1 - input). So let's call the output of the invert node "1 - (2*r-1)^2 + (2*g-1)^2".

6. The gamma node, set to 30.10 (taken from byRo's post in the "Gamma" thread), returns something which I hope is the square root of its input. I did some basic validation by multiplying the output of the gamma node against itself, and it looked visually identical to what we're inputting to the gamma node (I don't think it is quite precise enough to be mathematically identical). So let's cross our fingers and call the output of the gamma node "sqrt(1 - (2*r-1)^2 + (2*g-1)^2".

7. At this point we have z as derived above.

8. To get from z to b, we need to get z*0.5+0.5.

9. The multiply blend with 50% gray as the foreground performs z*0.5, so we'll call the output of that node "z*0.5".

10. As above, linear dodge is just (foreground + background), so again 50% gray as the foreground adds 0.5 to the input. We'll call the output of this node "z*0.5+0.5", and at this point we have what *could* be a valid blue channel for an RGB normal map texture, if my logic and math is all correct smile;)
  Details E-Mail
rgoer
Posts: 46
Oops, I was just going back through the filter and I realized I accidentally had a 50% opacity setting on one of the linear dodge blend nodes. Updated filter attached.

Normal Map ftook a stab at blue channelw.ffxml
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
OK, gave it another shot (with the math above in mind) - preset 1 is the output of our normal construction, preset 2 is the FF generated normal map. Try rendering the FF map (preset 2) save it as EXR and open it again before opening the filter graph - there are some seemingly unused branches that lets you compare the FF map and the map generated by the filter. It might be possible to tweak it even closer to the FF normal map, though this one is quite close already smile:)

Normal Map - with Blue channel.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Geez, I go and do something else for a couple of weeks and you get way ahead of me!

I would imagine you can get an accurate square root with curves. It is easy enough to make a parabolic curve and square root would be the inverse operation thereof.

Matter of fact, it looks like the default gamma curve might even be the curve that gives you the square root in the range of 0-1.

Any math genius that can verify this?

Does the attached filter give you the square root in the range of 0-1?

Square root x0-1i.ffxml
  Details E-Mail
rgoer
Posts: 46
Sphinx, can you explain the use of curves in your filter and how they relate to the math from earlier? That is one part of FF I don't understand. I have something cool (as far as normal maps go) in the works, but I need a way to actually subtract one sample from another...
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Just thought I'd post some results- it's close enough that I'm ready to use it without any qualms

Here's the simulated blue channel from sphinx's latest:

  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Here's the actual blue channel (subtle differences, almost looks inverted inside the gray area smile:?: )

  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Simulated Red channel

  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Actual Red normal channel

  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
Those last two are almost exact, I think if I tinkered with the "surface height" I could get an exact match.

Speaking of which- where should the the "surface height" slider go in the simulated version?
  Details E-Mail
rgoer
Posts: 46
surface height controls the opacity of a lerp (regular blend) between your calculated normal map and RGB [127.5,127.5,255], such that zero surface height returns just RGB [127.5,127.5,255]
  Details E-Mail
KGtheway2B
KGtheway2B

Posts: 660
Filters: 34
that's absurdly easy thanks smile:D

I really didn't expect it to be that simple.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
rgoer wrote:
Sphinx, can you explain the use of curves in your filter and how they relate to the math from earlier? That is one part of FF I don't understand.


The two first linear curves are simply used to get into the curve "space" (blue connectors). While it may not seem intuitive, the spatial information is actually passed on during the curve operations (i.e. its not simple functions, f(x), its more like f(x,y,v)). The last Tone Curve + Assemble RGB is how we get back into the normal sample flow (green connectors) - the actual color of the Assemble RGB is irrelevant as we are getting a constant result no matter what we plug in (its really just a work around because of the required source input in the tone curve)

I can't give you an exact explanation of what I did - with FF your solutions are often a mix of theoretical ideas and intuitive experimentation smile:D However, telling from your math, we're dealing with some sort of modified euclidean distance function, so this was my starting point - now how does this "look"? Like a radial gradient with black center. A radial gradient can be faked by doing something like x * (1 - x) + y * (1 - y) with some additional adjustments. Its not perfect but its very fast smile;) The rest of the curve math and settings were simply made by experimenting and comparing with the real normal map.

Quote
rgoer wrote:
I need a way to actually subtract one sample from another...


In curve "space" you can use the Math component for that.
  Details E-Mail
rgoer
Posts: 46
ugh I guess without proper unclamped math this stuff just won't work... I was working on calculating a normal via a 9-sample Sobel approach directly in the filter (using Sphinx's awesome 1-pixel offset snippet), but it broke down by the end.

After that I was trying just a 3-sample cross-product approach, but again the value clamping was breaking the result. Alas...
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
rgoer wrote:
but again the value clamping was breaking the result


The secret is to scale down and offset temporary to get around the clamping, so instead of working in full [0..1] range, you work in a much smaller range, say [0.45..0.55]. It should not have significant impact on precision. I do that in the blue channel calculations too. The easiest way to make this transformation is to remap via a linear curve where you set its minimum and maximum props. To get back to the ordinary range you then use the start and stop props instead. Follow?


  Details E-Mail
rgoer
Posts: 46
ahhhh that makes a lot of sense now

this is the first time I have tried doing filter work in "curve space" but yeah, I guess you don't really lose precision when you scale/bias curves like you do when you scale/bias pixel samples smile:)
  Details E-Mail
rgoer
Posts: 46
edit: nevermind, I was being stupid smile:)

edit again: OK Sphinx, now I'm back to being confused. I thought I was in good shape remapping amplitudes to a compressed space... but now I think I'm screwed again.

Let's say we have 3 curves, A, B, and C, and their values are all very close to one another (less than ~0.1% difference between them, but different and unique nonetheless). If I leave them in [0..1] space, then (A - B)+(2*C) is going to be something like ~0.1% away from 2*A (or 2*B or 2*C). If I compress them to [0.45..0.55] space before I do any math, (A - B)+(2*C) is still going to be very close to 2*A (or 2*B or 2*C)... and I'm still going to end up going negative (or greater than 1) eventually as the math continues. Sorry for being somewhat dense here, but am I missing something stupid?
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
rgoer wrote:
Sorry for being somewhat dense here, but am I missing something stupid?


Nono.. working in compressed space (good term you nailed for that btw!) will certainly not solve all issues (and will possibly introduce new problems too, hehe) - sometimes you have to work with 0.5 as the new zero to get a decent margin for your intermediate subtraction ops, and sometimes this will only complicate matters. What I meant to show you is that you can work around clamping limitations by offset and/or scale the values. Its in no way a wonder fix that lets you continue without troubles.

Under all circumstances you have to end up with a meaningful range [0..1] for the ongoing processing (i.e. the rest of the graph), there is no way around that. The compression/offset trick will only help you with intermediate calculations.

I need more details on what you're working on to help further..
  Details E-Mail
rgoer
Posts: 46
I have to go out of town for a couple of days, but when I'll post what I have so far when I get back on Saturday. Hopefully it is a solvable problem smile:)
  Details E-Mail
rgoer
Posts: 46
ok, haha, I managed to get a Sobel normal calculation working, sort of, and it only takes 2 whole minutes to render! haha

if anybody wants to take a look at the filter, it is attached--there is a good chance that something isn't (or many things aren't) being done the best way as far as filter optimization goes, it's kind of a brute-force deal...

I think I even skipped doing the normalization because it was so slow, haha

Normal Map Filter.ffxml
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,533 Posts
+38 new in 30 days!

15,348 Topics
+73 new in year!

Create an Account

Online Users Last minute:

24 unregistered users.

Recent Forum Posts: