Simple Emboss Shader

More
7 years 3 weeks ago #41 by Ioxa
Replied by Ioxa on topic Simple Emboss Shader
Warning: Spoiler!



@LuciferHawk to the rescue :D This is fantastic, very nicely ordered, easy to copy and implement. Now i have everything copied into the corresponding files that you stated, it's kind of not compiling and throwing up a very specific line of code. \ReShade\CustomFX\Emboss.h (10, 54) : error X3004: undeclared identifier 'RFX_PixelSize'. Not sure what this means? Any additional help would be much appreciated :D
Change RFX_PixelSize to RFX_pixelSize.
The following user(s) said Thank You: Aelius Maximus

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

More
7 years 3 weeks ago #42 by Aelius Maximus
Replied by Aelius Maximus on topic Simple Emboss Shader

Warning: Spoiler!



@LuciferHawk to the rescue :D This is fantastic, very nicely ordered, easy to copy and implement. Now i have everything copied into the corresponding files that you stated, it's kind of not compiling and throwing up a very specific line of code. \ReShade\CustomFX\Emboss.h (10, 54) : error X3004: undeclared identifier 'RFX_PixelSize'. Not sure what this means? Any additional help would be much appreciated :D

Change RFX_PixelSize to RFX_pixelSize.


Hi Loxa. Tried and tested your suggestion already, it now gives a new error! /ReShade/CustomFX/Emboss.h(51, 1): error X3000: syntax error: unexpected '}'

Any ideas?

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

More
7 years 3 weeks ago #43 by Ioxa
Replied by Ioxa on topic Simple Emboss Shader
Glancing at the code I don't see an extra brace anywhere. Maybe something was left from the file you pasted the code into? Scroll down to the bottom of the .h file and delete the last brace ( } ) you see.

Use Notepad ++ or something like it, it makes it a lot easier to troubleshoot this stuff. When you get an error message in ReShade it tells you the file and location in the file of an error. So where it says Emboss.h(51,1) it's telling you file name(line number in the file, column number in the file). That will make it easy to find that extra brace.
The following user(s) said Thank You: Aelius Maximus

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

More
7 years 2 weeks ago #44 by Aelius Maximus
Replied by Aelius Maximus on topic Simple Emboss Shader

Glancing at the code I don't see an extra brace anywhere. Maybe something was left from the file you pasted the code into? Scroll down to the bottom of the .h file and delete the last brace ( } ) you see.

Use Notepad ++ or something like it, it makes it a lot easier to troubleshoot this stuff. When you get an error message in ReShade it tells you the file and location in the file of an error. So where it says Emboss.h(51,1) it's telling you file name(line number in the file, column number in the file). That will make it easy to find that extra brace.


Recopied and pasted the code into the Emboss.h, somehow before i only copied 51 lines, when there is in fact 53, my mistake, got it up and running and compiled now. Great work guys. :woohoo:

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

More
7 years 2 weeks ago #45 by Valken
Replied by Valken on topic Simple Emboss Shader
Can someone advise the syntax to add this to MasterEffects.h and Reshade.fx properly? Thanks!

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

More
7 years 2 weeks ago - 7 years 2 weeks ago #46 by kingeric1992
Replied by kingeric1992 on topic Simple Emboss Shader
Why not use angle offsets?
float2 offset;
sincos(radians( iEmbossAngle), offset.y, offset.x);
float3 col1 = tex2D(RFX_backbufferColor, texcoord - RFX_PixelSize*fEmbossOffset*offset).rgb;
float3 col2 = origcolor.rgb;
float3 col3 = tex2D(RFX_backbufferColor, texcoord + RFX_PixelSize*fEmbossOffset*offset).rgb;

iEmbossAngle [-180, 180], direction of light
Last edit: 7 years 2 weeks ago by kingeric1992.
The following user(s) said Thank You: Aelius Maximus

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

More
7 years 2 weeks ago - 7 years 2 weeks ago #47 by Aelius Maximus
Replied by Aelius Maximus on topic Simple Emboss Shader

