So,
I'm trying to find a way on getting detailed diffuse maps look good (not desaturating) in my shader. Currently, my detail diffuse is from my standard diffuse, just a smaller res, greyscale and edited for a weebit better tiling.
In my shader I'm simply adding the detail diffuse to the standard diffuse but I get overly white / desaturated results.
Any ideas?
Replies
Idea #1: Try multiplying your two diffuse maps, instead of adding them.
Idea #2: Try adding your two diffuse maps, and then subtracting .5 from the result.
Idea #3: Try adding your two diffuse maps, and then dividing the result by two.
Idea #4: Experiment with different blend modes in Photoshop. If you find a good one, look up the math on this webpage: http://www.nathanm.com/photoshop-blending-math/
By the way - off topic just a little. Which is more expensive in regards to CPU/GPU computing.. Dividing or Multiplying?
In some cases (ARM9, for example), division is more expensive. In other cases, there's no difference.
Only issue is that my buildings look great but my terrain is WAAAY too bright (yes, they share the same shader).
Continuing debugging ...
I recommend making all your detail textures with an average shade of mid-gray (127 in photoshop). Adjust levels in photoshop to ensure this.
Once that's done, you can balance your shader correctly because you know that your detail texture has an average value of .5
If you add your detail texture, compensate by subtracting .5 from the result.
If you multiply against your detail texture, compensate by doubling the result.
etc.
Turns out the problem is being caused from my baked in AO map... still trying to fit the AO bake into the pipeline (since I've been trying Xnormal and 3Ds max for the AO bake... not sure which one I like better).
DiffuseTexture * DetailTexture * AmbientOcclusion * 2
or
(DiffuseTexture + DetailTexture - .5) * AmbientOcclusion
As long as your detail textures are mostly middle-gray, either of those oughtta work ok.
http://img204.imageshack.us/my.php?image=specularwtf1mn3.jpg
The left side is the back, right side is the front. Last time this happened it was with detail normals and so I decided to just rewrite the shader... detail normals work fine but now speculars jacked up. :P
Any help? (I wish there was a HLSL forum here)
(I don't know how to attach files here so here's a snippet of the pixel shader)
What happens if you leave off the detail normal map, and just use your original normal map? Does the problem go away?
thanks
-Ryan
If so, then the problem must lie in the code by which you combine the two normal maps.
Simply adding two normal maps is not going to achieve quite the effect that you desire, btw. Even though you renormalize them afterward, you'll find details will be reduced... but I don't think thats the cause of this problem.
I think you have to zero out the detail normal map's z channel.. which I assume is the blue channel? You can do it either in shader code or in the texture itself.
iirc when you make materials in UT3 you have to zero out the blue channel on the detail normal maps.
not entirely sure though.
right now you are just adding the two normal maps together and normalizing them I believe and well... I think it will give you undesired results.
sadly I'm not sure at all of what I'm saying.. just something I picked up. but it's an idea at least.
They are using totally separate UV coords, how could this happen?
Kawe, I believe you have to half the blue channel (thanks for reminding me to do so), since the blue channel only goes 0 - 1. So adding two blue channels could screw things up!
Thanks!
This line screws things up (commented out so my scene still looks good ), like Ryan was hinting at.
*thinks of the solution* ... I know you can't really 'mix' shaders although there is 'stacking' but that's still on in the same shader (right?).
The funny thing is, detail diffuse works fine, no issues there. Why would normals be different?
btw, I added this too
That still didn't help.
So if you have 0.5 of the detail normal map's blue channel you would have to take 0.5 for the normal.. normal map's blue channel. In UE3 they vary it.. sometimes they zero it out and sometimes they take 0.3.. and so on.. but they adjust the other normal map's blue channel accordingly so it always adds up as 1.
I think you should give it a shot
If it doesn't work try posting your normal maps too. Hard to determine what is going wrong from the renders only.
I'll post normals soon.
A quote I just googled up from blender's homepage.
So if your implementation only uses 128-255 then normalizing something that is off the scale would most likely push values below 128 and get you into the minus range.
If it uses the full blue range then I suppose there shouldn't be any problems?
Not entirely sure though...
And not even sure if it has anything to do with your streaking issues. Heh.
Thanks for you help man! I really appreciate it.
I'll look into it more. From what I understand, it's 'standard' to half the blue channel in normal maps when using more than one.
If anyone else has any insight to this weird 'streaking' problem, feel free to let me know!
The way I do it is to basically the method of combining normal maps in photoshop (halve the blue channel on one, set to overlay);
There might be a cheaper way to do it out there, and this only works for tangent normal maps.
First create an overlay function outside of the pixel shader: This is the overlay formula from shaderFX; I believe this to be the way photoshop's overlay modifier works as well.
You use it to combine the individual channels of your sampled base normal map and detail map before expanding, transform into worldspace, or normalizing either of the maps. This shouldn't weaken or distort the existing normals.
Heres a pic of it at work with a maya cgfx node:
http://img12.imageshack.us/img12/1266/normalk.jpg
If there is a method of combining objectspace normal maps in photoshop, you could probably modify this to overlay them after the tangent maps have been transformed into worldspace.