Jump to content

Oh No, I Broke Josh's Waterplane!


Guest Red Ocktober
 Share

Recommended Posts

Guest Red Ocktober

i dunno what's happening here today, but it seems as if i'm having a coding epiphany :D ... or something... :):lol:

 

anyways... i finally got some water with real waves (on the cpu using a simple sin function) with josh's water shader... it's not all that pretty, but at least i can see some waves...

 

check out the short video below (open the zip and play)

 

still got a bit to do to make it acceptable for government work...

 

i'm using a mesh with 2178 vertices and still getting around 70 frames per sec in an 8x6 window...

 

 

 

 

--Mike

Link to comment
Share on other sites

8x6 window

 

[~] <---- hmm its a little small ...

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Guest Red Ocktober
[~] <---- hmm its a little small ...

the better to keep the framerate up my dear :)

 

How did that train get up there? Dag'um

yeah.... who left that thing up there... :lol:

 

 

i hope you release some code to us that been waiting for something like this

sure... it's nothing spectacular... right now the code is in all over the place... but it's not difficult at all to follow... actually, it's quite simple...

 

 

in Renderer.bmx i load my own mesh instead of using the mesh that is originally created... search for waterpatch and this segment of code (the commented stuff is the original code)...

 

			'Create water mesh and prepare
		If Not waterpatch
			SetWorld transparency.world
			'         waterpatch=CreatePatch(20,20)   
			waterpatch=LoadMesh("abstract::OceanLakePond.gmf")
			EntityOcclusionMode(waterpatch,True)
			SetWorld Main.world
		EndIf

 

then a few lines under that i messed around with the scale and the position...

 

			waterpatch.paint(watermaterial[submerged])
		'          waterpatch.SetScale(vec3(Main.camera.farrange*3.0))
		waterpatch.SetScale(vec3(.5,.25,.5))
		'   waterpatch.SetPositionf(Main.camera.mat.tx,waterheight,Main.camera.mat.tz,1)
		waterpatch.SetPositionf(0,waterheight,120,1)

 

 

the actual function to animate the water is in the calling program... in the main loop slip in...

 

If fw.renderer.waterpatch Then  AnimateWaves(fw.renderer.waterPatch)

( the leadwerks water is referenced fw.render.waterPatch )

 

 

then add this function...

 

Function AnimateWaveMesh(theWater:TMesh)
  Local vertex:TVec3[2180]
  Local theWaves:TSurface
  Local lwWaves:TSurface
  Local waveFreq:Float

  theWaves=GetSurface(theWater,1)

   For Local i:Int =0 To 2177
     Local waveFreq:Float=MilliSecs()/16
     vertex[i]=GetVertexPosition(theWaves,i)
     vertex[i].y=Sin( waveFreq+vertex[i].x*50 + vertex[i].z*30)*5
     SetVertexPosition (theWaves,i,vertex[i])
   Next 

EndFunction

 

 

as you can see i've got a lot of stuff hard coded... and i'm sure there's a better way to organize everything... this was just the results of a sudden hot flash i had today... don't know where it came from...

 

i'll be looking into putting back the original large ocean plane and doing a lot of other fixesa lil later... just glad to have found a way to implement this after so long...

 

dunno why it took me soooo long... i was looking for something a lil more complicated...

 

 

oh yeah... the mesh im using for the water (something i had lying around from way back in the original 3DRAD days, so you might wanna make a better one) converted over to gmf... get it below and put it in your path... rename the extension to .gmf...

 

 

--Mike

OceanLakePond.zip

Link to comment
Share on other sites

is the mesh at the origin and you are not? it covers only a small area, you maybe looking at the underwater divide

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

what you mean at origin? Mesh covering exact area i need to cover and i did exactly what he did(according to code i saw), but waterpatch surface(custom one) is white and i see it..its just..no reflection and stuff I got with usual one(createpatch)..just wondering what can go wrong or is there any other way to treat mesh waterpatch..

 

