tcGen environment liquid issue


(Wezelkrozum) #1

I’ve created a watersurface for my featured map. And to make it look more realistic I want to give it a reflection of the sun. However, my reflection is mirrored in the y-ax of the texture. In other words: I can see the sun at the west-side reflecting in the watersurface, but I can also see the sun reflecting at the east-side of the water.

This is my shader:


textures/terrain_dm_castle/water
{
 qer_editorimage textures/terrain_dm_castle/water1.tga
 qer_trans .5
 q3map_globaltexture
 surfaceparm trans
 surfaceparm nonsolid
 surfaceparm water
 surfaceparm nomarks
 cull none
 nopicmip
 nomipmap
 nofog
 deformVertexes wave 160 sin 0 2 0 0.3
 q3map_tcMod rotate 20
 {
  map textures/terrain_dm_castle/water3.tga
  blendFunc blend
  alphaFunc GT0
  rgbGen identity
  rgbGen wave sin .2 .8 .5 0
  tcmod turb .01 .05 .25 .1
  tcmod scale 1.4 1.5
  tcmod scroll -.018 .002
 }
 {
  map textures/terrain_dm_castle/water2.tga
  detail
  blendFunc blend
  alphaFunc GT0
  rgbGen identity
  rgbGen wave sin .4 .6 .6 0
  tcmod turb .01 .05 0 .1
  tcmod scale 0.4 0.4
  tcmod scroll .02 -.001
 }
 {
  map textures/terrain_dm_castle/water_ref.tga //reflection (bug)
  blendFunc GL_ONE GL_ONE
  rgbGen vertex
  tcGen environment
  tcMod scale 1 2
 }
}

Additional information:
I use deformvertex but without deformvertex the problem stays.
I use tcMod scale 1 2 so you can see the sunreflection. Else it was to far from view of the player and you couldn’t see the sun. I tested the shader without this value but the problem stays.

It looks like the shader breaks the texture into 2 parts mirrored from each other. This means I can see the left part of my texture, where the sun shines, but that the other half without the sun isn’t show in the water.

Does anyone has the problem before or know how the fix it?


(Max1) #2

Hey,

Maybe you could try to solve the problem a bit different. I’d suggest to try a portal camera this way:

When the player is on the a) side he will see the reflection shader through the portal surface.

When the player is on the b) side he will just see the water cause the walls are black.

Heres a suggestion for the portal shader:

textures/your_map/portal
{
qer_editorimage textures/editorimages/portal.jpg
surfaceparm nolightmap
surfaceparm nomarks
surfaceparm trans
portal
{
map $whiteimage
blendFunc GL_ONE GL_ONE_MINUS_SRC_ALPHA
rgbGen const ( 0.0 0.0 0.0 )
depthWrite
alphaGen portal 4096
}
}

The portal surface should be extended across the whole water plane, so you dont see any edges or something. And if you take the portal shader from above be sure to render the water above the portal surface.

I didn’t test that myself, but it might be worth a try.

Best Regards

Max1


(ailmanki) #3

I think the only way to make it look correct from every perspective is using a mirror…
but deformvertex does not play well with portals…

But this is quite an interesting aproach…

You say it breaks your texture into 2 and uses it wrongly? Unsure, but maybe modifying your texture like that, could fix it (check attachement pic).
Also it might help to create a image which has a pattern, and use that for tcgen environemnt, to see how it gets distorted and used.

edit: tesselation does also affect it and tcmod scale…


(Wezelkrozum) #4

[quote=ailmanki;203929]I think the only way to make it look correct from every perspective is using a mirror…
but deformvertex does not play well with portals…

But this is quite an interesting aproach…

You say it breaks your texture into 2 and uses it wrongly? Unsure, but maybe modifying your texture like that, could fix it (check attachement pic).
Also it might help to create a image which has a pattern, and use that for tcgen environemnt, to see how it gets distorted and used.
[/quote]

I’ve broken my environment image into 2 parts like your attachment but it shows me only one half of the environment image and mirrors that one also at the other side of the texture. Its like >< in stead of >-

[quote=ailmanki;203929]
edit: tesselation does also affect it and tcmod scale…[/quote]

Yes, I know. But without those values the same problem is still there.


(stealth6) #5

make another brush just under the water as a mirror?


(Wezelkrozum) #6

Since I use deformvertex it will look ugly if the wave is under or overleaping the mirror. And it eats fps which are already at it’s critical minimum.

The only way to get this right is with a nice shader which work in stead of this weird error.:mad:

And else I will keep it this way. It isn’t really annoying for the players view.


(ailmanki) #7

uhm sorry, I misunderstood there something…
it is not possible to-do such a reflection…

but maybe it looks nicer - one can always try - to take a screenshot just above the water, looking straight up. so that as much sky is captured… and maybe some surroundings, and then use that for tcgen environment.