Why not use angle offsets?
float2 offset;
sincos(radians( iEmbossAngle), offset.y, offset.x);
float3 col1 = tex2D(RFX_backbufferColor, texcoord - RFX_PixelSize*fEmbossOffset*offset).rgb;
float3 col2 = origcolor.rgb;
float3 col3 = tex2D(RFX_backbufferColor, texcoord + RFX_PixelSize*fEmbossOffset*offset).rgb;

iEmbossAngle [-180, 180], direction of light


Hey Kingeric. What is this and how does it work? I guess it will add more realism? can i copy and paste it straight into the shader that Luciferhawk created?
Last edit: 7 years 2 weeks ago by Aelius Maximus.

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

More
7 years 2 weeks ago #48 by kingeric1992
Replied by kingeric1992 on topic Simple Emboss Shader
option to control the direction of shadow like in here (Photoshop)


replace these line,
float3 col1....
float3 col2...
float3 col3 ...
then add
#define iEmbossAngle 120 //[-180, 180] light direction
at config file.

Should work, haven't tested in reshade though....(๑•́ ₃ •̀๑)
The following user(s) said Thank You: Aelius Maximus

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

More
7 years 2 weeks ago #49 by Aelius Maximus
Replied by Aelius Maximus on topic Simple Emboss Shader

option to control the direction of shadow like in here (Photoshop)


replace these line,
float3 col1....
float3 col2...
float3 col3 ...
then add
#define iEmbossAngle 120 //[-180, 180] light direction
at config file.

Should work, haven't tested in reshade though....(๑•́ ₃ •̀๑)


Ahh, thought it was going to compile, then i got this

"H:\Program Files\GRID Autosport\ReShade/CustomFX/Emboss.h(14, 23): error X3004: undeclared identifier 'origcolor'"

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

More
7 years 2 weeks ago - 7 years 2 weeks ago #50 by kingeric1992
Replied by kingeric1992 on topic Simple Emboss Shader
You probably accidentally delete the line: "float4 origcolor..." .

Here is the complete shader with angle modification.
float4 PS_Emboss(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
	float4 res = 0;
	float4 origcolor = tex2D(RFX_backbufferColor, texcoord);

        float2 offset;
	sincos(radians( iEmbossAngle), offset.y, offset.x);
	float3 col1 = tex2D(RFX_backbufferColor, texcoord - RFX_PixelSize*fEmbossOffset*offset).rgb;
	float3 col2 = origcolor.rgb;
	float3 col3 = tex2D(RFX_backbufferColor, texcoord + RFX_PixelSize*fEmbossOffset*offset).rgb;

#if(bEmbossDoDepthCheck != 0)
	float depth1 = tex2D(RFX_depthColor,texcoord - RFX_PixelSize*fEmbossOffset*offset).r;
	float depth2 = tex2D(RFX_depthColor,texcoord).r;
	float depth3 = tex2D(RFX_depthColor,texcoord + RFX_PixelSize*fEmbossOffset*offset).r;
#endif
	
	float3 colEmboss = col1 * 2.0 - col2 - col3;

	float colDot = max(0,dot(colEmboss, 0.333))*fEmbossPower;

	float3 colFinal = col2 - colDot;

	float luminance = dot( col2, float3( 0.6, 0.2, 0.2 ) );

	res.xyz = lerp( colFinal, col2, luminance * luminance ).xyz;
#if(bEmbossDoDepthCheck != 0)
        if(max(abs(depth1-depth2),abs(depth3-depth2)) > fEmbossDepthCutoff) res = origcolor;
#endif
	return res;

}
Last edit: 7 years 2 weeks ago by kingeric1992.

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

More
7 years 1 week ago #51 by klotim
Replied by klotim on topic Simple Emboss Shader
Aelius Maximus

I think you done something wrong as it worked perfectly by just copying the code and do as lucifer said.
And also copy the #define iEmbossAngle 120 //[-180, 180] by kingeric

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