Light Shafts + Tone Mapping?
- Quentin-Tarantino
- Topic Author
Less
More
8 years 6 months ago #1
by Quentin-Tarantino
Light Shafts + Tone Mapping? was created by Quentin-Tarantino
Please Log in or Create an account to join the conversation.
- kingeric1992
Less
More
8 years 6 months ago #2
by kingeric1992
Replied by kingeric1992 on topic Light Shafts + Tone Mapping?
light shafts == god rays
Please Log in or Create an account to join the conversation.
- Quentin-Tarantino
- Topic Author
Less
More
8 years 6 months ago #3
by Quentin-Tarantino
Replied by Quentin-Tarantino on topic Light Shafts + Tone Mapping?
I know but looking more like the ones in the link?
Please Log in or Create an account to join the conversation.
- Constantine PC
Less
More
8 years 6 months ago #4
by Constantine PC
Replied by Constantine PC on topic Light Shafts + Tone Mapping?
I sure hope so. I don't think godrays is quite the same as that.
Please Log in or Create an account to join the conversation.
- 04348
Less
More
8 years 6 months ago - 8 years 6 months ago #5
by 04348
Replied by 04348 on topic Light Shafts + Tone Mapping?
I've managed to get something, but there's some issues with the distance and ReShade can't easily detect the sun/light position, specifically when it's out of the screen.
Util.h :
float4 PS_mdGRMask(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
float4 color = tex2D(RFX_backbufferColor, texcoord);
float depth = tex2D(RFX_depthColor,texcoord).r;
if (depth == 1 && (color.r+color.g+color.b)/3 > GR_Bright) return color;
return float4(0,0,0,0);
}
float4 PS_mdGRBlur(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
float4 color = tex2D(RFX_backbufferColor, texcoord);
float4 mask = tex2D(SamplerMask, texcoord);
float4 output = float4(0,0,0,0);
float count = 0;
float2 lightXY = float2(0.5,0.0);
float angle = 0;
float2 vect;
for (int c=0;c<=GR_Size;c+=GR_Skip) {
if (texcoord.x >= 0.5) angle = atan( abs(texcoord.y - lightXY.y)/abs(texcoord.x - lightXY.x) ); //droite
else angle = PI-atan( abs(texcoord.y - lightXY.y) / abs(texcoord.x - lightXY.x) ); // gauche
vect = float2( -c*cos(angle)*PIXSIZE.x, -c*sin(angle)*PIXSIZE.y);
count ++;// 1-tex2D(RFX_depthTexColor, texcoord.xy + vect.xy).r;
output += tex2D(SamplerMask, texcoord.xy + vect.xy );//*(1-tex2D(RFX_depthTexColor, texcoord.xy + vect.xy).r);
}
return color + (output/count)*GR_Alpha;
}
technique Custom_Tech <bool enabled = RFX_Start_Enabled; int toggle = Custom_ToggleKey; >
{
pass mdGRMask
{
VertexShader = RFX_VS_PostProcess;
PixelShader = PS_mdGRMask;
RenderTarget = texMask;
}
pass mdGRBlur
{
VertexShader = RFX_VS_PostProcess;
PixelShader = PS_mdGRBlur;
}
}
Util.h :
#define RENDERMODE RGBA8
#define PIXSIZE float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
//textures
texture texMask { Width = BUFFER_WIDTH/2; Height = BUFFER_HEIGHT/2; MipLevels = 8; Format = RENDERMODE;};
texture texGR { Width = BUFFER_WIDTH/4; Height = BUFFER_HEIGHT/4; MipLevels = 8; Format = RENDERMODE;};
sampler2D SamplerMask
{
Texture = texMask;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
sampler2D SamplerGR
{
Texture = texGR;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
int br(float4 color) {
return (color.r+color.b+color.g)/3;
}
void PS_Init(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 hdrT : SV_Target0)
{
hdrT = tex2D(RFX_originalColor, texcoord.xy);
}
technique Init_Tech < enabled = true; >
{
pass Init_Mask
{
VertexShader = RFX_VS_PostProcess;
PixelShader = PS_Init;
RenderTarget = texMask;
}
}
Last edit: 8 years 6 months ago by 04348.
Please Log in or Create an account to join the conversation.
- Marty McFly
Less
More
Anything that is outside the screen is totally nonexistant for ReShade.
Please Log in or Create an account to join the conversation.
It didn't work for me, its missing GR_Bright and GR_Skip.
Please Log in or Create an account to join the conversation.
- kingeric1992
Less
More
8 years 5 months ago #8
by kingeric1992
Replied by kingeric1992 on topic Light Shafts + Tone Mapping?
those are macros
#define GR_Bright 0.8 //[0,1] brightpass
#define GR_Size 8 // step count for blur
#define GR_Skip 1 // skipping step counts in blur
#define GR_Alpha 1 //blending weight
also there is still room for optimization in the code.
no need to atan first and sincos later, vectors will work.
#define GR_Bright 0.8 //[0,1] brightpass
#define GR_Size 8 // step count for blur
#define GR_Skip 1 // skipping step counts in blur
#define GR_Alpha 1 //blending weight
also there is still room for optimization in the code.
no need to atan first and sincos later, vectors will work.
Please Log in or Create an account to join the conversation.
- 04348
Less
More
8 years 5 months ago - 8 years 5 months ago #9
by 04348
Replied by 04348 on topic Light Shafts + Tone Mapping?
Yes, it was more a proof of concept to see limitations involved by ReShade than a usable shader ^^
For optimisation, vector are far better than trigonometry but i didn't see a single fps drop between use of atan and only vertical ray without atan or vector so I didn't change it to vector
For optimisation, vector are far better than trigonometry but i didn't see a single fps drop between use of atan and only vertical ray without atan or vector so I didn't change it to vector
Last edit: 8 years 5 months ago by 04348.
The following user(s) said Thank You: kingeric1992
Please Log in or Create an account to join the conversation.
@04348:Do you have any sort of contact method? (Email, Steam)?
I usually have shaders i like to see ported and it would be cool to have another person to help me with them.
Also, thanks for the shader, it worked fine after kingeric posted the macros.
I usually have shaders i like to see ported and it would be cool to have another person to help me with them.
Also, thanks for the shader, it worked fine after kingeric posted the macros.
Please Log in or Create an account to join the conversation.
- 04348
Less
More
My Steam is 04348, I can try to help you but I have to warn you, I'm not very familiar with shader programming
Please Log in or Create an account to join the conversation.
8 years 5 months ago - 8 years 5 months ago #12
by matsilagi
Replied by matsilagi on topic Light Shafts + Tone Mapping?
Added, thanks a lot.
Lemme know when you get online.
Incase i added the wrong profile, just search for me, it isn't hard (Matsilagi2 is the id, Matsilagi is the steam name)
Lemme know when you get online.
Incase i added the wrong profile, just search for me, it isn't hard (Matsilagi2 is the id, Matsilagi is the steam name)
Last edit: 8 years 5 months ago by matsilagi.
Please Log in or Create an account to join the conversation.