Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, RealSerious3D, BrainSailor), 1,265 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Reflecting and refracting water [Re: Scorpion] #218814
07/30/08 18:41
07/30/08 18:41
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Nice UC, pretty handy yes smile smile
When looking at a water shader, their are 2 things I immediatly look at since they are quite important for a proper water shader:

- Fresnel term
- lerp function

1) Regarding Fresnel, the function you used isn't fully correct although it is an approximated version but abit rough wink wink
This is a better approximated version of the Fresnel term:

// Schlick's approximation, accurate to within 1% ^^
const float FRI = 0.01f; // FRI is the Fresnel reflectance index of the material at normal incidence
float F = FRI + (1 - FRI) * pow((1 - N.V), 5.0f);

Important note is that this function is mostly used for outdoor scenes but it would fail in indoor games. The reason therefore is that attenuation is used for indoor light sources.

2) Regarding the lerp function, it's better to combine your color calculations within the pixel shader via lerp. Look at the beaty of the methode:

lerp(a,b,c)
// returns a + c.(b-c)
// when c = 0, a will get returned
// when c = 1, b will get returned

Thus when using this as a final calculation with water, you should input the corresponding parameters relative for a water shader to achieved a plausible output:

color = lerp(reflectColor,refractColor,F);

Not that your code was ineffective since the effect looks pretty nice but just to enhance the importance of little intrinsic functions smile smile

Thanks in progress

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Reflecting and refracting water [Re: frazzle] #218825
07/30/08 20:14
07/30/08 20:14
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline
Serious User
jigalypuff  Offline
Serious User

Joined: Nov 2005
Posts: 1,007
getting a can`t load dll, it`s the render to texture one?


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: Reflecting and refracting water [Re: Scorpion] #222035
08/17/08 18:07
08/17/08 18:07
Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
Roel Offline OP
Senior Member
Roel  Offline OP
Senior Member

Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
I improved the shader, you can download it here:
Download


Check out the throwing game here: The throwing game
Re: Reflecting and refracting water [Re: Scorpion] #222485
08/19/08 16:38
08/19/08 16:38
Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
Roel Offline OP
Senior Member
Roel  Offline OP
Senior Member

Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
I've taken the lerp function into the shader, thanks! smile

and yes, it is the render2texture dll. I do not have pro edition, and many other gstudio users either

about the fresnel, You are right, but I wanted to use the shader in indoor scenes too!

Last edited by Roel; 08/19/08 16:40.

Check out the throwing game here: The throwing game
Page 2 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1