dynamic water (b3d port-over)
BlitzMax Forums/MiniB3D Module/dynamic water (b3d port-over)
| ||
I took the source from the codearcs (http://www.blitzbasic.com/codearcs/codearcs.php?code=991) and converted it to bmax using the import bb feature of maxide, and a little handy work. The only way it will run is using klepto2's extended version (not to mention VERY slowly), under the original it crashes at RenderWorld. I'm posting this because my lack of programming knowledge. If anyone knows why this is so slow or why it crashes with the original minib3d, please, post. heres a zipped up version: http://files.filefront.com/dynamic+waterrar/;9543932;/fileinfo.html (ORIGINAL) http://files.filefront.com/dynamic+waterv2zip/;9549915;/fileinfo.html (NEW) EDIT: SELF ERRROR !! as i was playing around with it in blitz3d, i changed the demo_water_height and demo_water_depth values, this is what slowed it down. heres the fix '--- change this: Global DEMO_WATER_WIDTH = 75 Global DEMO_WATER_DEPTH = 75 '--- to this: Global DEMO_WATER_WIDTH = 40 Global DEMO_WATER_DEPTH = 40 However, using sidesign.minib3d still crashes at 'RenderWorld.' FIXED |
| ||
Changed the code a bit to show control info. But it's showing the 3d stuff shaded, as if i drew an alpha'd rectangle over everything. (since sidesign.minib3d is crashing i modified klepto.minib3d for 2d, using the same exact code from sidesign.minib3d) FIXED: http://www.blitzbasic.com/Community/posts.php?topic=74544 using this test, however, it isn't shaded. Soo, can someone point out what's wrong in the dynamic water demo? FIXED: See above. |
| ||
Hmmm, it runs here on my version, although it does highlight an error with FitMesh not scaling the flat grids properly (they appear invisible). Can you step into RenderWorld to find out what specific line it's failing on? |
| ||
It fails the second render through the loop at TMesh.bmx:ln1947If surf.vbo_enabled=True glDrawElements(GL_TRIANGLES,surf.no_tris*3,GL_UNSIGNED_SHORT,Null) Else glDrawElements(GL_TRIANGLES,surf.no_tris*3,GL_UNSIGNED_SHORT,surf.tris) EndIf Probably just a graphics card problem. |
| ||
Very slowly sounds like you didn't use the imported bb code as base and convert it to true BM ... because if you don't it will use int -> obj conversion which is 20+ times slower. |
| ||
@Dreamora : Ofcourse you're right with this, but he also stated (edited) that this was because of modified values( actual the grid dense). For me I have tested the bbcode with the B3D demo and it is nearly the same speed as the bmx code. @simonh: I think this may rely on the same fitmesh bug i have reported to you. For the moment you could simply replace it by Scalemesh mesh,width,1,depth . @Plash: Add the BeginMax2D and EndMax2D code out of this thread at the end of your code and delete the TGlobal. in front of the related function calls in your main loop. http://www.blitzbasic.com/Community/posts.php?topic=74544 |
| ||
That fixed the shading problem with 2d. @Dreamora: I did an Import BB Project, and changed things until it ran. As for the slow-down, i simply forgot i had the quality values really high. |
| ||
klepto - no it was a different FitMesh bug. This one related to resizing flat surfaces. Plash, what happens when you set USE_VBO=False in minib3d.bmx? What gfx card do you have? |
| ||
ATI Radeon 7500 Turning off VBO's makes it run, but neither of the surfaces are visible. All I see is the ball bouncing around. Also, with the 2d part, TrisRendered() is not a function in sidesign.minib3d. (should it be?) With the functions klepto posted for max2d I get rectangles around where the text would be drawn. rectangles Using TBlitz2d.BeginMax2D and TBlitz2d.EndMax2D I get the shaded problem again. shaded |
| ||
Plash, in that case the crash bug might be driver related - the latest ATI driver is 8.1, do you have that? It might also fix your other problems. The invisible planes are due to a FitMesh bug, here's a fixed version: |
| ||
Woah!! that FitMesh function made it run ALOT faster (50fps, 20fps up from my avg), though i still have the problem with the text boundary rectangles (using klepto's begin and end max2d - gfx driver didnt fix TBlitz2d shading). The 8.1 update didn't change anything, not even the driver version. That was an update for newer models I think. The most recent version for radeon is 6.11, which I have. heres the funtion for klepto.minib3d (fixes the ceiling being invisible at beginning and the lag) Current dynamic water code (still needs location correction for pickmode): Using the updated fitmesh function in klepto.minib3d, I get nearly half the fps that I get with USE_VBO=False on sidesign.minib3d (about 25, using sidesign.minib3d 48-51). |
| ||
Edit - never mind, the newer driver is only for Radeons 9500 and newer. The reason for the current speed advantage over klepto's version is probably due to the UpdateNormals function written in C++. |
| ||
The reason for the current speed advantage over klepto's version is probably due to the UpdateNormals function written in C++ Considering that fact, it all should be written in C++ ;) |
| ||
Not really, as there wouldn't be much speed gain elsewhere. |
| ||
Changed it over to OO, I don't know what I'm doing wrong but after many variations I can't get the arrays to work in this: |
| ||
your problem is that you init the arrays at 0,0 and try to access them with anything larger. This W.bank1[FXWATER_MAX_WIDTH + 1, FXWATER_MAX_DEPTH + 1] W.bank2[FXWATER_MAX_WIDTH + 1, FXWATER_MAX_DEPTH + 1] Should be W.bank1 = new Float[FXWATER_MAX_WIDTH + 1, FXWATER_MAX_DEPTH + 1] W.bank2 = new Float[FXWATER_MAX_WIDTH + 1, FXWATER_MAX_DEPTH + 1] |
| ||
Thank you. SuperStrict version will be posted shortly, after I fix this weird update glitch. |
| ||
Fixed: OO & SuperStrict version. |
| ||
How would this work on an irregular surface? (i.e. same surface it uses but some faces deleted to create different shapes, like for terrain lakes/ponds etc) Just looking for a point in the right direction.. EDIT: Use a TMap (uneducated guess), or a type for each individual face? Another idea is to use the same setup, only to define different boundaries for the edges of the effect (no clue how.) |