Jump to content

Photo

[WIPz/RELz] Sun shaft rays


  • Please log in to reply
187 replies to this topic

#1
phal

phal
  • Members
  • Adept
  • Joined: 04-April 09
  • 246 posts
  • Location:Germany
This is a shader adding sun rays to the sun, as seen in Far Cry 2, Crisis etc.

First of all, you need MGE SVN rev118.

The shader is available here. (v0.02a)

Edit:
If you have changed your Field of View (FOV) via MW FPS Enhancer or any other tool, you will need to open the shader fx file with a text editor and find the line '#define fov 75'. Change the 75 to the exact FOV setting you use. Otherwise the sun movement on the screen will not fit to the rest of the screen.

Screens:
1 2 3 4 5 6

Personally, I think this shader makes MW's sunglare obsolete, so I have included a completely transparent sunglare texture in the zip file to get rid of it. It will still work if you keep the sunglare, though it may look too bright and kinda strange when MW's sunglare keeps popping in.
This shader should be placed before bloom in the active shader list, to make bloom work on the sun rays. I have included some tweakable values at the top of the shader file, so you can adjust the shader parameters to your likings. I've also tried to describe what each parameter does. I have found that the strength of the bloom shader you use has a great effect on sunray brightness, so you may need to adjust the 'raystrength' variable to prevent overblooming.

Edit:
Updated to v0.02a

Edited by phal, 10 October 2009 - 02:34 AM.


#2
sasuke21

sasuke21
  • Members
  • Adept
  • Joined: 30-October 07
  • 351 posts
so, this is some kind of god rays right?

#3
phal

phal
  • Members
  • Adept
  • Joined: 04-April 09
  • 246 posts
  • Location:Germany

so, this is some kind of god rays right?

Yes, but it's a completely different algorithm than vtastek's godrays.

#4
sasuke21

sasuke21
  • Members
  • Adept
  • Joined: 30-October 07
  • 351 posts
great, I'll be sure to try this out, but does this replace the sun glare completely so that no sun replacer is required?

#5
SpectaclesOfDoom

SpectaclesOfDoom
  • Members
  • Acolyte
  • Joined: 15-May 08
  • 177 posts
Oooh, subtle. Very nice. I might actually have to use MGE now. (I was avoiding it like the plague before...)

#6
Marbred

Marbred
  • Members
  • PipPipPip
  • Diviner
  • Joined: 21-March 04
  • 3660 posts
  • Location:Paper st.
:o
that looks amazing.

#7
Eevv

Eevv
  • Members
  • Acolyte
  • Joined: 21-September 06
  • 163 posts
heh... and I thought crysis looked good back in the day :/

#8
vtastek

vtastek
  • Members
  • PipPipPip
  • Diviner
  • Joined: 30-July 08
  • 4767 posts
  • Location:Different places
This makes mine obsolete. <_< I like this because I don't like the original sun. Finally a sun with actual colors.

I noticed a couple of things. It is a little slow in my end, and sunglare seems to be still there somehow. I will edit the ini to completely disable it. I saw the original sun around sunset hours. It was a little shifted to left-bottom corner. But it is not important, I guess we can paint the sun texture to transparent too.

I was leeching your sunposition codes, I think I should be updating mine with your codes again, so if anyone left using mine could benefit it..

Edited by vtastek, 05 September 2009 - 05:24 AM.


#9
matilija

matilija
  • Members
  • PipPip
  • Disciple
  • Joined: 12-February 09
  • 1339 posts
  • Location:Illinois
Very nice Phal, I like it, subtle, speedy, and just good! :P

Don't worry Vtastek, I liked yours too, I'm only using this one because of the strange blue hue I get at certain angles from the sun with yours.

Besides, 2 months ago this seemed like an impossible dream, now there are not one, but 2 options that make it a reality!

#10
Alaisiagae

Alaisiagae
  • Members
  • PipPipPipPipPip
  • Patriarch
  • Joined: 27-December 07
  • 13252 posts
  • Location:Cloudsdale
Beautiful! :wub:

@vtastek: More choice is always a good thing, don't be discouraged and/or abandon your project. :hugs:

#11
Judassem

Judassem
  • Members
  • Adept
  • Joined: 05-September 08
  • 247 posts
  • Location:Somewhere in the warm Mediterranean
Hi!

I took some screenshots with this wonderful shader. Here there are*:

