So I'm trying to make it so that the Specular Texture would control the color of reflection as well as the intensity of reflections like in Marmoset.
I have my material tree set up like this so far:
But it's not really where I want it at - does anyone have some tips on changes?
Thanks!
Replies
Intuitively, it doesn't quite make sense to me - appreciate an explanation to help me understand.
This is true ^
Also if you're trying to integrate reflections into the specular path then maybe it might be better to do it by using the custom input and recreating the phong specular and combining it with the reflection.
Now, for the other half, I would hope for the SpecularPower (grey-scale Gloss map in the alpha channel of the Spec map as an alpha for a Lerp between 1-100) to also control the sharpness of the reflection and I have no clue on where to start on this as most of the math operations seem to only be able to affect its brightness.
I'm not really sure what you are asking. If you are asking how do you make your environment map work with your gloss map, the answer is that there is no good answer. Epic failed big time in that regard. If they wanted to make amends they would add support for cubemaps as inputs to custom nodes and they would add a DDS file importer (with support for cubemaps of course) that preserves mip chains. Then you could store various levels of gloss in the different mip levels and use your gloss value as an input to tex2Dlod.
I would also recommend you not use UDK's default lighting. It's crap.
That is a solution I hadn't thought of yet and it sounds like it'd work reasonably well. I'll get to testing it soon.
Default lighting do you mean the default settings for the lights? Or the "Morning/Afternoon/Night" Preset levels?
I mean the built in Phong shading. Here is a custom lighting shader and an example of how to use it.
http://dl.dropbox.com/u/48657892/CustomLighting.upk
A quick rundown on the parameters.
Roughness: This is the equivalent of "glossiness", but unlike Phong, bigger number = more rough. The range of this is parameter is technically (0, +inf), but most common materials are going to be in the rage of (0, 1].
Diffuse: This is the diffuse albedo, pretty self explanatory. Be careful to use realistic values. Very few materials have an diffuse albedo > 0.6ish.
Specular: This is the specular albedo, equivalent to the amount of light that gets reflected at normal incidence. This value can be calculated based off of the material's index of refraction. Example:
Glass IOR = ~1.54
Specular albedo = ((1.54 - 1) / (1.54 + 1))^2 = ~0.0452
You may find some more insights by reading this blog: http://seblagarde.wordpress.com/2011/08/17/feeding-a-physical-based-lighting-mode/
Is the package you linked to also a PBR shader like in the blog?
Seems similar effect.
Instead of the flat colors, looks like the CustomLighting shader will translate sRGB textures as well?
Indeed, it's a variation of Cook-Torrance and Oren-Nayar. UDK actually works with linear RGB values. By default, texture samples get converted from sRGB -> Linear RGB. So, for example, if you wanted to make something copper you could use the values from the blog (0.955008, 0.637427, 0.538163) in a constant node. However, if you wanted to put this in a specular texture, you would first adjust the values from linear -> gamma, the from the range [0, 1] -> [0, 255] like so:
(0.955008, 0.637427, 0.538163) ^ (1/2.2) * 255 = (250, 208, 192)
I tried it, and all I get is black, (other than the surfaces that are being hit by direct sun) any idea how to work around it or what I'm doing wrong?
Do you have to use a env cubemap to get the ambient light from?
Try also plugging your diffuse into the CustomLightingDiffuse slot.
I'm also having some issues with the material in DX11 mode - lots of artifacting on the corners.
If I do as MooseCommander suggests and plug the diffuse into the CustomLightingDiffuse aswell as the Diffuse slot in the customlightning, only the areas hit by the DominantDirectionLight make use of the custom shading.
Maybe I'm forgetting something but if it only works on the surfaces hit by the DominantDirectionalLight I don't know how to use it. =(
CustomLighting is where you put in your lighting (like Lambert, Oren Nayar, etc) term, it essentially the equivalent of LightPerPass function of your average shader. This part will ALWAYS show whatever you put into it, from the light position, as long that is what you want (and should be).
CustomLightingDiffuse is your Ambient/Diffuse slot, where you put in only your Diffuse and/or with Ambient Map. This one won't interact specifically with the light source, UNLESS you write a specific term for it.
The difference is one will react to light, other won't, the other is like the ambient/core color of the mesh. If you want it even more simplified, one is ontop of the other and replaces/merges with the other when it sees light.
Put two different colors in each slot and you will see what I mean, best way to understand what they do.
Emissive is...what the name says literally, your emissive/glow slot. If you put a cube map in here, it's going to 'glow' the cube on your mesh as a fully lit source map, hence why you plug your cube and/or with ambient in here if you wish to take 1:1 value of your map without relying on the light source.
The second confusion here is that cube and ambient maps are supposed to be the replacement of your Specular and lighting quality term, and you guys are using generic maps in environments that won't work with them properly.
Both of them can be used and mixed, but you need to make sure both of the terms being used aid each other, and don't fight each other.
Think of it this way, if you character is in a cave, you cube and ambient map NEED to reflect the environment you're in, putting on the map of a skyline on the beach inside a cave doesn't make sense, and parts of mesh that are supposed to shadowed for physical correctness (like the bottom, and part facing inside the case) will glow and be blue, instead of dark brown or such.
Ambient especially is important to be correct here.
If you can't be bothered to create the proper maps, then you will be limited to used a Specular term, simple as that, the reason Specular terms aren't put into the emissive is because they will glow all over the mesh, even in the dark parts, and UDK doesn't take Light Vector into the Emissive slot.
Lastly, make sure you take a moment to read the UDK wiki, CustomLightDiffuse is explained that it's also shadowed, so meaning it will show itself when being shadowed FROM the light source. You can push back the amount of shadow under the options in the material, called Shadow Bias iirc? Use small numbers however.
But yeah, cubemaps (in emissive) are used for faking indirect lighting. And if your cubemap doesn't match the environment, it's not the shader's fault.