I'm currently making my first Unity game for my Game Design class and thus learning the ropes with JavaScript, the engine and now ShaderLab.
I'm trying to get multiple textures on one material to be layered on top of each other, some with different blending modes. I found some GLSL and HLSL documentation (included as an attachment) on this, but I'm not sure how I can implement it in my Shader. I've set up the Base Color and Texture slots, as well as a Hue slider. My two main questions are as follows:

1) How can I set a Texture's blending mode to Overlay/ Add? I understand the SetTexture and Combine principle, but I don't know how to apply it for these specific Blending Modes.

2) How can I control a Texture's Hue/ Tint?

Also, am I correct in assuming these values can be changed real-time by means of a GUI or an in-game event using the getComponent() function?

I'm currently making my first Unity game for my Game Design class and thus learning the ropes with JavaScript, the engine and now ShaderLab.
I'm trying to get multiple textures on one material to be layered on top of each other, some with different blending modes. I found some GLSL and HLSL documentation (included as an attachment) on this, but I'm not sure how I can implement it in my Shader. I've set up the Base Color and Texture slots, as well as a Hue slider. My two main questions are as follows:

1) How can I set a Texture's blending mode to Overlay/ Add? I understand the SetTexture and Combine principle, but I don't know how to apply it for these specific Blending Modes.

2) How can I control a Texture's Hue/ Tint?

Also, am I correct in assuming these values can be changed real-time by means of a GUI or an in-game event using the getComponent() function?

Thanks in advance,
Patrick

Click to expand...

Most photoshop blending styles cannot be expressed on the GPU itself. The three most common hardware supported blending styles are 'blend' ('normal' in photoshop), 'additive' (linear dodge/add) and 'multiply' (multiply). You will find several shaders in the particle section of the built-in shaders that implement these. Other popular blending styles, like photoshop's screen, simply cannot be expressed on the GPU. You will have to try and avoid using such effects when designing for GPU rendered games.

Affecting a texture's hue or tint can be done in hardware (by writing custom shaders), although hue will require quite an extensive shader (GPU's only support RGB, so the shader will need to implement the RGB to HSL conversion). For the Battlebot game we made, the customizer does the hue conversion of the textures in script, rather than the shader. I believe there are scripts on the Unify wiki for HSL/RGB conversion to help you with that, but it will be some programming work.

Edit: After checking your attachment, which contains photoshop implementations for blend effects, I feel I need to clarify: you can use any photoshop blending type for colors within a single shader on a single object. However, as far as I know, you just cannot use them between different objects, as you cannot use shader programs to control the blending with the framebuffer. Sadly, using these effects between different objects is by far the most useful application.

I'm so sorry, I can't believe I never noticed these answers! I'll be sure to give it all a try, thank you both so much!! =D
@Tom: Blending multiple textures on a single object is all I need luckily! =)

Anywho, I just did a quick test on two of the shaders and they both worked just fine. Where are yuu experiencing trouble? To use these shaders you have to:
- Create a new shader (.shader file) and copy the shader code into this.
- Create a new material and set it to use that newly created shader.

Unity Technologies

does anyone have a shader for photoshop "screen"?
also known as negative multiply...

the code should be output= 1-((1-a)*(1-b))

so it should be something like OneMinus (OneMinusSourceColor)* (OneMinusDstColor)

Click to expand...

I think you might be misunderstanding what shaders do. "Screen" is one type of blending operation. There are an infinite number of possible shaders that use a screen operation somewhere.

If you're looking for parameters to the Blend command that will produce a screen blend, that's unfortunately not possible due to the limitations of fixed function blending. To get a screen operation into the final blend, you would need to get the destination colour from a more versatile source, such as a GrabPass. The documentation for GrabPass is here.

Actually you can do `Screen` using the blending hardware. I did it in my Shader Wizard asset. But other ones like Overlay, Hard Light etc you can only do between two textures within the shader, and not against the backbuffer.

Hmm, let's see... You were quite close:
a + b - ab
can be also expressed as:
a + (1 - a) * b
which can be translated as a simple addition:Blend One OneMinusSrcColor
or symmetrically:Blend OneMinusDstColorOne

which is already included in the manual as "Soft Additive" blending... Maybe it needs some clarification that it's equivalent to Screen blending?

And for simulating the "Color" Photoshop layer effect? I can reward anybody with a working Unity shader, because I am really unable to find this anywhere on Google.

Click to expand...

If you specify color blending as just multiplying the destination color with a luminosity normalized source color, then it can be done with just hardware blending as well... Otherwise you will need to have it either as a post processing effect or use grab pass or command buffer magic. PM me the details if you want me to write you one.

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.