Adding Photoshop blending modes to the RT Shader System

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Adding Photoshop blending modes to the RT Shader System

Post 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?
You do not have the required permissions to view the files attached to this post.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Adding Photoshop blending modes to the RT Shader System

Post by Assaf Raman »

I missed it - but now I see he also wrote the shaders in hlsl. Look here.
You do not have the required permissions to view the files attached to this post.
Watch out for my OGRE related tweets here.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Re: Adding Photoshop blending modes to the RT Shader System

Post by sinbad »

Makes sense since that's how artists tend to think of things.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: Adding Photoshop blending modes to the RT Shader System

Post by xavier »

Can't count the number of times an artist has said to me "but it looks how I want in Photoshop"...
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
x 2

Re: Adding Photoshop blending modes to the RT Shader System

Post 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
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Adding Photoshop blending modes to the RT Shader System

Post by Assaf Raman »

Can I add this to the roadmap\help wanted and make this thread public?
Watch out for my OGRE related tweets here.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Re: Adding Photoshop blending modes to the RT Shader System

Post by sinbad »

Fine by me.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Adding Photoshop blending modes to the RT Shader System

Post by Assaf Raman »

Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
Watch out for my OGRE related tweets here.
User avatar
bishopnator
Gnome
Posts: 348
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 16

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Adding Photoshop blending modes to the RT Shader System

Post 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...
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
			}
		}
	}
}
You do not have the required permissions to view the files attached to this post.
Watch out for my OGRE related tweets here.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Re: Adding Photoshop blending modes to the RT Shader System

Post by sinbad »

Nice work!
User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
x 2

Re: Adding Photoshop blending modes to the RT Shader System

Post 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
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
x 2

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Adding Photoshop blending modes to the RT Shader System

Post by masterfalcon »

Cool cool. I'll probably check that in soon. Just gotta test it and the GLSL ES version.
User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
x 2

Re: Adding Photoshop blending modes to the RT Shader System

Post by Nir Hasson »

I added the GLSL implementation...
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Adding Photoshop blending modes to the RT Shader System

Post 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!
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: Adding Photoshop blending modes to the RT Shader System

Post by Assaf Raman »

New video on the showcase forum thread.
Watch out for my OGRE related tweets here.
roimatola
Halfling
Posts: 58
Joined: Fri Sep 07, 2007 4:57 pm

Re: Adding Photoshop blending modes to the RT Shader System

Post 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?
User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
it's turtles all the way down
roimatola
Halfling
Posts: 58
Joined: Fri Sep 07, 2007 4:57 pm

Re: Adding Photoshop blending modes to the RT Shader System

Post 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!
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: Adding Photoshop blending modes to the RT Shader System

Post 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.
it's turtles all the way down