Simple Emboss Shader
- Ioxa
Aelius Maximus wrote:
LuciferHawk wrote:
Added the shader to the Framework, here is what you can use until the release:
Emboss.h in CustomFX suite folderNAMESPACE_ENTER(CFX) #include CFX_SETTINGS_DEF #if USE_EMBOSS float4 PS_Emboss(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target { float4 res = 0; float4 origcolor = tex2D(RFX_backbufferColor, texcoord); float3 col1 = tex2D(RFX_backbufferColor, texcoord - RFX_PixelSize*fEmbossOffset).rgb; float3 col2 = origcolor.rgb; float3 col3 = tex2D(RFX_backbufferColor, texcoord + RFX_PixelSize*fEmbossOffset).rgb; #if(bEmbossDoDepthCheck != 0) float depth1 = tex2D(RFX_depthColor,texcoord - RFX_PixelSize*fEmbossOffset).r; float depth2 = tex2D(RFX_depthColor,texcoord).r; float depth3 = tex2D(RFX_depthColor,texcoord + RFX_PixelSize*fEmbossOffset).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; } technique Emboss_Tech <bool enabled = RFX_Start_Enabled; int toggle = Emboss_ToggleKey; > { pass Emboss { VertexShader = RFX_VS_PostProcess; PixelShader = PS_Emboss; } } #endif #include CFX_SETTINGS_UNDEF NAMESPACE_LEAVE()
Add this line somewhere in EffectOrdering.cfg#include EFFECT(CustomFX, Emboss)
Add this configuration section to CustomFX_settings.cfg////----------// ///**EMBOSS**/// //----------//// #define USE_EMBOSS 1 //[Emboss] //-Gives the image a painty look //>Emboss Settings<\\ #define bEmbossDoDepthCheck 1 //[0:1] //-EXPERIMENTAL! If enabled, shader compares emboss samples depth to avoid artifacts at object borders. #define fEmbossDepthCutoff 0.0080 //[0.0001:0.0100] //-Preserves object edges from getting artifacts. If pixel depth difference of emboss samples is higher than that, pixel gets skipped. #define fEmbossPower 0.666 //[0.100:2.000] //-Amount of embossing. #define fEmbossOffset 2.0 //[0.5:5.0] //-Pixel offset for embossing. #define Emboss_ToggleKey RFX_ToggleKey //[undef] //-
Enjoy
@LuciferHawk to the rescue 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
Change RFX_PixelSize to RFX_pixelSize.
Please Log in or Create an account to join the conversation.
- Aelius Maximus
Change RFX_PixelSize to RFX_pixelSize.Ioxa wrote:
Warning: Spoiler!Aelius Maximus wrote:
LuciferHawk wrote:
Added the shader to the Framework, here is what you can use until the release:
Emboss.h in CustomFX suite folderNAMESPACE_ENTER(CFX) #include CFX_SETTINGS_DEF #if USE_EMBOSS float4 PS_Emboss(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target { float4 res = 0; float4 origcolor = tex2D(RFX_backbufferColor, texcoord); float3 col1 = tex2D(RFX_backbufferColor, texcoord - RFX_PixelSize*fEmbossOffset).rgb; float3 col2 = origcolor.rgb; float3 col3 = tex2D(RFX_backbufferColor, texcoord + RFX_PixelSize*fEmbossOffset).rgb; #if(bEmbossDoDepthCheck != 0) float depth1 = tex2D(RFX_depthColor,texcoord - RFX_PixelSize*fEmbossOffset).r; float depth2 = tex2D(RFX_depthColor,texcoord).r; float depth3 = tex2D(RFX_depthColor,texcoord + RFX_PixelSize*fEmbossOffset).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; } technique Emboss_Tech <bool enabled = RFX_Start_Enabled; int toggle = Emboss_ToggleKey; > { pass Emboss { VertexShader = RFX_VS_PostProcess; PixelShader = PS_Emboss; } } #endif #include CFX_SETTINGS_UNDEF NAMESPACE_LEAVE()
Add this line somewhere in EffectOrdering.cfg#include EFFECT(CustomFX, Emboss)
Add this configuration section to CustomFX_settings.cfg////----------// ///**EMBOSS**/// //----------//// #define USE_EMBOSS 1 //[Emboss] //-Gives the image a painty look //>Emboss Settings<\\ #define bEmbossDoDepthCheck 1 //[0:1] //-EXPERIMENTAL! If enabled, shader compares emboss samples depth to avoid artifacts at object borders. #define fEmbossDepthCutoff 0.0080 //[0.0001:0.0100] //-Preserves object edges from getting artifacts. If pixel depth difference of emboss samples is higher than that, pixel gets skipped. #define fEmbossPower 0.666 //[0.100:2.000] //-Amount of embossing. #define fEmbossOffset 2.0 //[0.5:5.0] //-Pixel offset for embossing. #define Emboss_ToggleKey RFX_ToggleKey //[undef] //-
Enjoy
@LuciferHawk to the rescue 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
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.
- Ioxa
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.
Please Log in or Create an account to join the conversation.
- Aelius Maximus
Ioxa wrote: 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.
Please Log in or Create an account to join the conversation.
- Valken
- Topic Author
Please Log in or Create an account to join the conversation.
- kingeric1992
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
Please Log in or Create an account to join the conversation.
- Aelius Maximus
kingeric1992 wrote: 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?
Please Log in or Create an account to join the conversation.
- kingeric1992
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....(๑•́ ₃ •̀๑)
Please Log in or Create an account to join the conversation.
- Aelius Maximus
kingeric1992 wrote: 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.
- kingeric1992
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;
}
Please Log in or Create an account to join the conversation.
- klotim
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.