Jump to content
The Dark Mod Forums

water reflection + refraction


ungoliant

Recommended Posts

The following is the newest incarnation of my water surface texture, and I can't seem to get it right. The whole point is to overlay a reflection of the sky on top of the refracting water, this can be achieved, but the original diffusemap / bumpmap is lost and only the reflecting portion remains.

 

textures/water_source/water_top
{
qer_editorimage textures/water_source/water_grey
noshadows
{
	blend diffusemap 
map 	textures/water_source/water_grey
colored
	}
	{
blend bumpmap
map 	textures/water_source/water_green_local
translate	0.01 * sintable[time * 0.2], 0.01 * sintable[time * 0.22]
scale 0.5,0.5
	}
{
	program		heatHaze.vfp
	vertexParm	0	time * 0.1 , time * 0.1 // scroll
	vertexParm	1	0.5 //magnitude
	fragmentMap	0 	_currentRender
	fragmentMap 1 textures/sfx/vp1
	fragmentMap 2 textures/water_source/vp_water
}
{
	blend	blend
	mirrorRenderMap	512	512

	translate	0.5, 0.5
	scale		0.5, 0.5
}
}

 

I used to have a seperate fresnel material that went under this with the mirrorRenderMap stage, but I scrapped it as it complicated things too much. Anyway, can someone tell me how I can keep the original water_grey diffuse and the bumpmap?

 

edit: tried setting alpha 0.5 to the blend blend stage, didn't work. tried putting blend blend stage first, then setting alpha 0.5 to the blend diffusemap stage, that didn't work either, just shows the diffuse and bump maps with no reflection. Can't seem to get them both to display together.

Edited by ungoliant
Link to comment
Share on other sites

I don't think there is any way to combine all of this into one texture (although good luck to you if you can find one). All the ref-ref water shaders I've seen have used a separate reflective/blend patch underneath the refractive one.

Link to comment
Share on other sites

that was what I did with the original attempt that had a seperate patch underneath the surface with the reflection stage + fresnel. For whatever reason, that still blocked out the diffuse / bumpmap of the top surface, although the reflection still displayed with heat haze(which was in the top surface). very aggravating. why would the diffuse / bump maps be lost, but not the heat haze?!

Link to comment
Share on other sites

I'm not sure why you would want a diffuse/bumpmap on the top surface, since this would be entirely opaque and prevent seeing through the water. You could use a diffusemap with alphatest I suppose, if you wanted flecks of opaque dirt on top of the water, but generally a "blend modulate" stage would be better for providing some colour/texture to the water.

Link to comment
Share on other sites

not experienced enough to even know how to use blend modulate.

 

But: it ALMOST works. take a look at this screenie:

 

th_almost.jpg

 

if you look close, you can see that theres a box on the bottom left corner that takes up 1/4 of the screen, and it has the effect that i want!!!! I put the moon reflection cut by the top part of this box, just to illustrate it. Now... If i can get that overlay fullscreen.........

Link to comment
Share on other sites

Don't know if it helps but I'm using a patch skin of textures/water_source/water_fake_reflect_02 over a water surface of textures/water_source/water_green outdoors and a skin of textures/water_source/water_reflective2 in a small sewer where the sky is not visible and performance not so critical. I get both reflectiveness, bumpmapping, and the refraction effect.

 

post-400-127729330889_thumb.jpg post-400-127729331931_thumb.jpg post-400-127729332731_thumb.jpg

Link to comment
Share on other sites

ok, I've almost got it. It seems that the parameters to renderMirrorMap directly influence the size of this box..... this is friggin weird because most of the time without any diffuse / bumpmap the reflection by itself works just fine with the default values... my screen res 1152 x 864 doesn't make it fullscreen either.

Link to comment
Share on other sites

Don't know if it helps but I'm using a patch skin of textures/water_source/water_fake_reflect_02 over a water surface of textures/water_source/water_green outdoors and a skin of textures/water_source/water_reflective2 in a small sewer where the sky is not visible and performance not so critical. I get both reflectiveness, bumpmapping, and the refraction effect.

 

post-400-127729330889_thumb.jpg post-400-127729331931_thumb.jpg post-400-127729332731_thumb.jpg

 

hmmmm. maybe i'll try incorporating that. Whats up with the 3rd SS btw? why is the moon in that sewer?

 

edit: ahh i see whats going on here. The fake reflect is using a cubemap, hence the moon. I'm doing dynamic reflection. I know this can work though, but its got something to do with alpha channel.... the mirrored reflection and the diffuse / bump need to be like half transparent on top of eachother, but I'm too noob with material shaders to figure out the solution.

Edited by ungoliant
Link to comment
Share on other sites

The screenshot with the moon is a canal or open sewer; the one with the wall light is covered over. The fake is not perfect but if you don't look too close it is convincing enough and with good performance. But if you can get your shader to work it will save having to set up two things.

Link to comment
Share on other sites

got it working. apparently after adding the reflection, you need to boost up the light level much higher to see the original texture. Additionally, proximity to the reflective surface seems to have a major effect, which is difficult to deal with when your stuff is in a skybox.

 

Adjusting the light level doesn't affect the reflection itself though, which is a blessing. I gotta say, the overall effect looks amazing when you get the lighting right. Been working for about 6 hours trying to put the finishing touches on the skybox, but I can't seem get a soft horizon edge because of the stupid clouds and their reflections on the water as they pass over it. Well, I can get it soft, but either it ruins the clouds, or it ruins the water/moonlight effect. Its going to drive me insane.

Link to comment
Share on other sites

What happens if you add another light into the skybox low down at the side over the water surface? Does that emphasise the bump map?

 

[EDIT] oh yeah and i've been assuming this is a separate portalled skybox?

 

