Jump to content


Photo

What Makes Water Gud?


11 replies to this topic

#1 Epifire

Epifire

    Advanced Member

  • Active Developer
  • PipPipPip
  • 526 posts

Posted 02 March 2018 - 01:16 AM

So yeah as by the title you can gather I'm attempting to gather good shader and MTR info on completing good water. What's paining me most is that I can't get even relatively close to good reflections and it's bugging the hell outta me. I've got a pretty snazzy material that can provide worthy generic reflection (from say a cubemap of the skybox) but that can't constitute the water line of shore, docks and buildings.

 

This brings me to the planar reflections of a stock material I found called "textures/water_source/cave_water_reflective_01"

{
qer_editorimage textures/glass/glass1
translucent
noshadows
nonsolid


{
blend blend
mirrorRenderMap 1024 1024
program fresnel.vfp
vertexParm 0 0.6
fragmentMap 0 _scratch
}
}

This simply doesn't work if you're using a normal skybox, as the mirrorRenderMap stage doesn't recognize the skybox projection and reflects a backdrop relative to seeing a leak. However what it will do is achieve the water line reflections I seek. At the mercy of recasting and rendering every single shadow in the map (yikes!).  :o

 

Now I'm not accustomed to the workings of the vfp but is it possible to condense/create a simpler one that doesn't relist shadows twice? I only need the silhouette that the planar reflection can provide as it wont be used wholesale as the primary effect. My goal is to layer this reflective pass (to gather waterline reflection data) and then fill in the blanks of a skybox backdrop manually by layering in a cubemap blend. Then what you'd have is proper world reflections, decent sky and cut the additional shadow cost. In the end it would be some fancy water, without the fancy overhead budget. I'm no expert to these materials so if anybody has a simpler method to getting that water line, I'm all ears.

 


You need a model? Epi does you a model.

 

Toss me a PM I promise I don't bite.

 

 


#2 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 1296 posts

Posted 02 March 2018 - 03:34 AM

I wish I was more helpful here, but apart from the skybox issue, I remember a discussion in which someone mentioned the fresnel image program doesn't work like an actual fresnel, so that might also be a source of problems. I wanted to use fresnel program for a frob outline, as you typically do in other engines, but I couldn't get it to work.



#3 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7476 posts

Posted 02 March 2018 - 06:18 AM

I don't think it is possible to have a dynamically-rendered reflection that doesn't increase shadow rendering, because the reflection is effectively a completely separate render from a different perspective (i.e. the other side of the plane looking back towards the camera). Assuming you want correctly-rendered shadows in the reflection, it is going to be necessary to render the shadows from this perspective, and there is no way to re-use the shadows from the main render because it's a completely different camera setup with a different field of view.

 

The only options, as far as I know, are the fully-dynamic reflection which has a performance hit due to the second render, or use a pre-rendered cubemap which is much faster but does not respond dynamically to changes in the scene.



#4 Epifire

Epifire

    Advanced Member

  • Active Developer
  • PipPipPip
  • 526 posts

Posted 02 March 2018 - 07:55 AM

Well from what I'm gathering the dynamic reflection is re-rendering the scene. I guess what I'm unsure about is how much of this re-rendering is shader dependent, or what other arbitrary functions are being calculated as mandatory steps in run time. I was under the impression the vfp is containing the math/commands to define what's being drawn up for the reflection. Under that same assumption I was looking to create a stripped down vfp that skips certain aspects of the rendering. All I really need is the basic shapes of buildings and shore to complete the water line. It'll be blurred beneath other layers so it's not required to be %100 accurate with shadow casting. If it can reference texture data and ambient world lighting that's plenty helpful for it's purpose.

 

Of course this is assuming shadow rendering can just be skipped at this stage. Otherwise I'm kinda outta ideas for tonight. On a separate note is this fresnel.vfp, and that is the fact it cannot render the skybox (otherwise being a projection of a projection). Is there a way to just insert a black mask to substitute the space of, "nothingness" it's attempting to render? Then you'd have a mostly condensed image where a skybox cubemap can just be thrown on top of that to complete the sky reflection. It would be even cooler if the cubemap and mirrorRenderMap could be combined in the same MTR, but I get a, "too many texgens" error if they're based in the same material.

 

