Page 1 of 2

Help! "Multiply" transparency..?

Posted: 23 Apr 2013, 09:00
by mrmacmusic
I'm hoping someone can help with an urgent request... is it possible to replicate the effect of having a layer "multiply" the layer beneath as in Photoshop?

I need to place logos over an animated background, but rather than simple alpha transparency, the colours in the logo needs to multiply with the (grayscale) layer below. Can this be done using the Texture Shading Editor, and if so.. how?!? :oops:

Thanks in advance!

Re: Help! "Multiply" transparency..?

Posted: 23 Apr 2013, 12:33
by mrmacmusic
Alex Klein wrote:Not completely sure, but I think that's not possible with the DirectX fixed function pipeline texture shading. Simplest solution is to use an HLSL node, use the trivial vertex shader that is automatically filled in and simply do the multiply in the pixel shader. Check out http://www.ventuz.com/support/help/late ... hader.html , you should only need a very basic knowledge of HLSL that you should be able to google/read up in an hour or less... perhaps if you google for hlsl shaders, you will even find a suitable code. Unfortunately, I don't have any time at all at the moment to code it myself, but it's really, really easy. Hope it helps...

Alex
Thanks Alex – I will go Googling now that our internet has returned... we've been disconnected all morning :x

Re: Help! "Multiply" transparency..?

Posted: 29 Apr 2013, 13:41
by ErikB
We do have the Texture Mixer Shader http://www.ventuz.com/support/help/late ... Mixer.html which might allow you to do what you need.

Re: Help! "Multiply" transparency..?

Posted: 29 Apr 2013, 13:47
by mrmacmusic
ErikB wrote:We do have the Texture Mixer Shader http://www.ventuz.com/support/help/late ... Mixer.html which might allow you to do what you need.
Thanks for that – I will check it out.

I was just about to post to say that I've not had the chance to get my head round programming my own Multiply Blend shader, and now the client definitely wants this look rather than boring old alpha transparency.... I know programming one should be relatively simple, but now I'm struggling. So much to learn, so little time...! :?

Re: Help! "Multiply" transparency..?

Posted: 29 Apr 2013, 16:25
by mrmacmusic
Looks like it will need to be an HLSL shader, and if anyone can point me in the direction of how to make this work I'd be eternally grateful!

So, how do I get Ventuz to make sense of this blend function?

float4 Multiply (float4 cBase, float4 cBlend)
{
return (cBase * cBlend);
}

I guess I need to define what cBase and cBlend are, but I'm really not sure how to do that :? Can anyone help?!

Re: Help! "Multiply" transparency..?

Posted: 30 Apr 2013, 11:16
by mrmacmusic
I'm still desperately seeking help with this :oops:

By tweaking the basic HLSL node, I've solved one element of this project (a simple blue rectangle which needs to multiply the grayscale underlying layer)...

Code: Select all

float4x4 WorldViewProjection  : WORLDVIEWPROJECTION;

// Vertex shader program input
struct VS_INPUT
{
	float4 Position : POSITION;
};

// Vertex shader program output
struct VS_OUTPUT
{
	float4 Position : POSITION;
};

// Vertex Shader Program

VS_OUTPUT VS( VS_INPUT Input )
{
	VS_OUTPUT Output;

	// Transform the vertex from 3D object space to 2D screen space.
	Output.Position = mul(Input.Position, WorldViewProjection);
	
	return Output;
}

// Pixel Shader Program

float4 PS( VS_OUTPUT Input ) : COLOR
{
	return float4(0.1f, 0.15f, 0.4f, 0.1f);
}

technique Tech1
{
	pass pass0
	{
		vertexshader = compile vs_3_0 VS();
		pixelshader  = compile ps_3_0 PS();
		srcBlend = destColor;
		destBlend = srcAlpha;
	}
}
But I still need a shader that will not generate the blue colour itself (as the above code does), but instead it needs to use the colours of the existing texture which is next in the node tree (logo with alpha) to multiply the underlying layer... Can someone please help me get this working?!

Re: Help! "Multiply" transparency..?

Posted: 30 Apr 2013, 18:26
by chriss0212
hi mr mac

can you post a simple photoshop file what shows what you like to have?

greetz

christian

Re: Help! "Multiply" transparency..?

Posted: 01 May 2013, 08:35
by mrmacmusic
chriss0212 wrote: can you post a simple photoshop file what shows what you like to have?

christian
No problem Christian – see attached screen grab which illustrates the layers.

Logo layer is coloured, has transparency, and is set to "Multiply" blend in Photoshop;
Base layer is a grayscale animated background (illustrated by the pattern in the screen grab).

Does this make things clearer?!

Re: Help! "Multiply" transparency..?

Posted: 21 May 2013, 13:09
by Götz_B
Did you already find a solution?
I wrote some HLSL code that might suit your needs.

Re: Help! "Multiply" transparency..?

Posted: 22 May 2013, 08:27
by mrmacmusic
Götz_B wrote:Did you already find a solution?
I wrote some HLSL code that might suit your needs.
Hi – I managed to fake it, but the result wasn't the "multiply" blend that I wanted. I would be interested to see your HLSL shader code if you don't mind sharing it?