your idea about light off to the side (near the moon) over the water surface is exactly whats giving me the problems with the horizon line. cannot light up water near horizon without hitting the clouds on horizon. but on the water surface the effect (with a round ambient light texture) looks wicked sweet.

 

The biggest regret I have about this, is that you really have to miss out on a lot of the really neat water effects, because camera in the skybox always stays still and always sees things from the same angle from the same distance.

 

yes its a seperate portalled skybox, and when I finally finish it, I'll prefabulate it and upload it (after the contest).

 

EDIT: I believe I may have found the answer: spectrum. stars, moon, and clouds all go into their own spectrum, with their own individual spectrufied lights, leaving me free to light the water surface however I damn well please without interference by the other skybox assets. got the idea from the twinkle_stars texture that already uses this.

Edited by ungoliant
Link to comment
Share on other sites

the function of shadow-textured brushes still eludes me. Maybe get to that on another project. Almost done with skybox. Need a final placement on water illuminating light now that they I'm weapons-free on water lighting, and another cloud illuminating light directly in front of the moon so that clouds rolling in front of the moon appear more brightly. maybe experiment with multi-spectrum lights and see if i can illuminate the moon and moon-clouds with 1 light.

 

Check the WIP thread in another hour or so. Its gonna be sweet.

Link to comment
Share on other sites

About refraction, there's a quick trick to make it nicer (if it isn't there already) a falloff in respect to the viewing angle of the camera.. that's a little harder to explain than I expected, so here's an example I made in Max:

 

plane with a regular 50% opacity:

teste2.jpg

 

Plane with a falloff material:

teste1.jpg

Notice how the farther away from the camera, the viewing angle gets less perpendicular to the surface and therefore less transparent.

 

These examples do not have reflection so it's easier to see the effect.

 

Edit: The images were inverted :P

Edited by Diego
Link to comment
Share on other sites

Interesting. How would I make a falloff material? This might be of use for my supercrumb method. I am testing with grass and dirt using a superfine dot pattern 4096 x 4096 alpha map to simulate gradient transparency so it softens better eg with stone path. The problem is that it looks great close up looking down at high angles but the effect fades rapidly as you look farther along. If I increase the width of the dotted area then it increases the effective distance but now the player can see a ripple effect as he walks forward and the distant edge comes within range.

 

post-400-127745518178_thumb.jpg post-400-127745519348_thumb.jpg

 

[EDIT] Actually I am not sure it is the angle but the distance. If I noclip high and look down the effect diminishes so perhaps this falloff idea isn't applicable here (unless it can be used to somehow produce gradient transparency on the edge?)

Link to comment
Share on other sites

Almost certainly what is happening is that your superfine pattern is turning into a solid because of the lower resolution mipmaps used at far distances, which will blur the pattern into more constant colours. If this was a true blend operation it wouldn't matter because the blurred pattern would be partially transparent, but with alphatest there are only two possible states and the distant pattern becomes a hard edge.

Link to comment
Share on other sites

This sounds like the Moiré effect, wich is strange, I thought Doom 3 engine had some anti aliasing filter built in.

 

But maybe a material like that could solve your issue. I don't have any idea on how to implement it, though, never worked with materials in D3.

Link to comment
Share on other sites

what about a solid partial transparency strip? I'm quite new to this whole thing with alpha channels, and not so good at working with it in materials yet. But what if you used a solid layer of both grass and dirt overlaying eachother. So if grass is on the left side and dirt is on the right (in your map), use an alpha channel on the grass image that rolls white to black from left to right above the dirt image, and leave the dirt texture underneath it as totally opaque.

 

If it works, it would be super easy for people to create their own blend textures. Replace grass with X texture, and dirt with Y texture.

 

(I think i got that right. white is opaque and black is transparent, yes?)

Edited by ungoliant
Link to comment
Share on other sites

ungoliant: There is no gradient transparency in Doom3. This is why I am trying to simulate it with a fine mesh. An alpha map gradient from white to black would show full grass on one side and nothing on the other depending on the value of alphatest.

 

Diego: So what did you mean by a 'falloff material'? Is that something that works in Max but not in Doom3?

Link to comment
Share on other sites

ungoliant: There is no gradient transparency in Doom3. This is why I am trying to simulate it with a fine mesh. An alpha map gradient from white to black would show full grass on one side and nothing on the other depending on the value of alphatest.

 

Diego: So what did you mean by a 'falloff material'? Is that something that works in Max but not in Doom3?

 

oh, you mean that alpha has to be either pure black or pure white? oh well, that sucks.

Link to comment
Share on other sites

oh, you mean that alpha has to be either pure black or pure white? oh well, that sucks.

 

Partial transparency is supported only for material stages which use the blend blend mode, which causes a pure alpha blend with no lighting interaction. For materials which must be lit by scene lights, with bumpmapping etc, the only way of using an alpha channel is with the alphaTest keyword, which causes a division into fully-opaque and fully-transparent pixels.

Link to comment
Share on other sites

Diego: So what did you mean by a 'falloff material'? Is that something that works in Max but not in Doom3?

 

Sort of.. I knew that the algorithm to create an alpha map based on the angles and normals would have to be coded, but if the engine doesn't support gradient transparency it's not going to work. But then, how does the water shader works? it's not completely opaque neither transparent.

Link to comment
Share on other sites

Sort of.. I knew that the algorithm to create an alpha map based on the angles and normals would have to be coded, but if the engine doesn't support gradient transparency it's not going to work. But then, how does the water shader works? it's not completely opaque neither transparent.

 

Well, there is the "translucent" keyword for shaders, which sounds like it is what we want, except it *always* renders at 50% transparency *sigh* Wish one could change that value in real-time on a per-tris basis...

 

I guess all our water and glass shaders use this keyword.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 3 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
×
×
  • Create New...