[HELP] Shader with multiple SamplerColor

  • matsilagi
  • Topic Author
More
10 years 9 months ago - 10 years 9 months ago #1 by matsilagi [HELP] Shader with multiple SamplerColor was created by matsilagi
So, im porting a shader for personal use, and i have been trying to solve this basically the entire December + January (yes, im THAT dedicated on solving something).

The texture in its original form (Unity) uses 2 color buffers, but each one renders its stuff (one of them is dedicated of rendering a pass only, without mixing its color changes on the main texture, and the other one is the main).


It has something like this:
Code:
float tn = tex2D(_TapeTex, pn).x
But on ReShade, i can only do it in a single SamplerColor, which would be like using _MainTex on it, which equals to:
Code:
float tn = tex2D(_MainTex, pn).x //Unity float tn = tex2D(SamplerColor, pn).x //ReShade

How can i replicate the second SamplerColor (_TapeTex) in ReShade? Doing it like the original code just changing the names didn't work, it gave a broken result just like in Unity if i did it that way.
Last edit: 10 years 9 months ago by matsilagi.

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

  • crosire
More
10 years 9 months ago #2 by crosire Replied by crosire on topic [HELP] Shader with multiple SamplerColor
I don't understand the problem. What do you need a variable called "SamplerColor" for?? Just do something like this:
Code:
texture _MainTexture ...; sampler _MainTex { Texture = _MainTexture; } texture _TapeTexture ...; sampler _TapeTex { Texture = _TapeTexture; } ... tex2D(_MainTex, pn); tex2D(_TapeTex, pn);

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

  • matsilagi
  • Topic Author
More
10 years 9 months ago - 10 years 9 months ago #3 by matsilagi Replied by matsilagi on topic [HELP] Shader with multiple SamplerColor
I already did that, problem is both use COLOR as texture. But on Unity, it is possible to have 2 of those, but one of them(_TapeTex) wont mix in the main image completely.

Ok, so, here's the Unity shader working correctly (Using _TapeTex and _MainTex):


Here's the Unity shader if i choose to use _MainTex only:


Which is the same result i get on ReShade, no matter what:


I don't know how to say this, but the _TapeTex sampler in Unity is the entire Tape pass, plus it renders those color changes (sepia + distortion and tape noise) only on that sampler instead of mixing into the main Color one, i need a way to replicate this in ReShade (2 color samplers but each with its own changes i guess).

Here's the code i use in ReShade for them:
Code:
texture2D texColor : COLOR; texture2D _TapeTex : COLOR; sampler2D _TapeColor { Texture = _TapeTex; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = Clamp; AddressV = Clamp; }; sampler2D SamplerColor { Texture = texColor; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = Clamp; AddressV = Clamp; };

OK, i fixed part of it, the noise now appears, but it still needs to be joined to the other part of the code and still needs to be fixed.
Last edit: 10 years 9 months ago by matsilagi.

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

  • crosire
More
10 years 9 months ago - 10 years 9 months ago #4 by crosire Replied by crosire on topic [HELP] Shader with multiple SamplerColor
"COLOR" is a semantic and a feature of ReShade FX which in this context allows you to mark a texture to recieve the backbuffer content. It has nothing to do with COLOR in Unity (you cannot put semantics on textures in Unity).

You have not explained what data _TapeTex is supposed to hold. Is it a rendertarget? Is it some image file? Since you mentioned a "Tape pass" I'm guessing it's the former? And _MainTex is probably the backbuffer content (= frame image)? Or is that some rendertarget buffer too?
Code:
texture BackBuffer : COLOR; texture TapeBuffer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; }; sampler _MainTex { Texture = BackBuffer ; } sampler _TapeTex { Texture = TapeBuffer; } ... float4 PS_Tape(...) : COLOR { ... } float4 PS_SomePass(...) : COLOR { tex2D(TapeBuffer, ...); ... } ... technique MyEffect { pass TapePass { VertexShader = ...; PixelShader = PS_Tape; RenderTarget = TapeBuffer; } pass SomePass { VertexShader = ...; PixelShader = PS_SomePass; } }

Or do you want multi-target rendering?
Code:
texture MainBuffer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; }; texture TapeBuffer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; }; sampler _MainTex { Texture = MainBuffer; } sampler _TapeTex { Texture = TapeBuffer; } ... void PS_Tape(..., out float4 colorMainOut : COLOR0, out float4 colorTapeOut : COLOR1) { colorMainOut = ...; colorTapeOut = ...; } ... technique MyEffect { pass TapePass { VertexShader = ...; PixelShader = PS_Tape; RenderTarget0 = MainBuffer; RenderTarget1 = TapeBuffer; } ... }
Last edit: 10 years 9 months ago by crosire.
The following user(s) said Thank You: matsilagi

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

  • matsilagi
  • Topic Author
More
10 years 9 months ago - 10 years 9 months ago #5 by matsilagi Replied by matsilagi on topic [HELP] Shader with multiple SamplerColor

crosire wrote: "COLOR" is a semantic and a feature of ReShade FX which in this context allows you to mark a texture to recieve the backbuffer content. It has nothing to do with COLOR in Unity (you cannot put semantics on textures in Unity).

You have not explained what data _TapeTex is supposed to hold. Is it a rendertarget? Is it some image file? Since you mentioned a "Tape pass" I'm guessing it's the former? And _MainTex is probably the backbuffer content (= frame image)? Or is that some rendertarget buffer too?

Code:
texture BackBuffer : COLOR; texture TapeBuffer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; }; sampler _MainTex { Texture = BackBuffer ; } sampler _TapeTex { Texture = TapeBuffer; } ... float4 PS_Tape(...) : COLOR { ... } float4 PS_SomePass(...) : COLOR { tex2D(TapeBuffer, ...); ... } ... technique MyEffect { pass TapePass { VertexShader = ...; PixelShader = PS_Tape; RenderTarget = TapeBuffer; } pass SomePass { VertexShader = ...; PixelShader = PS_SomePass; } }

Or do you want multi-target rendering?
Code:
texture MainBuffer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; }; texture TapeBuffer { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; }; sampler _MainTex { Texture = MainBuffer; } sampler _TapeTex { Texture = TapeBuffer; } ... void PS_Tape(..., out float4 colorMainOut : COLOR0, out float4 colorTapeOut : COLOR1) { colorMainOut = ...; colorTapeOut = ...; } ... technique MyEffect { pass TapePass { VertexShader = ...; PixelShader = PS_Tape; RenderTarget0 = MainBuffer; RenderTarget1 = TapeBuffer; } ... }


Sorry for the late reply! Don't get mad but, i fixed it myself :v

Unity engine stores its data in a confusing way, apparently, _TapeTex was a RT that held the resolution of the screen and drew the noise and returned just the noise, the color part was beign manipulated in Pass 1, but applied to the _TapeTex RT. (I hope i didn't get confusing again)

Here's a screenshot:

Sorry for disturbing!
Last edit: 10 years 9 months ago by matsilagi.

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

  • crosire
More
10 years 9 months ago #6 by crosire Replied by crosire on topic [HELP] Shader with multiple SamplerColor
Alright. Glad to hear it's working now =).

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