(GTA 4) How to disable sun shafts(godrays) at night?

  • Author
  • Message
Offline
Posts: 4
Joined: 04 Jan 2017, 00:38

(GTA 4) How to disable sun shafts(godrays) at night?

Hello everyone, I'm glad to be on the board of this web.
I know or maybe most of you don't pay attention to this game, but I still and I need some help.
Thanks in advance to everyone!

So this's my problem:
Finally I made the godrays that i wanted, with correct shafts, they follow camera position+sun position, colors, etc...:

Image

Everything is fine, but they are visible at night 22:00; 3:00; 4:00-5.00:

Image

God rays code is located in enbeffect.fx, in enbseries.ini I dont use [SKY] (Enable=false), I use only clouds(CloudsUseCustomTexture=true), with vanilla sky and timecyc.dat editing I have more options.
Enb version is 0.163.

My Question is, How to disable them at night!!???

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: (GTA 4) How to disable sun shafts(godrays) at night?

Sorry, there is no time of the day separation in the mod for gta4, so i don't know any trick to cut off rays in night. And i don't want to touch this game any more, it's abandoned by players and most modders now.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
Posts: 4
Joined: 04 Jan 2017, 00:38

Re: (GTA 4) How to disable sun shafts(godrays) at night?

Thanks for the reply!!!
It's a bit of sadness, that is abandoned, to me this's one of the greatest game ever made.
I don't wanna be presuming or like a crying baby for a toy.

I want to ask one more thing, I use these sun coordinates:

float2 sundir=SunDirection.xy/SunDirection.w;//.w !=0. It negative when sun is on back side
float2 uvpos=IN.txcoord0.xy*2.0-1.0;
uvpos.y=-uvpos.y;
sundir.xy=(uvpos.xy-sundir.xy);
sundir.y*=ScreenSize.w;
float sunvis=dot(sundir.xy, sundir.xy);
sunvis=saturate(1-pow(sunvis, 0.1))*10;//pow(tempF1.x, 16);
if (SunDirection.w<0.0) sunvis=0.0;
_oC0.xyz+=sunvis

With these coordinates the sun is negative(invisible) on back side, I was thinking that there is a some simple coordinates (code) but away from my knowledge that make negative on down side.
Anyway, if you want or if you don't want to reply, I understand.
Thanks!

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: (GTA 4) How to disable sun shafts(godrays) at night?

That's screen stransformed vector, not world space, so without camera vectors it's useless to detect if sun if below the horizon.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
Posts: 4
Joined: 04 Jan 2017, 00:38

Re: (GTA 4) How to disable sun shafts(godrays) at night?

Thanks for the reply!

I understood how to stop them at night.

Now I want to stop this:

Image
Image

I think that this's shafts or samples (NUM_SAMPLES) when they pass through the el. lights :x :?:

Thanks!!!

[youtube]watch?v=e83RmjihIt4&t=1s[/youtube]

Offline
User avatar
*master*
Posts: 136
Joined: 08 Nov 2012, 15:24

Re: (GTA 4) How to disable sun shafts(godrays) at night?

A method I saw for correcting that problem was to not do a blur from the sun position in the image, but rather have a separate "sun glow" which was just the colour of the light shafts/sun, and display it according to the mask created from a radial blur of the depth buffer. I don't know how much you have access to in your shader, though, so that might not be applicable.

Offline
User avatar
*master*
Posts: 119
Joined: 05 Jan 2012, 22:34
Location: France

Re: (GTA 4) How to disable sun shafts(godrays) at night?

It's either you decrease the power of the "shafts" depending of their position, or you clamp it.
1st method should be better. You don't want full brightness of your shafts at 6am

Offline
Posts: 4
Joined: 04 Jan 2017, 00:38

Re: (GTA 4) How to disable sun shafts(godrays) at night?

