Welcome, Guest.
Username: Password: Remember me

TOPIC: Concatenating Two or More Images Together

Concatenating Two or More Images Together 3 weeks 3 days ago #1

(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: 3 weeks 3 days ago by Cypher.
The administrator has disabled public write access.

Concatenating Two or More Images Together 3 weeks 3 days ago #2

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 administrator has disabled public write access.
The following user(s) said Thank You: Cypher

Concatenating Two or More Images Together 3 weeks 2 days ago #3

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.
The administrator has disabled public write access.

Concatenating Two or More Images Together 3 weeks 2 days ago #4

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 administrator has disabled public write access.
The following user(s) said Thank You: Cypher

Concatenating Two or More Images Together 3 weeks 2 days ago #5

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.
The administrator has disabled public write access.