Concatenating Two or More Images Together

  • Cypher
  • Topic Author
More
5 years 3 weeks ago - 5 years 3 weeks ago #1 by Cypher Concatenating Two or More Images Together was created by Cypher
(Sorry if I may be using nontechnical terms since I'm new to Shader Programming)

I want to concatenate the Current Frame + Depth + Normals.

The "DisplayDepth.fx" shader extracts the Depth & Normals BUT when showing them, It splits the screen like this:
I want to display the whole original frame + the whole frame's depth + the whole frame's normals in a split screen (That would be 3 Structurally identical images in each frame). For example this Video shows 2 processed frames side by side each other:

I'm aiming for something like above but with 3 images per each frame: COLOR + DEPTH + NORMAL
These are the orders I'm looking for (preferebly the first one):

[1 = COLOR | 2 = DEPTH | 3 = NORMAL]

[1 = COLOR | 2 = DEPTH | 3 = NORMAL]

I've tried to modify the code for the Depth3D shader and came up with a way to show both the COLOR and the DEPTH side by side like this:
color = texcoord.x < 0.5 ? tex2D(BackBuffer, float2((texcoord.x*2), texcoord.y)) : depth;

But I don't know how to concatenate the NORMAL alongside these two images since it first needs to somehow be resized to 0.5 or 0.33 of the screen size and then added to the frame. I can resize both the COLOR and the DEPTH images using the `tex2D` function as shown above but I don't know how to resize the NORMAL. Is there a way to code this?

Thanks
Last edit: 5 years 3 weeks ago by Cypher.

Please Log in or Create an account to join the conversation.

  • seri14
More
5 years 3 weeks ago #2 by seri14 Replied by seri14 on topic Concatenating Two or More Images Together
Write multi pass shader.
technique MyEffect
{
  pass first_execute
  {
    VertexShader = PostProcessVS;
    PixelShader = PS_First;
    RenderTarget = TemporaryTex_For_First;
  }
  pass second_execute
  {
    VertexShader = PostProcessVS;
    PixelShader = PS_Second;
    RenderTarget = TemporaryTex_For_Second;
  }
  pass third_execute
  {
    VertexShader = PostProcessVS;
    PixelShader = PS_Third;
    // Render to screen with using TemporaryTex_For_First and TemporaryTex_For_Second.
  }
}
The following user(s) said Thank You: Cypher

Please Log in or Create an account to join the conversation.

  • Cypher
  • Topic Author
More
5 years 3 weeks ago #3 by Cypher Replied by Cypher on topic Concatenating Two or More Images Together
Thank you so much for the hint. Is there a sample code you could guide me to so that I could build up on it? Your pseudocode is great but since I'm new to programming shaders, I could really use a sample code. Thanks again.

Please Log in or Create an account to join the conversation.

  • seri14
More
5 years 3 weeks ago #4 by seri14 Replied by seri14 on topic Concatenating Two or More Images Together
part of fx and not tested
// Bring to equal with game screen resolution. (BUFFER_ macro created by ReShade)

// for PS_First and PS_Third
texture TemporaryTex_For_First { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };
sampler TexSampler_For_First { Texture = TemporaryTex_For_First; };

// for PS_Second and PS_Third
texture TemporaryTex_For_Second { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };
sampler TexSampler_For_Second { Texture = TemporaryTex_For_Second; };

void PS_First(float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target)
{
	// Render to TemporaryTex_For_First
	passColor = float4(texCoord.x, 0.0, 0.0, 1.0); // Gradation of red
}

void PS_Second(float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target)
{
	// Render to TemporaryTex_For_Second
	passColor = float4(0.0, texCoord.x, 0.0, 1.0); // Gradation of green
}

void PS_Third(float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target)
{
	// Render to screen
	if (texCoord.x < 0.5) // Render the gradation of red to left
	{
		// texCoord 0.0 ... 0.5 for texture 0.0 ... 1.0
		passColor = tex2D(TexSampler_For_First, float2(texCoord.x * 2.0, texCoord.y));
	}
	else // Render the gradation of green to right
	{
		// texCoord 0.5 ... 1.0 for texture 0.0 ... 1.0
		passColor = tex2D(TexSampler_For_Second, float2((texCoord.x - 0.5) * 2.0, texCoord.y));
	}
}
The following user(s) said Thank You: Cypher

Please Log in or Create an account to join the conversation.

  • Cypher
  • Topic Author
More
5 years 3 weeks ago #5 by Cypher Replied by Cypher on topic Concatenating Two or More Images Together

seri14 wrote: part of fx and not tested

// Bring to equal with game screen resolution. (BUFFER_ macro created by ReShade)

// for PS_First and PS_Third
texture TemporaryTex_For_First { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };
sampler TexSampler_For_First { Texture = TemporaryTex_For_First; };

// for PS_Second and PS_Third
texture TemporaryTex_For_Second { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };
sampler TexSampler_For_Second { Texture = TemporaryTex_For_Second; };

void PS_First(float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target)
{
	// Render to TemporaryTex_For_First
	passColor = float4(texCoord.x, 0.0, 0.0, 1.0); // Gradation of red
}

void PS_Second(float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target)
{
	// Render to TemporaryTex_For_Second
	passColor = float4(0.0, texCoord.x, 0.0, 1.0); // Gradation of green
}

void PS_Third(float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target)
{
	// Render to screen
	if (texCoord.x < 0.5) // Render the gradation of red to left
	{
		// texCoord 0.0 ... 0.5 for texture 0.0 ... 1.0
		passColor = tex2D(TexSampler_For_First, float2(texCoord.x * 2.0, texCoord.y));
	}
	else // Render the gradation of green to right
	{
		// texCoord 0.5 ... 1.0 for texture 0.0 ... 1.0
		passColor = tex2D(TexSampler_For_Second, float2((texCoord.x - 0.5) * 2.0, texCoord.y));
	}
}


Thank you so much. I was able to pull it off.

Please Log in or Create an account to join the conversation.

  • kex
More
4 years 11 months ago #6 by kex Replied by kex on topic Concatenating Two or More Images Together
May I ask for the shader file? Im realy interested in getting this for split screen of original and depth combined.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.