Long night here messing with this stuff, so I hope most of that made sense.


You need a model? Epi does you a model.

 

Toss me a PM I promise I don't bite.

 

 


#5 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7476 posts

Posted 02 March 2018 - 08:05 AM

Well from what I'm gathering the dynamic reflection is re-rendering the scene.


Correct.
 

I guess what I'm unsure about is how much of this re-rendering is shader dependent, or what other arbitrary functions are being calculated as mandatory steps in run time. I was under the impression the vfp is containing the math/commands to define what's being drawn up for the reflection.


None of the rendering is shader-dependent. There are actually two separate things happening in this shader stage:

  • A mirrorRenderMap image map. This is not a shader, it is just an image map, like a diffuse or normal map, but this particular image happens to be the result of rendering a reflection from an appropriate camera position behind the surface. There is no way to control what this render contains; it is just a regular render as if you noclipped behind the plane and turned around to look back at your original position.
  • A fresnel.vfp custom shader. My understanding is that all this shader does is make the intensity of the stage dependent on the view angle, so you see more of the reflection at shallower angles and less reflection when looking straight ahead. You can most likely remove this shader entirely and you will still get the reflection, which demonstrates that the reflection has nothing to do with the shader.

It seems that what you really want is a way to control what is rendered by the mirrorRenderMap material stage, which is not possible without modifying the game code AFAIK.


  • teh_saccade likes this

#6 teh_saccade

teh_saccade

    Advanced Member

  • Member
  • PipPipPip
  • 630 posts

Posted 02 March 2018 - 01:11 PM

Didn't Arcturus come up with a fancy way of making realistic, animated water surface textures that could be adapted to have specular and bump and stuff?
Think there was some talk as Orbweaver confirmed in that it's killer render to do this, but the accurately moving water round a bend kinda trumped the need for it to reflect as a mirror, since the effect was awe-inspiring enough.

I can't find it now, but the water in the animated grass test maps from a while before still looks really nice:
http://forums.thedar...grass-test-map/

2nd & 3rd screenshots.

The water in this map has good reflections. The scenery is great. The light cast upon it works well, there is enough detail surrounding to not make it the main feature.

Increasing the detail of the objects that are being reflected - giving an impressionist feel to the reflections... it's really effective.
The pool has so much going on in it, it doesn't need to be an accurate mirror - it's a good example of good scene design that means no matter where your eye rests, the scene looks full.

Also, water doesn't reflect shadows... it reflects only reflects light.
This could easily be simulated by pointing spotlights onto the surfaces that the light from the water would reflect (eg, under a bridge over a canal, light is seen in the water from a streetlight, along with objects adjacent to the water body - the light from the source and the lighted objects is seen in the water reflection by default, but - the light bounces from the surface of the water, fake-reflected by use of a spotlight that has a watery light pointed up into the archway, casts shadows).

Don't see why that wouldn't work without having to mess with shaders or mirrors or grinding render to 0.1fps.

It's good, effective level design.
Fake it til you make it (or, more likely, someone else does and you steal it).

Sometimes mechanical illusion is as good coding magic, imo.



#7 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1624 posts

Posted 02 March 2018 - 03:07 PM

Didn't Arcturus come up with a fancy way of making realistic, animated water surface textures that could be adapted to have specular and bump and stuff?

 

My latest attempt from this topic:

 

 

Link to the files.


  • Bikerdude, RPGista and teh_saccade like this

It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#8 Epifire

Epifire

    Advanced Member

  • Active Developer
  • PipPipPip
  • 526 posts

Posted 03 March 2018 - 04:52 AM

 

  • A mirrorRenderMap image map. This is not a shader, it is just an image map, like a diffuse or normal map, but this particular image happens to be the result of rendering a reflection from an appropriate camera position behind the surface. There is no way to control what this render contains; it is just a regular render as if you noclipped behind the plane and turned around to look back at your original position.
  • A fresnel.vfp custom shader. My understanding is that all this shader does is make the intensity of the stage dependent on the view angle, so you see more of the reflection at shallower angles and less reflection when looking straight ahead. You can most likely remove this shader entirely and you will still get the reflection, which demonstrates that the reflection has nothing to do with the shader

 

