Jump to content

Water texture and shader??


Rick
 Share

Recommended Posts

So in materials/water I see a water.mat and it has:

 

texture0="abstract::water01DOT3.dds"

texture1="abstract::wobbleDOT3.dds"

texture7="abstract::caustics.dds"

castshadows=0

shader="abstract::mesh_diffuse.vert","abstract::water.frag"

//depthmask=0

 

 

But I don't see any of those dds files.

Link to comment
Share on other sites

It's done in Renderer:

 

 local watertime:float = (apptime() / 200.0 * wavespeed)
 local waterframe:int
 local framename:string

 waterframe = watertime Mod 32
 framename = waterframe
   if waterframe < 10 framename = "0" + framename
   if not watertexture[waterframe]
     watertexture[waterframe] = loadtexture("abstract::water02_" + framename + ".dds")
   endif

 ' .............

 setmaterialtexture(watermaterial[submerged], watertexture[waterframe], 6)
 setmaterialtexture(watermaterial[submerged], watertexture[Modulate(waterframe-1,32)], 0)  

 ' .............

 function Modulate:float(a:float, b:float)
   a = a Mod b
     if a < 0 a = b + a
    return a
 endfunction

 

The rest can be found in Renderer in the Draw method/function.

Link to comment
Share on other sites

Hmm, I did:

 

SetWorld(world_transparency)

object.plane = CreatePlane()

object.mat = LoadMaterial("Models/Entities/Pi/Pi-Water/water4.mat")

object.plane:Paint(object.mat)

SetWorld(world_main)

 

But got the same result. If I open the dds in Paint.NET and change transparency to 125 or below then it doesn't show up at all.

Link to comment
Share on other sites

I have a transparent texture working on a model in the Editor but again its just using the alpha test shader to allow complete transparency over the face area of a hair mesh . That's simply using the mesh_diffuse_alphatest.frag shader defined in the material file and it works fine. I just tried substituting it for the mesh_diffuse_alphablend.frag shader but that doesn't work, the transparent area shows up as opaque black!

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

For the windows that are transparent in the shots from Jeklynn Heights I just used a blend=1 in the material:

 

texture0="abstract::barborshop_windows_d.dds"
clamp0=0,0,0
texture1="abstract::barborshop_windows_n.dds"
clamp1=0,0,0
texture2="abstract::barborshop_windows_s.dds"
clamp2=0,0,0
texture3="abstract::barborshop_windows_selfillum.dds"
clamp3=0,0,0
blend=1
depthmask=1
depthtest=1
overlay=0
zsort=1
cullface=0
castshadows=1
specular=2.50000000
bumpscale=1.00000000
gloss=0.100000001
bakeaomap=1
raytraced=1
shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap_specularmap_glow.frag"
shadowshader="abstract::refraction.vert",""

 

Ignore bakeaomap and raytraced and the selfillum stuff, that is all some custom shader work we did that isn't related to the transparency.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Actually I think I got it. I used the material editor, which didn't display it very well, and it looks better in the editor. Now I have to see if I can apply the sway shader to get it to move.

 

 

Hmm, I have:

 

shader="abstract::mesh_diffuse_bumpmap_sway.vert","abstract::mesh_diffuse_bumpmap_specular_glow.frag"

shadowshader="abstract::refraction.vert","abstract::ambientlight.frag"

 

but no sway.

Link to comment
Share on other sites

This is pretty cool, but I have to ask, why aren't you just using the default Leadwerks water shader applied to the plane?

 

Then you can just render all your puddles like the single infinite water plane, and there you go...

 

EDIT: I guess because the water shader doesn't seem to work when applied to other meshes, lol. Answered my own question.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

lol, yeah, I couldn't get it to work.

 

About the puddles being a single infinite water plane, the problem with the infinite water plane is the height of things. If my castle is high on a mountain I can't have an infinite plane for the water. I need a plane that I can control the size of. This would also work for things like swimming pools or like a wishing well. Anything that needs water that can't be done with the 1 single infinite plane.

 

I might actually have to change this to a cube though because currently no matter what if the camera x & z are in the bounds of the plane and the camera y is < the water plane y it'll do the underwater effect to the screen. This limits having tunnels under the water plane because even though visually you aren't in water, if your tunnel goes under the water plane it would apply the underwater effect. With a cube I could limit the water on all sides. This cube could just be a body I guess.

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...