1
2
3
4
5 (I also use Linora's Mystical Underwater Effects shader)

I also saw some problems:

At 7 P.M. (It's always like this at 7 P.M. Maybe it was intentional but the sun seems too whitish)
Greyed out a little bit too much (Actually, I'm not sure whether this is a problem or not. If you position the sun in center top of the screen, and in some other specific angles, the screen gets greyed out a little. It's also realistic, though; in real world, when you look at the sun, and then turn your eyes to somewhere else, the colors seem to fade for a while.)

This is definitely a must-have. I expected some more critical bugs as it's still a WIP, but it seems flawless except for the white sun issue; and I can more than take it for the overall beauty :)

*I used an edited version (bloomscale set to 8 instead of 2) of HLSL HDR 2 shader together with this shader (the order is 1)sun shaft 2) HDR). I also deleted my previous sunglare textures before using this (I was using the sunglare textures from SWG's Skies v.2) and used the texture provided with this shader.

#12
phal

phal
  • Members
  • Adept
  • Joined: 04-April 09
  • 246 posts
  • Location:Germany

Hi!

I took some screenshots with this wonderful shader. Here there are*:

1
2
3
4
5 (I also use Linora's Mystical Underwater Effects shader)

I also saw some problems:

At 7 P.M. (It's always like this at 7 P.M. Maybe it was intentional but the sun seems too whitish)
Greyed out a little bit too much (Actually, I'm not sure whether this is a problem or not. If you position the sun in center top of the screen, and in some other specific angles, the screen gets greyed out a little. It's also realistic, though; in real world, when you look at the sun, and then turn your eyes to somewhere else, the colors seem to fade for a while.)

This is definitely a must-have. I expected some more critical bugs as it's still a WIP, but it seems flawless except for the white sun issue; and I can more than take it for the overall beauty :)

*I used an edited version (bloomscale set to 8 instead of 2) of HLSL HDR 2 shader together with this shader (the order is 1)sun shaft 2) HDR). I also deleted my previous sunglare textures before using this (I was using the sunglare textures from SWG's Skies v.2) and used the texture provided with this shader.

The greying could be an effect of the HDR shader, that decreases overall brightness when screen gets very bright. Maybe you could try and see if this still occurs without or with another HDR shader.
But you're right with sun being too whitish at late evening. This could be fixed by making sun disappear earlier at evening, before sun colour changes to its night value, which is blueish. You could easily do that by replacing
static const float light = (1-pow(1-saturate(sunvis*2),2));
with
static const float light = sunvis;
But this will make sunrays less strong at evening. Gotta find a good balance there.

#13
Judassem

Judassem
  • Members
  • Adept
  • Joined: 05-September 08
  • 247 posts
  • Location:Somewhere in the warm Mediterranean

The greying could be an effect of the HDR shader, that decreases overall brightness when screen gets very bright. Maybe you could try and see if this still occurs without or with another HDR shader.
But you're right with sun being too whitish at late evening. This could be fixed by making sun disappear earlier at evening, before sun colour changes to its night value, which is blueish. You could easily do that by replacing

static const float light = (1-pow(1-saturate(sunvis*2),2));
with
static const float light = sunvis;
But this will make sunrays less strong at evening. Gotta find a good balance there.


I think I'll keep it that way. I'll just imagine that Vvardenfell turns into Silent Hill for an hour each day, at 7 P.M. :P

I'll edit this post after I try your shader with/without other shaders.
Edit: Weird, but the greying issue didn't happen again, neither with other shaders, nor with HDR 2 shader. It was a discrete issue, I think; nothing general.

Edited by Judassem, 05 September 2009 - 11:32 AM.


#14
MojoBox

MojoBox
  • Members
  • Adept
  • Joined: 09-March 06
  • 260 posts
Wow, fantastic work, looks gorgeous!

http://i11.photobuck...ox/pretty-1.jpg

Using it along with DoF and a tweaked TruBloom g6 :D

#15
phal

phal
  • Members
  • Adept
  • Joined: 04-April 09
  • 246 posts
  • Location:Germany
Small update. I have simplified the iteration code, which should improve performance a bit. I also changed it so that the sun disc will not be drawn when underwater, which always looked a bit strange because sun colour then changes to light blue. I also modified the tweakable variables a bit, so feel free to modify them to your wishes ;)

Newest (0.01a) version: link

Edited by phal, 06 September 2009 - 08:58 AM.


#16
Syv

Syv
  • Members
  • PipPip
  • Disciple
  • Joined: 19-January 06
  • 1427 posts
Sun seems a bit off

Granted I have the black sun issue (the above is a better alternative nontheless), but would that interfere?

Edit: I loaded a different character of mine which is just off the boat (the month of last seed ) and the sun shines perfectly.

This is however not true for my main character (in the month of frost fall, some 50 days ahead) - see the sun in the first link and yet another pic.

I found this pretty weird.

On a side note. I first discovered this when I wondered why my main had no moons at night anymore. The moons actually have phases then:

Jonric: What are the main elements of the weather system in Morrowind that you are supporting in the game engine?

Todd Howard: The major elements are the clouds, sun, and moons. I guess that sounds obvious. The cloud layer has levels of transparency, and areas the sun can shine through, as well as the ability to transform between more clouds, less, overcast, rainy, etc. The sun lights the world and has the ability to shine through the cloud layer, so you get very realistic light levels and shadows. Lastly the moons have phases and times they are in the sky to complete the effect.


Funny to see the season actually affecting the brightness of the sun though (assuming everything's working correctly).

Edit 2: My above assumption regarding the sun is wrong. Actually my other characters has the same (blinded by sun) effect regardless of weather (and season).

Why this don't hold true for my main character I wouldn't know. However I'd appreciate a reply if anyone have an idea on the issue.

(yes, I'm using this mod - without sunglare)

Edited by Syv, 07 September 2009 - 09:39 PM.


#17
lettuceman44

lettuceman44
  • Members
  • Pip
  • Curate
  • Joined: 02-December 08
  • 641 posts
I now use this without sunglare, and its awesome!

#18
phal

phal
  • Members
  • Adept
  • Joined: 04-April 09
  • 246 posts
  • Location:Germany

snip

These problems don't seem to be related to the shader. But I have experienced that certain clothing meshes seem to disable the sun glare (maybe even moons). You could try unequipping everything and see if the sun glare re-appears.

The black sun issue should not have any effect on the shader though, as it is a texture issue, while the shader does not use any textures at all.
However, your pictures look like the shader is not used at all. Have you installed the custom d3d8.dll file (see first post)? You also need to add the shader to your active shader list (MGEgui.exe -> Tools -> Shader editor -> Edit active -> double-click on sunshaft_v001a -> Save).

I'm not sure what causes the screen brightening to be visible even with cloudy weather, but a possible fix could be editing your Morrowind.ini file and changing the 'Sun Glare Fader Max' value to 0. This will however completely disable the screen brightening.

#19
Syv

Syv
  • Members
  • PipPip
  • Disciple
  • Joined: 19-January 06
  • 1427 posts

Snip


Thanks for the reply. I tried your suggestion regarding the sun glare, and you're right. Undressing the enchanted "Magickguard robe" enabled the sun glare for my main (pretty weird).

I'm new to shaders, and I was just about to say that I did follow this guide (as well as installing the mod correctly). Seems I forgot to tick "update shader variables" in MGE (HDR were already ticked, unnecessarily so I suppose) which gave me a markedly different result than what I had.

It seems to be working correctly then. Wonderful mod by the way :D

Edit: Oops I spoke too soon, now the sun is present in all types of weather - from ash storms to rain and lightning.

I did download and (clean) install the latest MGE (mge3.8-SVN_rev-0117) though strangely enough the version number in its gui shows "mge3.8.0-SVN_rev-116" :blink:

I also replaced the d3d8.dll with the one provided in this thread.

Edit 2: Yes, present even after undressing :shrug:

Btw, this is the only shader currently in the active shader list.


To summarize. With everything (seemingly) installed correctly the sun shader only works with "update shader variables" activated, however this enables the sun at all times regardless of weather.

Edited by Syv, 08 September 2009 - 08:35 AM.


#20
Guest_Greendogo_*

Guest_Greendogo_*
  • Guests

Edit: Oops I spoke too soon, now the sun is present in all types of weather - from ash storms to rain and lightning.

That's actually a pretty interesting effect on the ash storm. Makes it look like the ash in the air is like a light fog. The bright sun gets through, but nothing else.

#21
starwarsgal9875

starwarsgal9875
  • Members
  • PipPipPipPip
  • Master
  • Joined: 03-September 08
  • 5762 posts
  • Location:Ottawa, Canada

Edit: Oops I spoke too soon, now the sun is present in all types of weather - from ash storms to rain and lightning.

:bolt: OH MY GOODNESS! That's awesome! And it gives me a fantastic idea too, time to go mess with my INI some more. :D

#22
Syv

Syv
  • Members
  • PipPip
  • Disciple
  • Joined: 19-January 06
  • 1427 posts
Hehe, creativity spawned. Glad you like it, but does anyone have an idea on the (for some of us =P ) issue?

#23
DesertRat

DesertRat
  • Members
  • Adept
  • Joined: 12-August 06
  • 304 posts
  • Location:Desert

Thanks for the reply. I tried your suggestion regarding the sun glare, and you're right. Undressing the enchanted "Magickguard robe" enabled the sun glare for my main (pretty weird).

I'm new to shaders, and I was just about to say that I did follow this guide (as well as installing the mod correctly). Seems I forgot to tick "update shader variables" in MGE (HDR were already ticked, unnecessarily so I suppose) which gave me a markedly different result than what I had.

It seems to be working correctly then. Wonderful mod by the way :D


What type of hardware are you running to get those frame rates. I have a Q6600 and a GT8800 1GB and only get ~ 17FPS in the same area. Enabling hardware shader gives my machine a big hit even if I have not shaders active. Any idea on what causes this hit. It it the passing of shader variables?

#24
KenR7A

KenR7A
  • Members
  • Adept
  • Joined: 22-March 06
  • 290 posts
Beautiful stuff here. You dont even see these kinds of things in modern day games.

#25
Syv

Syv
  • Members
  • PipPip
  • Disciple
  • Joined: 19-January 06
  • 1427 posts

What type of hardware are you running to get those frame rates. I have a Q6600 and a GT8800 1GB and only get ~ 17FPS in the same area. Enabling hardware shader gives my machine a big hit even if I have not shaders active. Any idea on what causes this hit. It it the passing of shader variables?


E8500/4GB ram/ Radeon HD 4870 (512MB)

To quote myself:

To summarize. With everything (seemingly) installed correctly the sun shader only works with "update shader variables" activated, however this enables the sun at all times regardless of weather.


Any ideas on the issue?

#26
vtastek

vtastek
  • Members
  • PipPipPip
  • Diviner
  • Joined: 30-July 08
  • 4767 posts
  • Location:Different places

E8500/4GB ram/ Radeon HD 4870 (512MB)

OT: A grand example of CPU power oriented Morrowind performance benchmark. E8500 can be overclock up to 4.2 GHz easily. With a price tag of 2xx$, it is definitely a super processor(for Morrowind). I want one.
http://www.neoseeker...l_e8500/11.html

BOT:
It seems you need shader variables for sunshaft shader. Which isn't a surprise. Phal released an update for sun visibility(check MGE thread), maybe that could help your issue. And 116 number on MGEgui, don't worry about it, developers sometimes forget to update it, because most developments are on d3d8.dll.

#27
Syv

Syv
  • Members
  • PipPip
  • Disciple
  • Joined: 19-January 06
  • 1427 posts

BOT:
It seems you need shader variables for sunshaft shader. Which isn't a surprise. Phal released an update for sun visibility(check MGE thread), maybe that could help your issue. And 116 number on MGEgui, don't worry about it, developers sometimes forget to update it, because most developments are on d3d8.dll.


I downloaded the newest d3d8 (sundir v3) but to no avail. The sun is still visible at all times through clouds and weather.

#28
Syv

Syv
  • Members
  • PipPip
  • Disciple
  • Joined: 19-January 06
  • 1427 posts
A small bump for a good mod and my still ongoing problem:

To summarize. With everything (seemingly) installed correctly the sun shader only works with "update shader variables" activated, however this enables the sun at all times regardless of weather.


You guys probably know more about this than I, so any help available is much appreciated :)

#29
phal

phal
  • Members
  • Adept
  • Joined: 04-April 09
  • 246 posts
  • Location:Germany

You guys probably know more about this than I, so any help available is much appreciated :)

The only thing I could imagine causing this would be strange morrowind.ini settings. Open your morrowind.ini and check if the 'Glare View' parameter under each '[Weather ...]' section is set to something lower than 1. This value determines the sun visibility passed to the shaders, if it is set to a low value, the sun rays should be very weak or vanish completely for the corresponding weather.
Other than that, you can only make sure to use the latest version of my d3d8.dll. Don't know what else could be wrong :/

#30
peachykeen

peachykeen
  • Members
  • PipPipPip
  • Diviner
  • Joined: 16-September 05
  • 4262 posts
  • Location:just out of focus with a subtle bloom effect
Also, you have to have shader vars on because it needs to be able to know where the sun is.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users