Interestingly if I remove the vfp line from the mtr the reflection will break. This is what spurred the idea on because I'd noted that the mirrorRenderMap has always done this same graphical glitch in the past (shown below) but was due to me not pairing a vfp in the material definition...

 

Spoiler

 

That's when I started asking myself exactly how bound the mirrorRenderMap is to the vfp hooked into it? Thing is I don't know jack about ARB but these are just my ramblings from many frustrated hours of tinkering with it.


You need a model? Epi does you a model.

 

Toss me a PM I promise I don't bite.

 

 


#9 teh_saccade

teh_saccade

    Advanced Member

  • Member
  • PipPipPip
  • 630 posts

Posted 03 March 2018 - 02:02 PM

 

My latest attempt from this topic:

 

 

Link to the files.

Didn't see that one yet, nor the thread - looks really nice.



#10 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7476 posts

Posted 05 March 2018 - 05:46 AM

 

Interestingly if I remove the vfp line from the mtr the reflection will break. This is what spurred the idea on because I'd noted that the mirrorRenderMap has always done this same graphical glitch in the past (shown below) but was due to me not pairing a vfp in the material definition...

 

If the mirrorRenderMap is broken without the shader, it will be broken with the shader. All the shader can do in this case is hide the problem.

 

In the example you posted, I can't see any sign of reflection in the top image. Can you post a simpler or more brightly-lit example that makes the reflection more obvious?

 

Here is an example of a post by by nbohr that includes a mirrorRenderMap with no shader stage, although it includes some other texture parameters which may be necessary to get the correct result (I haven't tested it myself).

 

http://forums.thedar...ve/#entry309753


  • Epifire likes this

#11 Epifire

Epifire

    Advanced Member

  • Active Developer
  • PipPipPip
  • 526 posts

Posted 05 March 2018 - 06:45 AM

The example Arcturus supplied uses an almost identical mtr that Nbohr had listed minus the RGB line. My assumption is that mirrorRenderMap requires additional data by default because it'll fail to project correctly if the function is just used by itself. The only difference I'm seeing compared with the parameters others have used (without the vfp) is it will apply the fresnel like a mask to refine the areas it reflects.

 

Reflections in the prior image I posted are running but not at high intensity. This is the same material set with greater power...

 

MPY3J1Y.jpg

 

Note the surface is completely opaque as I haven't made any water depth adjustments. I'm going to have to substitute the texgen reflect (cubemap) of the water's surface to HeatHaze I recon, as I don't think cubemaps will accept scroll values for wave motion. One other drawback is that the cubemap's own generic reflection stage wont update with a moving _local map in my own tests. I know the cubemap itself is a static image but I was hoping I could scroll the local stage it refers to in order to get the motion needed. I really don't want to use specular maps as it's probably the worst generic map to use for water. However I may not have much of a choice there either. 

 

For most reflections, this would be a piece of cake if we had access to parallax corrected cubemaps.  :wacko:

 

Also something crazy to note, is that the mirror doesn't like props without a bottom. I've noted on the big footings I used in the shot (that don't have a bottom) get skewed reflections streaming out behind them. Relative to the player's view of course but it's a minor bug to note. I guess my decision now is to figure if it's really worth the performance deficit to use the mirrorRenderMap stage at all. It's for a very large and very open map that currently runs great but I can guarantee it'll bog lower end systems with this puppy doubling the render budget.


  • Bikerdude likes this

You need a model? Epi does you a model.

 

Toss me a PM I promise I don't bite.

 

 


#12 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7476 posts

Posted 05 March 2018 - 11:18 AM

Also something crazy to note, is that the mirror doesn't like props without a bottom. I've noted on the big footings I used in the shot (that don't have a bottom) get skewed reflections streaming out behind them. Relative to the player's view of course but it's a minor bug to note.

 

That's exactly what I would expect. The mirror render takes place from a position below the water, looking upwards. The game does not render the backs of polygons correctly, so if the stones in the water don't have a bottom, they will at best be incomplete or missing, and at worst exhibit render artifacts like you describe.

 

I believe there is a twoSided material property you might be able to use to eliminate the problem, but adding a bottom to the objects would probably be better for performance, since you can minimise the number of polygons required to close the model whereas I think twoSided will just duplicate everything.





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users