myconid Posted July 26, 2012 Report Share Posted July 26, 2012 As I don't know exactly how you're trying to do it, I can't be of much help... If you release some code, I'll have a look (later tonight) and make some suggestions. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 26, 2012 Author Report Share Posted July 26, 2012 Not much to be done with the current code, as it's all created in the shaders. To do the waves in screen space, I'd need to restart that from scratch (and i'm not really sure how to do it anyway). Quote Link to comment Share on other sites More sharing options...
myconid Posted July 26, 2012 Report Share Posted July 26, 2012 Ah ok. My thought was to calculate the wave positions/directions in Atlas and insert polygons at those locations with the appropriate rotation.Then we create a material that moves one or more textures across the polygon surface and transforms them as needed to look wave-like. Alternatively, we create the animation in Blender and it could work just as well (but is probably less efficient).This material draws to two buffers simultaneously (look up MRT), one being a normalmap that is combined with the water normals and maybe an additional buffer for diffuse foam or such. The extra buffers are passed into the water shader and combined with the usual water effect. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 26, 2012 Author Report Share Posted July 26, 2012 The hardest part here is that the geometry must take into account the convexity of the map (to avoid overlapping). If you look at page 6/7 (can't recall which) you'll see I had that for some times, but it felt unsatisfactory. I could retry with your system. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 26, 2012 Report Share Posted July 26, 2012 I see what you mean. We don't need to have one looong wave all across the beach, it can be a lot of small waves here and there moving independently. Also, we might use several triangles to deform the shape of the waves as needed (this would need to be made a special case, though).Either way, it's doable! Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 26, 2012 Author Report Share Posted July 26, 2012 (edited) It's harder to do a lot of small waves properly in some cases. I'll have to give a look at some sort of wind direction.Anyway I'll retry with the mesh thing.Given my current timetable, this would probably push waves to after Alpha 11, though. Edited July 26, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
Pureon Posted July 26, 2012 Report Share Posted July 26, 2012 Given my current timetable, this would probably push waves to after Alpha 11, though.Don't worry too much about getting it into Alpha 11, Alpha 12 will be round the corner soon enough Quote Link to comment Share on other sites More sharing options...
MishFTW Posted July 26, 2012 Report Share Posted July 26, 2012 Amazing work so far! If only the units could swim... for the civs with prominent navies, that should be an option... swimming archers would be epic Quote Link to comment Share on other sites More sharing options...
idanwin Posted July 27, 2012 Report Share Posted July 27, 2012 Why not ones that walk on water and transform into trees? Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 28, 2012 Author Report Share Posted July 28, 2012 Myconid, I've implemented a way to do waves using render-to-textures. I think for waves I'll focus on using the "wind direction" and all waves will follow that (so I've got to take into account protection from wind. Should be okay.), and I'll use the alpha channel for the foam (which is all-right because it's already only one channel). So that should work. I'll just have to actually go through with it. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 28, 2012 Report Share Posted July 28, 2012 Myconid, I've implemented a way to do waves using render-to-textures. I think for waves I'll focus on using the "wind direction" and all waves will follow that (so I've got to take into account protection from wind. Should be okay.), and I'll use the alpha channel for the foam (which is all-right because it's already only one channel). So that should work. I'll just have to actually go through with it.Ok, looking forward to seeing it in action. What sort of look are you aiming for? Something like the AoE3 video that Mythos_Ruler posted perhaps? Quote Link to comment Share on other sites More sharing options...
zoot Posted July 28, 2012 Report Share Posted July 28, 2012 Myconid, I've implemented a way to do waves using render-to-textures. I think for waves I'll focus on using the "wind direction" and all waves will follow that (so I've got to take into account protection from wind. Should be okay.), and I'll use the alpha channel for the foam (which is all-right because it's already only one channel). So that should work. I'll just have to actually go through with it.AFAIK, though wind adds the energy that indirectly creates waves, shore waves generally flows towards the shore, not in the wind direction.Non-shore waves are another matter, though. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 28, 2012 Author Report Share Posted July 28, 2012 Yeah, but this is a fairly big constraint. I think a good effect can be achieved by using waves that go only in one direction (that is to say, you'd get breaking waves near some part of the beaches, the rest would get regular ocean stuff). Around small islands, it looks weird to have waves "morphing around" in the obviously wrong direction. On bigger islands, I'd have to check if some system can't be made to sort of follow the slope of the island, but I fear it might be complicated to do efficiently, nicely, and easily enough. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 29, 2012 Author Report Share Posted July 29, 2012 Okay, so I've tried using the ground directions for the wave... And the answer is no, it looks bad.I think I'm going to stop being dumb and start being clever instead, so I'll probably resort to some sort of fancy geometry stuffs that will allow for wave discontinuity, because hey, waves can be. Should work anyway.On the upside, this is really helping me work on my hatred for restarting from scratch. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 30, 2012 Author Report Share Posted July 30, 2012 Some news that, for once, aren't "This failed".So I've switched back to geometry, and to render-to-buffer, which helps nicely against depth problem and conflicts.Here's an early WIP:It looks promising enough that I should be able to get it to work, so that's something. Quote Link to comment Share on other sites More sharing options...
Pureon Posted July 30, 2012 Report Share Posted July 30, 2012 Good news! Quote Link to comment Share on other sites More sharing options...
myconid Posted July 30, 2012 Report Share Posted July 30, 2012 Some news that, for once, aren't "This failed".So I've switched back to geometry, and to render-to-buffer, which helps nicely against depth problem and conflicts.Here's an early WIP:It looks promising enough that I should be able to get it to work, so that's something.Ah yes, that looks like the sort of thing I had in mind. Nice work! Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 30, 2012 Author Report Share Posted July 30, 2012 Yeah, I hadn't thought at all of rendering the meshes to texture, but that eliminates quite a few issues. I had code leftovers from my many tries, too, so it took very little time.I've switched working from git to svn because I figured it would be easier in the end, and here's a patch for the current SVN version (12240 I believe).The wave effect is shown, it's not really clear in all orientations because it affects the normals, and not so much the foam (only a little). it's not really synched up or cleaned up, take that as a proof of concept and tell me how it feels.I intend to: make it so the squares are more aligned to the shores, so you won't get waves that start way too early/feel too weird. i'll try to make waves wider too, once that is done. Have some sort of pseudo-wind strength effect affect the amount of foam/waves.I'd need a wave texture (in the same spirit as the one I included, only way nicer. Basically, only one wave and some "blank space"), it should ultimately be animated, it'd be much nicer. Also, I'd need the same texture only in the form of a heightmap to help with the foam. If somebody could do that, it'd come in very handy.edit: patch update below(I'm not sure I can add files to the patch, so I've linked the two textures below. They have to be put in " binaries/data/mods/public/art/textures/terrain/types/water/ ")Since it's my first svn patch, it might not work, please report then Quote Link to comment Share on other sites More sharing options...
myconid Posted July 30, 2012 Report Share Posted July 30, 2012 First, some compilation errors:../../../source/renderer/TerrainRenderer.cpp: In member function ‘bool TerrainRenderer::RenderFancyWater(const CShaderDefines&, ShadowMap*)’:../../../source/renderer/TerrainRenderer.cpp:912:43: error: ‘glGenFramebuffersEXT’ was not declared in this scope../../../source/renderer/TerrainRenderer.cpp:913:59: error: ‘glBindFramebufferEXT’ was not declared in this scope../../../source/renderer/TerrainRenderer.cpp:925:108: error: ‘glFramebufferTexture2DEXT’ was not declared in this scope../../../source/renderer/TerrainRenderer.cpp:1022:45: error: ‘glDeleteFramebuffersEXT’ was not declared in this scopeYou need to add "p" to the front of the function names, due to how they are imported in glext_funcs.h.../../../source/renderer/WaterManager.cpp: In constructor ‘WaterManager::WaterManager()’:../../../source/renderer/WaterManager.cpp:73:23: warning: converting to non-pointer type ‘GLuint {aka unsigned int}’ from NULL [-Wconversion-null]Use "0" not "NULL" (better), or use an explicit cast (should work, but kinda funky).And then, there's this:ERROR: CCacheLoader failed to find archived or source file for: "shaders/glsl/waves.xml"ERROR: Failed to load shader 'glsl/waves'Segmentation faultYou have to use "svn add" on any unversioned files you want to include in your patches.Please use git in the future, it's much easier to test from. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 30, 2012 Author Report Share Posted July 30, 2012 Thanks for the report. Forgot about those files, that's pretty dumb of me. The "p" stuff didn't bother my compiler so i didn't notice, neither did the "NULL" stuff, that's fixed.Yeah, git is easier for testing but porting the commits to SVN is something I'm really uncomfortable with, so for that it'll be SVN (furthermore, I've had a few problems with git, and my fork is a huge mess right now which I can't bother fixing).I'll try to repost a (slightly newer) a bit later. Quote Link to comment Share on other sites More sharing options...
Wijitmaker Posted July 30, 2012 Report Share Posted July 30, 2012 I'd need a wave texture (in the same spirit as the one I included, only way nicer. Basically, only one wave and some "blank space"), it should ultimately be animated, it'd be much nicer. Also, I'd need the same texture only in the form of a heightmap to help with the foam. If somebody could do that, it'd come in very handy.Just to see if I follow you correctly... you would like an animated height & normal map of a full (single) wave cycle - from it's rise, then crest, then break?Wikipedia has some cool info (and animated images): http://en.wikipedia....iki/Water_waves Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 30, 2012 Author Report Share Posted July 30, 2012 That would probably be too complicated and would most likely not give the best results... I'd need some sort of "cruising" wave, ie no rise, no breaking, just at its crest phase. Only to simulate some sort of movement in the water, it could have some turbulences in the front or something.Animation is therefore mostly a plus, but even a proper normal map and heightmap for a single wave would be very handy. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 30, 2012 Author Report Share Posted July 30, 2012 Updated patch (from clean SVN): you'll still need the two textures from above but the rest should work.water.patch Quote Link to comment Share on other sites More sharing options...
Wijitmaker Posted July 30, 2012 Report Share Posted July 30, 2012 That would probably be too complicated and would most likely not give the best results... I'd need some sort of "cruising" wave, ie no rise, no breaking, just at its crest phase. Only to simulate some sort of movement in the water, it could have some turbulences in the front or something.Animation is therefore mostly a plus, but even a proper normal map and heightmap for a single wave would be very handy.Try this - Sorry I didn't convert them to a normal (maybe somebody else could?). CrazyBump kept crashing for some reason.I came across this which I thought was interesting:http://www.gamedev.net/blog/715/entry-2249487-ocean-rendering/page__st__5http://www.outerra.com/forum/index.php?topic=544.0Waves.zip Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 31, 2012 Author Report Share Posted July 31, 2012 Looks a lot like what we have now (in the method), actually, which is pretty nice. The difference is that he apparently uses a pretty high-scale texture of the distance to the shore for each shore pixel to have the waves crash nicely, and it seems the terrain in that simulation was more linked to the tiles when in 0 A.D.I figured, while I can't use an actual animated texture to have breaking waves, I could use a 3D texture. Is that supported by the game?Wijitmaker, thanks for the waves. To clarify what I needed, I needed mostly an image like your "wave_17" one. The animation could be used to introduce slight perturbations on that particular image (I don't need the wave to move in the texture, because of the system I use).I can do the conversion to normal myself. 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.