Simple Emboss Shader
- Valken
- Topic Author
Is it possible to make a ME shader that would duplicate that effect? I found this link that has some shader code but have no idea how to add it to Reshade.
It would be great to add this for old school games.
Please Log in or Create an account to join the conversation.
- Marty McFly
Please Log in or Create an account to join the conversation.
- Ioxa
Please Log in or Create an account to join the conversation.
- Valken
- Topic Author
gmc.yoyogames.com/index.php?showtopic=586870
QeffectsGL looks like it applies to everything - textures, pixels, voxels, models except for the player model/pixel and hud.
Thanks for looking into this!
Please Log in or Create an account to join the conversation.
- Ioxa
Please Log in or Create an account to join the conversation.
- Valken
- Topic Author
The settings available from QeffectsGL are:
Emboss=1
EmbossScale=0.666
Source code for QEffectsGL at the below link if you want to look at it:
code.google.com/p/qeffects-gl/
Please Log in or Create an account to join the conversation.
- Marty McFly
//tweakable variables
#define bEmbossDoDepthCheck 1 //[0 or 1] EXPERIMENTAL! If enabled, shader compares emboss samples depth to avoid artifacts at object borders.
#define fEmbossDepthCutoff 0.008 //[0.0001 to 0.005] 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.1 to 2.0] Amount of embossing.
#define fEmbossOffset 2.0 //[0.5 to 5.0] Pixel offset for embossing.
//end tweakable variables
texture2D texColor : COLOR;
texture2D texDepth : DEPTH;
sampler2D SamplerColor { Texture = texColor; };
sampler2D SamplerDepth
{
Texture = texDepth;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
uniform float Timer < source = "timer"; >;
#define ScreenSize float4(BUFFER_WIDTH, BUFFER_RCP_WIDTH, float(BUFFER_WIDTH) / float(BUFFER_HEIGHT), float(BUFFER_HEIGHT) / float(BUFFER_WIDTH)) //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
#define PixelSize float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
struct VS_OUTPUT_POST
{
float4 vpos : POSITION;
float2 txcoord : TEXCOORD0;
};
VS_OUTPUT_POST VS_PostProcess(in uint id : SV_VertexID)
{
VS_OUTPUT_POST OUT;
OUT.txcoord.x = (id == 2) ? 2.0 : 0.0;
OUT.txcoord.y = (id == 1) ? 2.0 : 0.0;
OUT.vpos = float4(OUT.txcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
return OUT;
}
float GetLinearDepth(float2 coords)
{
float depth = tex2Dlod(SamplerDepth, float4(coords.xy,0,0)).x;
depth = 1.f/(1000.f-999.f*depth);
return depth;
}
float4 PS_Emboss(VS_OUTPUT_POST IN) : COLOR
{
float4 res = 0;
float4 origcolor = tex2D(SamplerColor, IN.txcoord.xy);
float3 col1 = tex2D(SamplerColor, IN.txcoord.xy - PixelSize.xy*fEmbossOffset).rgb;
float3 col2 = origcolor.rgb;
float3 col3 = tex2D(SamplerColor, IN.txcoord.xy + PixelSize.xy*fEmbossOffset).rgb;
#if(bEmbossDoDepthCheck != 0)
float depth1 = GetLinearDepth(IN.txcoord.xy - PixelSize.xy*fEmbossOffset);
float depth2 = GetLinearDepth(IN.txcoord.xy);
float depth3 = GetLinearDepth(IN.txcoord.xy + PixelSize.xy*fEmbossOffset);
#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
if(IN.txcoord.x < 0.5) res = origcolor;
return res;
}
technique Emboss < bool enabled = 1;>
{
pass Emboss
{
VertexShader = VS_PostProcess;
PixelShader = PS_Emboss;
}
}
Please Log in or Create an account to join the conversation.
- Valken
- Topic Author
I think the next step would be to port POM and parallax shaders for better texture map depth in the future for Doom 3 engine games like Sikkmod.
Can't wait to try this for Half-Life, GZdoom and other games.
Please Log in or Create an account to join the conversation.
- Marty McFly
Although...I just had a crazy idea I need to try out later...embossing pseudo normal maps out of diffuse textures is simple, actually works similiar to this here. If I use the existing face normals by adding those embossed ones on top of them, I might get some roughness of the surface that I need for such purposes. Maybe not for POM but certainly for some fake lighting. Let me see....
Please Log in or Create an account to join the conversation.
- Valken
- Topic Author
May be cool in GZdoom or Half-Life or Doom 3/Quake 4 for "sewage" but I think it would need to map it to specific textures.
If you can pull some kind of Environment Mapped Bump Mapping effect, that would be incredible detail wise over simple emboss bump mapping.
Please Log in or Create an account to join the conversation.
- Marty McFly
Valken wrote: If you can pull some kind of Environment Mapped Bump Mapping effect, that would be incredible detail wise over simple emboss bump mapping.
Bump mapping in these areas just simulates light and shade on single pixel scale, nothing global so even if I could take the environment lighting into account, it would be vast calculation at a horrible performance which in effect would look 99% similiar to what we have here so I really doubt this is worth the effort.
EDIT: My assumptions concerning the normals were correct, these are A+ normals for the use in any AO technique or whatever.Notice the fine relief on surfaces that are actually 100% flat.
Please Log in or Create an account to join the conversation.
- klotim
Please Log in or Create an account to join the conversation.
- Marty McFly
Please Log in or Create an account to join the conversation.
- BillyAlt
- klotim
Marty McFly wrote: Nope, that won't happen because by definition, normal maps cannot exceed their range. I just put them for screenshot purposes into 0-1 range, they are actually in -1 to 1 range. And because they are generated by depth difference, blue channel or better z value is always 1. Oh and I actually managed to prove my own words wrong, environment bumpmapping is indeed possible, I just did it:
I quess that can't happen then when coding, I know in photoshop when working with normalmaps, by adding multiple normals on top causes a too strong blue channel causing artifacts. Normalizing and brighten the blue channel a bit fixes that.
Yup, Beautiful, Seen it on facebook. Good job!
Please Log in or Create an account to join the conversation.
- Marty McFly
klotim wrote:
Marty McFly wrote: Nope, that won't happen because by definition, normal maps cannot exceed their range. I just put them for screenshot purposes into 0-1 range, they are actually in -1 to 1 range. And because they are generated by depth difference, blue channel or better z value is always 1. Oh and I actually managed to prove my own words wrong, environment bumpmapping is indeed possible, I just did it:
I quess that can't happen then when coding, I know in photoshop when working with normalmaps, by adding multiple normals on top causes a too strong blue channel causing artifacts. Normalizing and brighten the blue channel a bit fixes that.
Yup, Beautiful, Seen it on facebook. Good job!
Remember that normals are not colors but vectors. Vectors can have any number of range. For texture lookup I only use X and Y factor of those where ranges don't matter. If I normalized those normal maps after adding the bump normals to the screen normals I couldn't really control the relief amount: normalize(bumpnormal + screen normal) means the higher I scale the bump normals, the less the screen normals are taken into account. Imagine the bump normals being 9x the screen normals, resulting normals would consist of 10% bump normals and 90% screen normals. Impossible. I have to use the screen normals and add the scaled bump normals onto them without any normalization. That essentially is against what "normals" are but I do a physically inaccurate effect so I can ignore that anyways.
Please Log in or Create an account to join the conversation.
- Aelius Maximus
Please Log in or Create an account to join the conversation.
- Marty McFly
Aelius Maximus wrote: This is amazing guys, one of the first great new ideas that has grabbed my attention again, could be an innovative way of giving old games a new lease of life, i hope an emboss shader can be derived from these demonstrations.
I don't quite get what you are saying, as I posted a fully working emboss shader and the reflective bumpmapping is a huge evolution of that. There is nothing left to derive, we even shooted way ahead than planned.
Please Log in or Create an account to join the conversation.
- kingeric1992
the demo pic also shows artifacts on trees and stuffs.
Please Log in or Create an account to join the conversation.
- Marty McFly
kingeric1992 wrote: but on what surface to apply reflection ??
the demo pic also shows artifacts on trees and stuffs.
Artifacts? GTASA trees look so shitty like this. See here:
abload.de/img/gta_sa2015-07-1623-28ynz4v.png
The poor alpha handling of GTASA causes semi-transparent areas make it see-through for textures that are behind.
And it's the curse of ReShade being so generic. And on ENB no one ever complained when it applied almost the same algorithm on everything. Try it out when it's released, good settings and it really fits almost every scene. I just amplified the effect to make it visible, like I do with everything. People keep seeing these debug-ish screens as end product.
Please Log in or Create an account to join the conversation.