After many tests, I succeeded to stop the shafts at nights, there is still some light samples but almost invisible.
Now (from months) I'm trying to calculate vertical (Y axis) center of the rays.
I already know how to do that but not at all in game hours, if a I make correct Y position (center) when is sunrise, sunset (horizon position of the sun) then when is midday, 9:00 or 18:00 o'clock the Y position (center) is still below from the sun and reverse if the Y center is correct at 9:00, midday and 18:00 o'clock then when is sunrise, sunset (horizon position of the sun) the shafts center will be above the sun :(

This picture is example when Y position is not correct at sunrise, sunset:
https://photouploads.com/images/1e7e24.jpg

Here the sun is on the ground but the shafts center is already above the sun.

Here is the code that I've made with descriptions:

float2 sundir=SunDirection.xy/SunDirection.w;//.w !=0. It negative when sun is on back side
float sunvis=(sundir.xy*-0.455); // X visibility of the shafts
sunvis=saturate((0.25-sundir.y*0.222)-pow(sunvis, 4.9))*0.153; // color and power and vertical visibility of the shafts
if (SunDirection.w<0.0) sunvis=0.0; //No shafts from the back side of the sky dome
_oC0.xyz+=sunvis;
float2 sunpos = 0.5; //X position of the shafts
float2 _v1 = 0;
float maxi = 0;
int count = 0;
float4 ratio = 0.081; //Power and X position of the shafts
float deltax = 0.37 / ratio; //Power of the shafts
int samplex = 25 * ratio; // X position

for(int i = 1; i <= 25; i++)
{
for(int j = 1; j <= samplex; j++)
{

r3 = tex2D(s2, _v1.xy);
r2.x = saturate(cross(r5.xyz, 0.003) - 10.0);

if((r5.x >= maxi) && r5.x)
{
maxi = r5.x;
sunpos.x += _v1.x*0.5; //X position
sunpos.y += _v1.y*0.5; //Y position, but not the center
count ++;
}
_v1.xy = sundir.xy; //Like this, the shafts will not move when you horizontally move the mouse(camera)
}

_v1.x = (2.11 + sundir.x); //X center
_v1.y *= (0.5+0.5)*ScreenSize.w; //Like this, the shafts will not move when you vertically move the mouse(camera)
}

if(sunvis) sunpos.xy /= count--;

float4 color;
r11=r0 + r11;

float2 ScreenLightPos;

ScreenLightPos.x = sunpos.x; //X position
ScreenLightPos.y = (sunpos.y*0.5+0.089)-_v1.y; //Now here if +0.089 is bigger, like +0.3; +0.4, Y Center will be correct at sunset, sunrise and incorrect at daytime and reverse

float2 texCoord = _v0; //Shafts, HDR
float2 deltaTexCoord = (texCoord.xy - ScreenLightPos.xy);

deltaTexCoord *= ScreenSize.w / NUM_SAMPLES * Density;

float4 Bloom_Sun;
Bloom_Sun=(Bloom_Amount*8.5)/deltax;

if(maxi)
{

for(int x = 0; x < NUM_SAMPLES; x++)
{
texCoord -= deltaTexCoord;
float4 sample = tex2D(s0, texCoord.xy);
if(sample.w) sample.xyz = 0.0;
else
{
sample = tex2D(s2, texCoord.xy);
sample.w = saturate(dot(sample.xyz*0.5, 0.4444+sunvis) - 2); // Like this and my timecyc.dat Godrays will stop at 21:00 and start at 5:40
if(sample.w == 0) sample.xyz = 0.0;
sample.r *= GodRays_Color_R;
sample.g *= GodRays_Color_G;
sample.b *= GodRays_Color_B;
}

sample *= Bloom_Sun*sunvis;
r11 += sample;
sunvis *= Decay;
}
}

r11 *= Exposure;


I'll be so glad if someone can help me!
Thanks in advance!!!

Offline
Posts: 6
Joined: 07 Jan 2024, 23:19

Re: (GTA 4) How to disable sun shafts(godrays) at night?

ENBSeries wrote: 04 Jan 2017, 22:56 Sorry, there is no time of the day separation in the mod for gta4, so i don't know any trick to cut off rays in night. And i don't want to touch this game any more, it's abandoned by players and most modders now.
Hello, I was looking in the request topic and thought since GTA4 was mentioned here and there, it's better to reply on an existing topic regarding IV than to make a new one. Especially since initially ENB does exist for GTA 4.

Here you are stating that gta 4 is abandoned by players and most modders, but it seems that lately especially in 2023 there has been a (dramatic) reversal. I'm talking about new multiplayer community mods such as CitizenMP (now discontinued in favor of HMP which is in development to work with latest version of GTA4 CE) and GTA Connected which works right now as we speak with players regularly playing and daily. That's the player aspect tackled, now the modding which is equally if not more impressive with the likes of Fusionfix being one of the biggest and best mod for the game which brought MANY fixes and improvements to the game.

Unfortunately because Fusionfix has fixed many things that required shader and other changes, like fixing Z-fighting and added many new things into the game which it initially did not have, it is now not compatible with ENB anymore. So my question or request (what you like to call it) is if you can restart/resume ENB for GTA4 considering it's well alive and not just a "dead popular game". The modding community hasn't been this active and huge in a long while, arguably ever. Until now.

The game can now be quite stable performance wise if you have a regular pc (no longer need 2008 NASA computer) and use DXVK, making butterysmooth gameplay possible while having the game maxed out including draw and detail distance. Add the magic of Fusionfix and you have the best port of the game, no longer do you need console versions to have the "best" version.

I think since your absence on the game you will be surprised how much better the fixes and stuff from the community has made the game better than before, if you would give it a try hopefully. :)

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: (GTA 4) How to disable sun shafts(godrays) at night?

You did say enbseries incompatible with some new mod. Then why do you ask enbseries to be developed again, if it will be incompatible anyway? I will not develop mod for another mod.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
Post Reply