Thank you sir. If my game ever gets completed it will be largely due to the excellent help and advice I always receive here. Hopefully one day I’ll be able to return the favour.
Edit: Having read up on this it would appear that the mask completely removes the glass. Although this isnt a problem when aiming, I was hoping to achieve a glass finish so that it would reflect light realistically when not in ‘aim-mode’. I can’t remember how games like Battlefield deal with this… am I being over ambitious, or can it be done without too much of a performance hit?
If you want to have tinted glass, change the Blend mode to translucent and give the mask a shade of gray instead of full black.
If you then leave the diffuse mask black where the glass part is, you can multiply the gray glass mask with a constant color and add it to the diffuse.
This way you have flexible control of the glass tint.
Or you bake the glass color into the diffuse. Less flexibility, but you save some shader instructions…
PS: If you want different blend modes for each (translucent for reticle and opaque for the gun), you need indeed split it into two material IDs.
Bear in mind that this will incurr an additional drawcall…
I don’t think that’s a great idea, because if the same material is mapped on the entire weapon, the entire weapon will be rendered in the transparency pass.
Instead, create two materials, one for the opaque bit, and one for the non-opaque bit (glass.)
While you could still use a single texture map for opacity and one for transparency with the glass being a small slice of the UV space of the gun, that would be very wasteful for the transparency map, as it’s not needed for all of the opaque parts.
Instead, I would use a separate UV map and separate texture for the glass part. This also lets you add a distortion/refraction map for the glass, if you don’t want it to be perfectly flat.
Separately, you will have to do some fixing-up of the material once imported into the engine; there’s no getting around that. But if you break the two parts into two separate materials, with separate texture maps, that’ll make the fixing-up easier.