Link to comment
Share on other sites

Just started playing with it myself, but when I first tried I was in the wrong place, there was a white area that marked the divide for submerged but no water mesh .. I did a new scene and put myself at the centre and there it was :) just wondered if that was your issue? .. only been playing with it for half an hour was just thinking out loud.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Guest Red Ocktober

hey there diedir... how ya doin :) yeah... i finally got a lot of legal stuff done and i had a few days to actually pay attention to what i'm doing... now i gotta spend some time learning how to texture the sub and interior... always something... :D

 

 

NaughtyA asks:

..hmm..strange, when i load custom mesh as a water surface, it is loaded but just blank white?? Anything special you did with water mesh before actual load in to program Red ?? I havent add waves, just loaded mesh as a waterpatch..

nothing special... i just replaced the default mesh josh creates in Renderer.bmx with the plain untextured mesh... the code in Renderer.bmx should apply the shader to it...

 

the scene you load should have a waterplane in it... you can try using Marley's simple scene loading code ( http:// http://leadwerks.com/werkspace/index.php?/topic/670-a-simple-scene-loader-in-blitzmax/ ) to load a scene with some water and terrain (try to make sure the errain and the player start are near the center of your map, else mod the code in Renderer.bmx to place the waterPatch at the desired location like Marley alluded to)...

 

or... you can edit this line in Renderer.bmx, and the water should appear anywhere the camera is located in the scene...

 

	'waterpatch.SetPositionf(Main.camera.mat.tx,waterheight-1,Main.camera.mat.tz,1)
waterpatch.SetPositionf(EntityPosition(Main.camera).x,waterheight-1,EntityPosition(Main.camera).z,1)

 

 

i still have to do a bit of work with this before it is ready for prime time... for instance, i still need to whip up some code to implement my 3 x 3 treadmill system here so that the water will appear infinite from the viewer (can anyone point me to cloning code or logic for LW)... plus some method of making this universally usable without invalidating the original stuff...

 

also... Josh... could you add some foam to the textures like there was in the earlier versions...

 

 

--Mike

Link to comment
Share on other sites

..still white..super weird...i did try this before but i had same result..white..but i had other things to do so i never tested again until now, when i saw that Red changed it and its working..however..in my case still doesnt work..everything is at proper position, it just, water plane is white..hmm..

 

Link to comment
Share on other sites

..sure..here it is..

'Create water mesh and prepare
		If Not waterpatch
			SetWorld transparency.world
			'waterpatch = CreatePatch(20, 20)
			waterpatch = LoadMesh("abstract::patch.gmf")
			EntityOcclusionMode(waterpatch, True)
			SetWorld Main.world
		EndIf
		waterpatch.SetColor(watercolor)
		waterpatch.paint(watermaterial[submerged])

		'waterpatch.SetPositionf(Main.camera.mat.tx,waterheight,Main.camera.mat.tz,1)
		waterpatch.SetPositionf(1, waterheight, 1, 1)

 

and of course, after every changes, I did compile module to make changes work..but so far nothing..here is the patch example i use..so give it a go..im really wondering is it something maybe wrong with my gmf.

 

waterpatch mesh:--> http://www.mediafire.com/?o1mgzkkrwbc

 

Link to comment
Share on other sites

Guest Red Ocktober

code looks ok... ( i never did module recompile, don't think u need to)

hhhhhmmmmm...

 

i dunno NA... are you running 2.3 or 2.31... (shouldn't make a difference though)...

 

looking at your mesh now...

 

--Mike

Link to comment
Share on other sites

Guest Red Ocktober

Naughty, try using my mesh (get it above)...

 

download it, change the extension from zip to gmf... put it in your path... reference it in loadmesh...

 

 

 

i substituted your mesh to test, and i started getting unusual errors from the default renderer code...

 

 

--Mike

Link to comment
Share on other sites

just rename the .zip to .gmf its a gmf file not a zip archive. :)

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...