How to set the 'size' of the waterFilter

Is there a way to make the size of the waterFilter-Ocean limited.



Something like.



filter.setOrigin(Vector3f.zero);

filter.setExpand(new Vector2f(1000,1000);



which would result in a ocean-plane with a scale of x=z=1000



greetz



ceiphren

It’s a screenspace effect, oyu need to use simplewater if you dont want it everywhere

hm I see. Well it was just for a decoration effect. So I’ll take another way.

Yep the’re right, there is no built in way.



Also if you feel like looking into the shader code, this can be added i guess.

No there isn’t

What’s the difference between Water.frag and Water15.frag?

aaaah, what have we here? A sweet little vec3 called position. Let’s see what we can do with that…

@nehon wrote the shader, I am sure he knows pretty well if it works or not :wink:

@nehon: I tried the following which seems to work:



vec4 main_multiSample(int sampleNum){



//… some awesome code…



if(position.x > 100 || position.z > 100 || position.x < -100 || position.z < -100) //the hundreds should be parameterized

{

return vec4(color2, 1.0);

}



// … more awesome code



My thoughts are: color2 is defined somewhere above and seems to be the incomming color which the post-effect is going to overwrite. So I checked the value of the vec3 ‘position’ and returned color2 without changing.



Could there be something I didn’t recognized?



Before this is going to be more a blog than a thread I’m off for tonight.^^



Good night everybody.

2 Likes

I do indeed :stuck_out_tongue:


@ceiphren said:
What's the difference between Water.frag and Water15.frag?

Water is for glsl1.0, Water15 is for glsl1.5 mostly to support multisampling.

@ceiphren said:
aaaah, what have we here? A sweet little vec3 called position. Let's see what we can do with that...

It's the position of the "pixel" in world space, it definitely what you need to check.
the idea would be to check the distance of this position and your origin and just return if the distance is above the limit.
But this will only give you a disc of water. For a square you need to check if the position is in the bounds

EDIT : that's it ;) well done!, maybe i could add it to the core...could be a nice feature

@nehon: well that would be really cool.



In my case I want to create a level-design that looks a little bit like a game board (like this one: ) but filled with water.



btw. is there a way to inherit shaders? (so that I don’t have to create a whole copy from water.j3md)

@ceiphren said:
btw. is there a way to inherit shaders? (so that I don't have to create a whole copy from water.j3md)

No there is no way.
I'll get your change into the water filter, but i have to change the branching to some step and clamp magic.

awesome :slight_smile:

I could use a similar feature. Is it possible to, instead of checking a bound coordinates, to check if the pixel is a certain Material (?)



For exemple, if you want two board games, both filled with water, it’s not possible with a single bound. But if you create two planes, and let the shader appear where those planes are, that would be awesome :slight_smile:

Not really afaik. The post processor works on the image that the renderer produces out of the scene, the material info is lost by then. But I might be wrong, maybe there is a way.

Well with a bit hacking you could create a 1bit stencil mask, that is rendered as 1 when the material is correct and as 0 when not (similar to the glow/bloom does work with a additional technique)

If this stencil is now set, do the water processing else just output the unmodified pixel.

No you’re right.



A way would be to send several set of parameters to the water filter and associate them to a bound.

This way you could have the same filter but you would be able to have several water area with different parameters side by side.

Like the sea, and a lake in the same picture… but that’s a huge change and IMO a lot of overhead on the GPU bandwidth for a very situational feature.

1 Like

Hey guys and @nehon ,



will this feature with position and extend be implemented in the core? Would be a very nice feature… Or something like a vec4 with upper left corner and lower right corner or sth,



Thx :slight_smile:

yeah I have to do this

2 Likes

ok it’s finally in the core.

you can set the center of the effect and a radius to define the area where the water should extend.

The nice side effect is that you can add several water filters to the scene with different sets of parameters.

I added a test case : TestMultiPostWater.java.

here are some screen shots



http://i.imgur.com/TZUV5.jpg

http://i.imgur.com/ObEqJ.png

http://i.imgur.com/5ihBc.png

http://i.imgur.com/IL4qp.png



of course you can also set different heights for the water pools

7 Likes