i have seen this being used where the alpha channel of the diffuse is being used for the specular map.
Is this really as simple as making your diffuse black and white, doing a color range select then copying that into the alpha channel?? or is there another way to do this?
Replies
For example, you could dedicate your R to be your spec, G to be your emissive stuff, and B to indicate where you want to have a detail normal or not...etc.
It also depends on your surfaces and whether or not a pure black and white will give you a decent spec result. In some surfaces it could, but on some you might need color. (Skin, copper, bronze, etc.)
So say you have a 1mb texture.
Compressed this is 256kb
Compressed with alpha this is 512kb
Now say you have 1mb textures(diffuse and color spec)
Compressed your diffuse will be 256kb
Compressed your specular will be 256kb
Total texture usage = 512kb
And yeah, as Ott says, having seperate images gives you more flexability, some types of materials need less resolution for the spec, or less for the diffuse. If both are packed together it makes it harder to optimize.
You should always make a proper texture rather than just copying the diffuse map, regardless of whether it's going to be greyscale in the alpha channel or full colour on its own.
Correct, but it is also an extra texture sampler in the pixel shader.
The issue of where to store what is completely driven by your needs- first come up with what you want the result to be, then figure out how to do it (including what maps are needed), then and only then figure out the best way to store textures. Not saying anyone is arguing against this, just worth pointing out. There are definite pros and cons of all these approaches and they are both equally valid (I don't usually say that about stuff), your needs will determine which to use.
These are pretty technical things... to be safe, just use whatever is easiest for you (usually storing everything seperately) and focus on making the prettiest things, since you won't get much out of the nitty gritty aspects of this performance.
I'm not 100% sure on how the compression works, but I believe it's something along the lines of sliding any pure black in the R,G,B to slightly grey (ie. 1% brightness) then multiplying the alpha into the R,G,B channels and treating anything in the resulting image that's pure black as one value while every other luminosity is treated as the other value which gives you your 1-bit image.
In this case, you can have a 256kb texture WITH 1-bit alpha, and just saved 256kb. Again though, it's pretty useless for spec maps unless you can think of a situation where you want something fully specular and something completely unspecular on the same texture sheet.
It seem more likely a 1 bit alpha on an 8 bit-per-channel image would still be 8 bits, but you're only using a tiny part of it? Kind of like having a 8 gallon gas tank with only 1 gallon in it? The only bonus I can think of in treating it that way would be compression... But then if you have 8 bits per pixel why not use them? I doubt the compression savings would be worth handicapping your artists.
As for the 1 bit it would probably have to be in a separate 1bit texture, I could see that being most useful on transparencies that would be run through alpha-test, where each pixel is either on or off but then its a separate texture as Rob pointed out.
I could be way off, this is just what I remember about images and bits...
As mentioned already, it depends on the Tech. For instance, in the Source engine, it's possible to use the alpha channel of the diffuse map for transparency, and the alpha channel of the normal map for specular.
The DXT1 format allows for an optional alpha which is 1bit. This is smaller in memory than having a DXT5 texture.
I use the 3 channels thing all the time. It's much more important to save memory than to worry about the extra texture sample in my experience. I usually colour the specular using expressions inside the shader. Of course this isn't suited to some sitations or objects.
I read up on how it works and from what I read, it looses 4 colors from the pallet if you add an alpha, 3 of them are just wasted, 1 is used for trans.
I'm also not sure but I think it drops the 8bits down to 4bits per channel, ouch.
Sounds like it works, but would only be used in very specific monochromatic cases, and the alpha would be used for alpha test transparency only?
Hanging wires, plants, a poster and maybe garbage.
It reads more like a rare case exception for really low end hardware, not really something I would want to use on characters, well maybe hair transparencies... maybe...
http://tech-artists.org/wiki/DirectDraw_Surface
http://tech-artists.org/wiki/Normal_map_compression
Both incorrect. It's in 4x4 blocks (16 pixels). DXT only stores two colors per block and interpolates the others, using 2 intermediate colors for DXT1, and either 4 or 6 (can't recall) for DXT2/3/4/5.
Edit... made a quick edit of the page. Super busy, working the weekend in fact, but hope to add more later.
This is very poor general advice, and varies wildly on the material type and content of the textures(some textures can be resized easier without noticing a quality loss). After doing a texture optimization pass on basically every texture in a game, i can tell you that sometimes you will want to resize the diffuse, sometimes the spec, and sometimes the normal. A good example of a case where you would want to resize the diffuse before the spec is pretty much any type of metal texture, like a gun, where the diffuse is pretty simple and the specular really has most of the detail.
This is good advice.
For some materials I will delete the diffuse texture altogether and just have spec+normal - especially if you have a very dark diffuse map.
also i am doing the modeling in Maya. Will the color map with the spec in the alpha even work? or do i have to do some crazy shit in Hypershade??
thanks for the help!!
Paint the grayscale spec map, get it looking right, then just create an alpha channel for the diffuse and paste the spec map in.
It's a shader thing, so I wouldn't expect any standard 3d package shaders to support it. We use the alpha in the diffuse in different ways, mostly for alpha but sometimes as a mask for a skin shader.
In this case you would copy your diffuse to the spec slot, and Under Mono Channel Output, switch it from "RGB Intensity" to "Alpha".
breakneck: since you were asking about maya, yes it's possible to do in maya as well, drag in your texture and shift-right-click drag on your shader, connect the out-alpha to the spec. I can never remember, you may have to do the out-transparency to the spec, or perhaps connect the out alpha to each channel of the spec (R,G,B). Try it both ways if it won't let you connect the out alpha directly to the spec and see what works.
That's also a pretty stupid requirement for an art test. They're making you spend time learning how to do technical stuff that is likely covered in their pipeline normally. It serves no purpose really, they should be more concerned with whether your spec map looks right than how you stored it.
Yes if you wanted a cgfx shader to do this, you would have to write one with that behavior.
Vj