wraitii Posted July 11, 2012 Author Report Share Posted July 11, 2012 That helped more than you'd think: I couldn't get the darn texture to work properly. Quote Link to comment Share on other sites More sharing options...
zoot Posted July 11, 2012 Report Share Posted July 11, 2012 (edited) Agreed. I think the massive water plane we have at the moment is too inflexible (pun intended) and you can't really do much with it. Maybe eventually we can replace that with multiple small water planes that each has its own elevation, materials, etc and can be placed in Atlas as objects.Perhaps a helpful metaphor is 'the water table'. Basically, the water table can be thought of as a terrain that is conceptually orthogonal to land terrain, with its own heightmap, tiles with materials, textures and blendings etc. That should also make it easier to do rivers and waterfalls: a waterfall, for instance, is just a drop in the water table, so this is where the engine should throw in special animations, particles, sounds etc. Edited July 11, 2012 by zoot Quote Link to comment Share on other sites More sharing options...
feneur Posted July 11, 2012 Report Share Posted July 11, 2012 About the foam, Michael (Mythos_Ruler) created a/or perhaps several textures a couple of years ago that he placed manually. Hmm, looking at them in Atlas (just search for wave in the object tab) I guess they are more like waves, but still, something to check out at least, perhaps it can be useful in one way or another Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 11, 2012 Author Report Share Posted July 11, 2012 Yeah, I've checked that out... I'm trying currently trying to get the terrain to give me some useful info, such as the normals (in x-z directions) so that I can put waves in the shaders. With luck, I could reuse Mythos' textures. Quote Link to comment Share on other sites More sharing options...
Gen.Kenobi Posted July 11, 2012 Report Share Posted July 11, 2012 So I decided to give it a try using Blender's Ocean Sim to create an "animated" ocean texture.What we should bear in mind is that Realistic Ocean is not seamless at all. If we can't implement a way to make things dinamically generated, or with an actuall animated water-plane (what would be pain, specially for all maps that we have, and maps that would be created by modders) it'll look quite unrealistic(tilled).Blender's Ocean Sim, gives a realistic way to get seamless waves at least in the X factor(lol). The Y one is not seamless because of the wave dumping, what would look weird, specially on map edges. I tried to fix it by reversing time, what made it look quite awkward, but now looks seamless.I'm gonna up two videos soon, one with the reversed time way and the other one completely time-foward.It's a 250 frames animation only using baked displacement texture (Bump maps generated by the OceanSimulator - I can mess up with the setting to create different kinds of atmosphere) on a 4 vertices plane. The main probleman is that the displacement map uses negative values, what, for some reason, blender can't compute. So you'll see the plane. Enough of chit-chat. I shall upload the video. Quote Link to comment Share on other sites More sharing options...
Gen.Kenobi Posted July 11, 2012 Report Share Posted July 11, 2012 First video up: Quote Link to comment Share on other sites More sharing options...
FeXoR Posted July 11, 2012 Report Share Posted July 11, 2012 First video up: https://vimeo.com/45607172Can you set the "boundary conditions" so the water height on the left/top equals those on the right/bottom? That would make it fit together. Or how are you planing to do that? Quote Link to comment Share on other sites More sharing options...
Gen.Kenobi Posted July 11, 2012 Report Share Posted July 11, 2012 Unfortunately I don't have that kind of control... All I could think was to reverse the time, but maybe we could flip the textures manually to make the water going to the same direction... I really don't know.BTW, I just uploaded the second video. It's now processing. Quote Link to comment Share on other sites More sharing options...
Gen.Kenobi Posted July 11, 2012 Report Share Posted July 11, 2012 Second Video is up: Tell me what you guys think. Quote Link to comment Share on other sites More sharing options...
FeXoR Posted July 12, 2012 Report Share Posted July 12, 2012 In general it looks good. It seams that the waves are reflected at the edges. If you can't change that it might be a good idea to only capture the middle of the calculated area so the reflection cannot be seen. I'd love to play around with this Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 12, 2012 Author Report Share Posted July 12, 2012 This looks good, but fairly small, which could make it look not too good.For "dynamic" water, the usual cheap system is using two textures and multiplying their normals. For those who have it, start Anno 1404: on low quality settings for the water, if you speed time up, you'll clearly notice it.The fact that negative values of the displacement map are not computed is bad, that'd look very weird in-game, I think. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 12, 2012 Author Report Share Posted July 12, 2012 (edited) Okay, I got the foam to move to properly simulate wave coming and going on the shores depending on the shore direction. It's still not perfect, but it's better. Edited July 12, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
zoot Posted July 12, 2012 Report Share Posted July 12, 2012 Okay, I got the foam to move to properly simulate wave coming and going on the shores depending on the shore direction. It's still not perfect, but it's better.Is it in your repo? If my computer can handle it, maybe I can find a way to videofy it. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 12, 2012 Author Report Share Posted July 12, 2012 (edited) Not yet, I had another git problem. Here's a screenshot in the meantime.(this shows my waviness improvements, Myconid's shadow on the water, Myconid's smoothing of the water texture and the foam)Of course, it looks much better animated…But I'd rather wait to have added a few more stuffs before uploading (namely, a "distance to shore" parameter for some stuffs.) Edited July 12, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
myconid Posted July 12, 2012 Report Share Posted July 12, 2012 Looks quite nice. Are you using the heightmap to calculate the direction of the waves? Quote Link to comment Share on other sites More sharing options...
zoot Posted July 12, 2012 Report Share Posted July 12, 2012 But I'd rather wait to have added a few more stuffs before uploading (namely, a "distance to shore" parameter for some stuffs.)Wouldn't it be better to use a water depth parameter in those cases? I mean, physically, the water doesn't "know" the distance to the shore... Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 12, 2012 Author Report Share Posted July 12, 2012 (edited) It would, but it gives weird results on maps like Oasis, and generally shallow maps. Technically, realistic result would be achieved by calculating "difference in water depth", which I might try.@Myconid: actually, I ended up using the x-z vectors of the terrain normal, so I get the "direction" of shore. With a bit of blurring, the effect is very nice. Edited July 12, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
Gen.Kenobi Posted July 12, 2012 Report Share Posted July 12, 2012 This looks good, but fairly small, which could make it look not too good.For "dynamic" water, the usual cheap system is using two textures and multiplying their normals. For those who have it, start Anno 1404: on low quality settings for the water, if you speed time up, you'll clearly notice it.The fact that negative values of the displacement map are not computed is bad, that'd look very weird in-game, I think.The negative values are computed whitin the texture, Blender is the one with problems with it. I can see if I can get you some textures, so you might try it, if you like. The only issue is that they are in .exr and by 100x100 pixels.:// Quote Link to comment Share on other sites More sharing options...
Sonarpulse Posted July 13, 2012 Report Share Posted July 13, 2012 (edited) It would, but it gives weird results on maps like Oasis, and generally shallow maps. Technically, realistic result would be achieved by calculating "difference in water depth", which I might try.@Myconid: actually, I ended up using the x-z vectors of the terrain normal, so I get the "direction" of shore. With a bit of blurring, the effect is very nice.I don't know any relevant fluid dynamics, but I'd imagine what you'd really want is the gradient vector field based off the height map. https://en.wikipedia.org/wiki/Gradient Edited July 13, 2012 by Sonarpulse Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 13, 2012 Author Report Share Posted July 13, 2012 (edited) Well, what I tried yesterday was "difference between 1 and the Y value of the normal". That gave me an indication of how slopes the ground was, which seemed to work fairly nicely.I'll try to add some basic wave effect today, and if I succeed or fail, will clean things up and commit.The last improvement would then be to use the z buffer to have a more realistic water depth. Edited July 13, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 13, 2012 Author Report Share Posted July 13, 2012 (edited) Okay, I've committed the foam. No proper waves for now, I'm not sold on how to do it... Should it be on the shader, using the distance to the coast as a reference? A decal?I'll probably try to add some sea foam on high waviness later.It only works on GLSL for now (the code is messy and I do a fair amount of calculations, so I haven't yet bothered porting).Needs recompiling (tell me if something goes wrong, I've had some serious troubles with git at some point and some files may be missing/corrupted).The effect is scaled with waviness and slope, it's not perfectly realistic but I think the result is quite all-right already.If someone wants to give a look at the code, I've modified slightly WaterManager.cpp/h and TerrainRenderer.cpp (more).There's a "WaterTest" demo that showcases it on small island. Check out the Mediterranean Coves scenario, too. Edited July 13, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
zoot Posted July 13, 2012 Report Share Posted July 13, 2012 I'll give it a spin Okay, I've committed the foam. No proper waves for now, I'm not sold on how to do it... Should it be on the shader, using the distance to the coast as a reference? A decal?The problem I see with using distance to the coast as a reference is that, unless you also take the angle of the coast into account, you might get waves that look a bit off. For instance, against a steep cliff you will want waves that surge 'violently' just before they hit the cliff face, not the cozy type of waves that roll slowly onto a beach.I only have a very general idea about how shaders work, but could you perhaps use a combination of the water depth at a given point and the gradient of the terrain immediately below it?On great depths, we obviously don't want breakers on the surface. On low depths we do. On steep gradients we want more 'violent' or intense breakers. On gentler gradients, not so much. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 13, 2012 Author Report Share Posted July 13, 2012 (edited) Just realized I did a ton of unuseful stuffs with my texture, I hadn't noticed that PatchRData was about setting up this sort of stuff... I'll update, and keep my texture for other info I might find useful.@Zoot: I'll probably do something along those lines.Edit: ah, nah, I'll have to do with the texture for the normals but won't need the heightmap. Edited July 13, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
myconid Posted July 13, 2012 Report Share Posted July 13, 2012 Works and looks good! A bit slow, but I'm sure there's plenty of room for improvement. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 13, 2012 Author Report Share Posted July 13, 2012 I just did a fair share of optimizations... Zooming as far back as legally allowed, it takes about 7ms on my computer, and the water refraction/reflection take about 5, I think it's okay given the effects.We might want to consider updating the refraction/reflection maps one at a time for a cheap optimization, too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.