Pureon Posted July 16, 2012 Report Share Posted July 16, 2012 Myconid's random experiment #2842: Animated water material that can be attached to models.http://imgur.com/QfhzHDoes this mean we can create mountain lakes and aqueducts with animated water? Does it work by making a prop to use a certain texture? Quote Link to comment Share on other sites More sharing options...
zoot Posted July 16, 2012 Report Share Posted July 16, 2012 Myconid's random experiment #2842: Animated water material that can be attached to models.http://imgur.com/QfhzHNo reflections or refractions. Not sure how efficient those would be to render. Maybe they can be faked with static simple/cube textures instead... What are the concerns about efficiency of reflection/refraction? Is it different from other water rendering? Quote Link to comment Share on other sites More sharing options...
myconid Posted July 16, 2012 Author Report Share Posted July 16, 2012 Does this mean we can create mountain lakes and aqueducts with animated water? Does it work by making a prop to use a certain texture?Aqueducts yes, lakes no(t yet). Yup, basically it attaches a new material type to a transparent plane that is then attached as a prop to a model. The material uses a normalmap/specular shader + some new "renderquery" stuff in the engine (a system I've been working on for materials to query the renderer to give them specific info, such as the game-time, the water texture etc).For lakes I want to modify the "global" water instead, which completely separate from this. Specifically, I want to make it possible for the global water plane to be deformed just like the terrain plane. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 16, 2012 Author Report Share Posted July 16, 2012 (edited) What are the concerns about efficiency of reflection/refraction? Is it different from other water rendering?Well, for reflections at least, everything needs to be rendered upside down. The more reflections you have, the more times you need to re-render everything for each frame. For refractions you need to "cut out" the bottom of the water and render it separately to a texture.Not sure if there's a clever way to do all of these at the same time (nothing comes to mind), but there must be a way to do it, I just haven't thought it yet.The alternative I was thinking is to simply have some prerendered textures that we use for relfections/refractions. For example, we could just reflect the sky texture and refract a static "reservoir-bottom" texture. As long as they roughly look like they are moving correctly relative to the camera, it may hide the fact they aren't real reflections. Edited July 16, 2012 by myconid Quote Link to comment Share on other sites More sharing options...
k776 Posted July 17, 2012 Report Share Posted July 17, 2012 There seems to be a file missing in your 'merged' branch. I can't seem to compile it at the moment.Once thats in, I'm looking forward to seeing the latest changes :-) Quote Link to comment Share on other sites More sharing options...
Wijitmaker Posted July 17, 2012 Report Share Posted July 17, 2012 Yup, that looks more correct! http://imgur.com/a/CkHWfIn regards to parallax: when you are creating heightmaps remember that the parallax effect actually goes inwards (i.e. the real surface of the polygon is at height=white). If your entire polygon is much lower than that, it gets pushed inwards and the effect doesn't know what to draw to fill in the gaps at the edges. That's why you got tiling gaps on the roof of the roman civil centre. The solution? Make the brick heightmap brighter, until the tops of the stones=white.Lets try this one. Sorry, no specular yet - I got distracted by the water thread. Quote Link to comment Share on other sites More sharing options...
fabio Posted July 17, 2012 Report Share Posted July 17, 2012 (edited) Whoops looks like I forgot to add the civic centre files to that branch, sorry! Mars_temple2 should work, though!I pulled again effectdistance2 branch but I get nothing new.Uh, indeed you didn't say that Is there a map with Mars_temple2 already built, I don't have the time now to play to get it. Edited July 17, 2012 by fabio Quote Link to comment Share on other sites More sharing options...
myconid Posted July 17, 2012 Author Report Share Posted July 17, 2012 (edited) There seems to be a file missing in your 'merged' branch. I can't seem to compile it at the moment.Not very specific, though I think it should be there now.Lets try this one. Sorry, no specular yet - I got distracted by the water thread.Closer now! http://imgur.com/sCObbIs there a map with Mars_temple2 already built, I don't have the time now to play to get it.Added a test map for you. Edited July 17, 2012 by myconid Quote Link to comment Share on other sites More sharing options...
fabio Posted July 17, 2012 Report Share Posted July 17, 2012 Thanks, now I get this, with a load of:r300: ERROR: FS input generic 20 unassigned, not enough hardware slots (it's not a bug, do not report it).r300: ERROR: FS input generic 20 unassigned, not enough hardware slots (it's not a bug, do not report it). Quote Link to comment Share on other sites More sharing options...
myconid Posted July 17, 2012 Author Report Share Posted July 17, 2012 Thanks fabio! We've seen something similar before, if you recall. It means there are too many inputs to the fragment shader. I'll try to reduce them, though I don't know if that'll be possible. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 17, 2012 Report Share Posted July 17, 2012 You can probably merge some things together. In the ARB shader, to stay under the 8 texcoords used, I had to put the v_tex and the v_los vec2 together in a vec_4, for example. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 17, 2012 Author Report Share Posted July 17, 2012 You can probably merge some things together. In the ARB shader, to stay under the 8 texcoords used, I had to put the v_tex and the v_los vec2 together in a vec_4, for example.Yup, already did that and also reworked the math a bit. Hopefully it won't mind the crapload of uniforms that are getting merged from the modelmapping branch, though. fabio, please try it now! (and fingers crossed) Quote Link to comment Share on other sites More sharing options...
fabio Posted July 17, 2012 Report Share Posted July 17, 2012 OK, it improved somehow, now I no longer get the driver error but I get this: Quote Link to comment Share on other sites More sharing options...
myconid Posted July 17, 2012 Author Report Share Posted July 17, 2012 (edited) fabio, it worked! Some odd seams at the polygon edges, but I don't think we'll get any closer on your hardware.(and thanks for responding/testing!) Edited July 17, 2012 by myconid Quote Link to comment Share on other sites More sharing options...
fabio Posted July 17, 2012 Report Share Posted July 17, 2012 Thank to you for all the work!Once this is main svn I'll report a bug against the graphic driver, but I doubt there is a chance to see it fixed. 1 Quote Link to comment Share on other sites More sharing options...
k776 Posted July 17, 2012 Report Share Posted July 17, 2012 Merged branch compiled. Appears things working properly (though the bumpy roof effect is less obvious now(?)).I get this when enabling water reflections from Menu > Settings.ERROR: Failed to compile shader 'shaders/glsl/water_high.fs':ERROR: 0:100: No operator '*' exists taking 'int' and 'float' (and no implicit type conversion allowed in GLSL 1.10)ERROR: 0:101: Use of undeclared identifier 'shadow'ERROR: 0:106: Use of undeclared identifier 'fresShadow'ERROR: 0:108: Use of undeclared identifier 'colour' Quote Link to comment Share on other sites More sharing options...
myconid Posted July 17, 2012 Author Report Share Posted July 17, 2012 Merged branch compiled. Appears things working properly (though the bumpy roof effect is less obvious now(?)).The effect hasn't changed - it's because I'm using Wijitmaker's hand-crafted heightmap. I get this when enabling water reflections from Menu > Settings.Thanks for reporting. That's probably due to my laziness (i.e. I type 1 instead of 1.0), combined with the fact that ATI's GLSL compiler is very permissive so I don't get those errors. Imho, since GLSL describes itself as a C-like language (instead of Java or such), the compilers should be very permissive.But I digress. I've changed the water shader GLSL version from 1.10 to 1.20 to match all the other shaders, and it should work now. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 19, 2012 Author Report Share Posted July 19, 2012 (edited) I'm using a cubemap to simulate sky reflections on arbitrary water planes. Works pretty well, I think.http://imgur.com/a/vgOsbCode: https://github.com/myconid/0ad/tree/skycubemap Edited July 19, 2012 by myconid Quote Link to comment Share on other sites More sharing options...
zoot Posted July 19, 2012 Report Share Posted July 19, 2012 I'm using a cubemap to simulate sky reflections on arbitrary water planes. Works pretty well, I think.http://imgur.com/a/vgOsbNice. I assume the only limitation is that other objects won't be reflected?Well, for reflections at least, everything needs to be rendered upside down. The more reflections you have, the more times you need to re-render everything for each frame. For refractions you need to "cut out" the bottom of the water and render it separately to a texture.For reflections, would it not be sufficient to render once per angle of the reflecting plane? Quote Link to comment Share on other sites More sharing options...
Gen.Kenobi Posted July 19, 2012 Report Share Posted July 19, 2012 Not reflecting objects would look weird... Is this possible for the modder to change it he wish, or it's hardcoded? I mean, all water that is not in the ocean. Water in actors... I think you know what I mean. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 19, 2012 Report Share Posted July 19, 2012 For reflections, would it not be sufficient to render once per angle of the reflecting plane?You need to reflect the water height too. So for each height that has a water plane, you'd need to re-render the whole screen. Even with proper optimizations, given that the terrain is rarely perfectly flat, this would probably be a fairly big performance hit. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 19, 2012 Author Report Share Posted July 19, 2012 Nice. I assume the only limitation is that other objects won't be reflected?For reflections, would it not be sufficient to render once per angle of the reflecting plane?That's the limitation, and what wraitii said is correct.Not reflecting objects would look weird... Is this possible for the modder to change it he wish, or it's hardcoded? I mean, all water that is not in the ocean. Water in actors... I think you know what I mean. The water on the objects is completely moddable and separate from the ocean water. You can edit the parameters by creating as many materials as you need.The missing reflections aren't too noticeable, tbh, but you can tell they're missing if you're looking for them. The reflections are basically the only hardcoded thing I use, which are generated using a cubemap of the skybox textures. We do have a couple of options to improve this...A worthwhile side-project would be to add support for loading cubemaps through the usual texture manager (so basically custom cubemaps loaded from the actor xml). This would allow us to at least have self-reflections in the water, but not reflections of other objects or terrain. It would also let us fake materials that look like this.A more challenging, but higher quality, solution would be to actually render our own cubemaps when there are large changes in the game-world (e.g. only after a new building is completed). Each reflective object instance would need its own low-resolution cubemap (i.e. somewhat large memory usage), and would need 6 renderings of the game-world for each update. This would give us accurate results, and may not be too performance/memory intensive since there probably won't be too many of these reflections. Quote Link to comment Share on other sites More sharing options...
zoot Posted July 19, 2012 Report Share Posted July 19, 2012 Thanks.You need to reflect the water height too. So for each height that has a water plane, you'd need to re-render the whole screen. Even with proper optimizations, given that the terrain is rarely perfectly flat, this would probably be a fairly big performance hit.Is this the case even after culling? I mean, very little actual geometry would seem to have to be drawn on small reflective surfaces like those in myconid's screenshot. Quote Link to comment Share on other sites More sharing options...
zoot Posted July 19, 2012 Report Share Posted July 19, 2012 Also, if we combined culling with what myconid is suggesting (rendering cubemaps at large changes), the amount of geometry to render would be even smaller (it would be limited to things that move, like units). Quote Link to comment Share on other sites More sharing options...
myconid Posted July 19, 2012 Author Report Share Posted July 19, 2012 (edited) Is this the case even after culling? I mean, very little actual geometry would seem to have to be drawn on small reflective surfaces like those in myconid's screenshot.Yeah, I've been thinking about that. I'm concerned that the cost of culling may exceed that actual cost of rendering...Okay, here's what we can do for efficient culling: we divide each game map into regions and store the static models in a 2d array of hashmaps, where each array element corresponds to a separate region. Every time the reflections need to change, we use the 9 regions around the model to re-render its cubemap. Sounds workable to me..!On hardware that supports MRT, we can actually render all sides in a single pass!The only remaining question is the size of the cubemaps in memory. For reflections, 128x128 is probably enough and I think comes out at 400k per model. Not bad. Edited July 19, 2012 by myconid 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.