Page 1 of 1

Adding Photoshop blending modes to the RT Shader System

Posted: Sat Sep 26, 2009 3:09 pm
by Assaf Raman
Nir and I talked about a requirement that we got from an artist to have a blending mode named "Overlay" that Photoshop has - as a new blending mode that the RT Shader System can have for textures.
After searching a bit I found this link that shows the math behind photoshop blanding modes. (the bottom of the page also has sample images).
I also found this link that implements all of them in glsl.

I think that adding all of the modes will be the best thing and will give the most to the users. Shouldn't be hard - we have them all in glsl so converting them to CG should be easy.

We can also use the images from the first link as use samples.

Is this a good idea?

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Sat Sep 26, 2009 3:52 pm
by Assaf Raman
I missed it - but now I see he also wrote the shaders in hlsl. Look here.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Sat Sep 26, 2009 4:10 pm
by sinbad
Makes sense since that's how artists tend to think of things.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Sat Sep 26, 2009 4:54 pm
by xavier
Can't count the number of times an artist has said to me "but it looks how I want in Photoshop"...

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Sat Sep 26, 2009 5:32 pm
by Nir Hasson
That looks cool !!

I will add it to my task list on high priority :)
I think the best place is to extend the texture unit blend modes and override the FFP texturing stage with these cool blend modes.

I liked it :D

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Mon Dec 07, 2009 9:10 am
by Assaf Raman
Can I add this to the roadmap\help wanted and make this thread public?

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Mon Dec 07, 2009 1:02 pm
by sinbad
Fine by me.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Mon Dec 07, 2009 1:39 pm
by Assaf Raman

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Tue Jan 12, 2010 7:11 pm
by Assaf Raman
I found this great article that really does a good job showing off the photoshop blending modes.
The nice thing is that the we can add the textures and images in the article to a new sample to demonstrate the blending mode - they have free licenses.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Thu Jan 14, 2010 8:51 am
by bishopnator
Hi, I think more interesting link is this: http://www.nathanm.com/photoshop-blending-math/. There are equations for each blending mode from PS instead of verbal description of blending modes.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Thu Jan 14, 2010 10:26 am
by Assaf Raman
bishopnator wrote:Hi, I think more interesting link is this: http://www.nathanm.com/photoshop-blending-math/. There are equations for each blending mode from PS instead of verbal description of blending modes.
Your link is the first link on the first post on this thread...

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Mon Mar 15, 2010 1:48 pm
by Assaf Raman
A friend implemented this feature (not me).
Just committed to the trunk.
Only the CG version for now.
Added an entity that shows the feature to the RTSS sample - a rock wall with the OGRE logo blended with the new "overlay" blend.

Here is how the material file looks like for this sample:

Code: Select all

material RTSS/Example-LayeredBlending
{
	technique
	{
		pass
		{
			lighting off
			texture_unit
			{
				scale 0.1 0.1
				texture rockwall.tga
			}

			texture_unit
			{
				// RT Shader system section - required by the comming layered blend extension.
				rtshader_system
				{
					layered_blend blend_overlay
				}
				texture ogrelogo.png
			}
			
			// RT Shader system section.
			rtshader_system
			{
				texturing_stage layered_blend
				// you must have this section (even with only texturing_stage layered_blend) for the layered blend to 
				// work. Also - this section must me the last one in the pass.
			}
		}
	}
}

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Mon Mar 15, 2010 3:40 pm
by sinbad
Nice work!

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Tue Mar 16, 2010 8:02 pm
by Nir Hasson
I just commited some fixes to this brand new feature.
Also changed the sample to show all the blend modes...
Seems like I'm running out of space for UI components.. :D

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Wed Mar 17, 2010 8:28 am
by masterfalcon
Out of curiosity, in setupContent there's a check for DX9, is it needed? Or could that be changed to check for a specific rendersystem capability perhaps? Otherwise we'll have to expand it to cover DX10, 11 and GLES 2, I think.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Wed Mar 17, 2010 5:39 pm
by Nir Hasson
I added this check for now because we don't have glsl shader implementation.
I'll remove it when it will be available.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Wed Mar 17, 2010 6:01 pm
by masterfalcon
Cool cool. I'll probably check that in soon. Just gotta test it and the GLSL ES version.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Thu Mar 18, 2010 8:17 pm
by Nir Hasson
I added the GLSL implementation...

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Fri Mar 19, 2010 5:31 am
by masterfalcon
GLSL ES is coming soon. About half of them work. I discovered a shortcoming of the GLSL ES writer that I need to work out first. It's something that will need to be fixed anyway so now is as good a time as any!

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Fri Mar 19, 2010 5:18 pm
by Assaf Raman
New video on the showcase forum thread.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Thu Apr 29, 2010 9:00 pm
by roimatola
Hi friends, just a quick question. This kind of blend modes you are covering here refers only to blending between textures, right? Not scene blending like the already supported by Ogre add, modulate or alpha_blend?

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Fri Apr 30, 2010 12:34 am
by Mattan Furst
@roimatola

That is correct. There is currently no way of extending the scene blends through shaders anyway, at least not in OpenGL and DirectX9/10/11.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Sat May 01, 2010 4:29 pm
by roimatola
bummmer.. I would think that a particle system with an overlay blending mode over the scene would make an incredible effect! Thanks a lot for the answer!

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Sun Feb 13, 2011 8:03 am
by masterfalcon
I just noticed what might be a typo in RTShaderSystem.material. Is this parameter correct?

Code: Select all

layered_blend blend_luminosity
I end up getting the "Expected one of the following blend modes" error in my log when the material is parsed.

Re: Adding Photoshop blending modes to the RT Shader System

Posted: Sun Feb 13, 2011 12:07 pm
by Mattan Furst
That would be my fault. I while back I changed the naming conventions in the layered blend modes to be more consistent with Ogre (e.g. removed capital letters, added underscores, removed the word "blend_" from all the modes which seemed redundant).

blend_luminosity should just be luminosity. I'll fix it.