About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Water shaders and others similar to water behavior
Author Message
aceio76 Offline
Silver Supporter

Post: #1
Water shaders and others similar to water behavior
Hi guys,

Has anyone else here in the forum started to dabble with shaders, specifically making custom water-like effects? I'd like to share notes of observation and maybe learn a bit more about how shaders are done (programmed, etc).

Thanks,

www.thinkplaystudios.com
01-23-2012 01:00 AM
Visit this user's website Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #2
RE: Water shaders and others similar to water behavior
Hi Esenthel,

I'm a little confused with how SPSet() works when I have multiple custom shaders running on multiple materials and objects. How do you know you are setting values for a specific shader that applies to a specific object is going to get set? In the tutorial, it's easy to follow since you are running one custom shader applied to a specific material for a specific object. How is it handled if I have multiples of everything? Should the call for SPSet() be used by a custom Object that I know will use specific custom materials? Heh, even my question is confusing.

www.thinkplaystudios.com
01-23-2012 04:48 AM
Visit this user's website Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #3
RE: Water shaders and others similar to water behavior
There was some sort of tutorial about this. something alpha instancing and it only worked with drawBlend. I might be wrong tho and things might have changes.
We did a small refraction shader to replace the games water. Its pretty much for still water in tubs and etc.
It does the job and currently the ocean seems to be really heavy on framerate.
All and all I'm also having some difficulties working with EE shaders and just get something very crude done every now and then.
01-23-2012 01:17 PM
Find all posts by this user Quote this message in a reply
Demostenes Offline
Banned

Post: #4
RE: Water shaders and others similar to water behavior
Does anybody know, if terrain works as ocludor for ocean? Do I need to turn ocean off by script when I am not nearby coast?
01-23-2012 02:37 PM
Find all posts by this user Quote this message in a reply
Abril Offline
Member

Post: #5
RE: Water shaders and others similar to water behavior
(01-23-2012 02:37 PM)Demostenes Wrote:  Does anybody know, if terrain works as ocludor for ocean? Do I need to turn ocean off by script when I am not nearby coast?

Turn on wireframe and see yourself... (Answer: no terrain doesn't occlude the ocean ) try disabling water reflection maybe this is the performance heavy part...
(This post was last modified: 01-23-2012 05:15 PM by Abril.)
01-23-2012 02:52 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #6
RE: Water shaders and others similar to water behavior
Also I noticed something strange.
I used the world editor environment settings in a test game.
When I had textures set on the ocean but did not have ocean enabled it still dropped framerate from 300->50ish
If I removed the ocean textures from their slots in the env settings editor it pushed back up.
01-23-2012 04:04 PM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #7
RE: Water shaders and others similar to water behavior
(01-23-2012 04:04 PM)b1s Wrote:  Also I noticed something strange.
I used the world editor environment settings in a test game.
When I had textures set on the ocean but did not have ocean enabled it still dropped framerate from 300->50ish
If I removed the ocean textures from their slots in the env settings editor it pushed back up.

This is strange indeed. I wonder if it behaves like that ingame...

www.thinkplaystudios.com
01-23-2012 04:08 PM
Visit this user's website Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #8
RE: Water shaders and others similar to water behavior
I have in the test game also those same environment setting things enabled and yes it did behave like that.
01-23-2012 04:29 PM
Find all posts by this user Quote this message in a reply
Demostenes Offline
Banned

Post: #9
RE: Water shaders and others similar to water behavior
(01-23-2012 02:52 PM)Abril Wrote:  Turn on wireframe and see yourself... (Answer: no terrain doesn't occlude the ocean ) try disabling water reflection maybe this is the performance heavy part...

Well, only solution is to turn off ocean when you are further from the coast....Having ocean with active refraction under terrain is not good idea.
01-23-2012 07:33 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #10
RE: Water shaders and others similar to water behavior
(01-23-2012 02:52 PM)Abril Wrote:  
(01-23-2012 02:37 PM)Demostenes Wrote:  Does anybody know, if terrain works as ocludor for ocean? Do I need to turn ocean off by script when I am not nearby coast?

Turn on wireframe and see yourself... (Answer: no terrain doesn't occlude the ocean ) try disabling water reflection maybe this is the performance heavy part...

That's becuase EE does not use horizon occlusion culling, which is surprising as it is a very old and easy technique to implement.

http://www.ceng.metu.edu.tr/courses/ceng...rYalim.pdf

Scroll down to the 5th page of the PDF and look at the pics... explains everything. This technique could also be used to stop rendering the water as well as terrain areas that are not in view.
01-24-2012 12:24 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #11
RE: Water shaders and others similar to water behavior
(01-23-2012 04:48 AM)aceio76 Wrote:  Hi Esenthel,

I'm a little confused with how SPSet() works when I have multiple custom shaders running on multiple materials and objects. How do you know you are setting values for a specific shader that applies to a specific object is going to get set? In the tutorial, it's easy to follow since you are running one custom shader applied to a specific material for a specific object. How is it handled if I have multiples of everything? Should the call for SPSet() be used by a custom Object that I know will use specific custom materials? Heh, even my question is confusing.
there is tutorial for that like b1s said, in the custom shaders folder.

this can be done only for blended objects (because blended meshes can be drawn instantly-immediately at the draw call)

while solid objects are added to the draw list and rendered by the engine later in order adjusted by the engine

if you need this in solid:
-instead of SPSet you can try encoding some custom parameters in the Material, use different material for objects
-create a few copies of the shader (each using different shader parameter, and modify them using SPSet)
-other options would need to be added as feature request to the engine (for example immediate solid drawing, and not by adding to the draw list)
01-24-2012 11:48 AM
Find all posts by this user Quote this message in a reply
Demostenes Offline
Banned

Post: #12
RE: Water shaders and others similar to water behavior
(01-24-2012 12:24 AM)fatcoder Wrote:  That's becuase EE does not use horizon occlusion culling, which is surprising as it is a very old and easy technique to implement.

No? I am surprised. Anybody tried custom implementation? For open world such technique can help a lot, especially for ocluding other meshes (mesh rocks, houses, trees.....).
(This post was last modified: 01-25-2012 12:12 AM by Demostenes.)
01-25-2012 12:08 AM
Find all posts by this user Quote this message in a reply
Post Reply