watermaterial.monkey2 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. Namespace mojo3d
  2. #rem monkeydoc The WaterMaterial class.
  3. #end
  4. Class WaterMaterial Extends Material
  5. #rem monkeydoc Creates a new water material.
  6. #end
  7. Method New()
  8. ShaderName="materials/water"
  9. AttribMask=1|4|8|32
  10. BlendMode=BlendMode.Opaque
  11. CullMode=CullMode.None
  12. ColorTexture=Texture.ColorTexture( Color.White )
  13. ColorFactor=Color.SeaGreen
  14. Metalness=0
  15. Roughness=0
  16. NormalTextures=New Texture[]( Texture.FlatNormal(),Texture.FlatNormal() )
  17. Velocities=New Vec2f[]( New Vec2f( 0,0 ),New Vec2f( 0,0 ) )
  18. End
  19. Method New( material:WaterMaterial )
  20. Super.New( material )
  21. End
  22. #rem monkeydoc Creates a copy of the water material.
  23. #end
  24. Method Copy:WaterMaterial() Override
  25. Return New WaterMaterial( Self )
  26. End
  27. Property ColorTexture:Texture()
  28. Return Uniforms.GetTexture( "ColorTexture" )
  29. Setter( texture:Texture )
  30. Uniforms.SetTexture( "ColorTexture",texture )
  31. End
  32. Property ColorFactor:Color()
  33. Return Uniforms.GetColor( "ColorFactor" )
  34. Setter( color:Color )
  35. Uniforms.SetColor( "ColorFactor",color )
  36. End
  37. Property Metalness:Float()
  38. Return Uniforms.GetFloat( "Metalness" )
  39. Setter( metalness:Float )
  40. Uniforms.SetFloat( "Metalness",metalness )
  41. End
  42. property Roughness:Float()
  43. Return Uniforms.GetFloat( "Roughness" )
  44. Setter( roughness:Float )
  45. Uniforms.SetFloat( "Roughness",roughness )
  46. End
  47. Property NormalTextures:Texture[]()
  48. Return New Texture[]( Uniforms.GetTexture( "NormalTexture0" ),Uniforms.GetTexture( "NormalTexture1" ) )
  49. Setter( textures:Texture[] )
  50. Assert( textures.Length=2,"NormalTextures array must have length 2" )
  51. Uniforms.SetTexture( "NormalTexture",textures[0] )
  52. Uniforms.SetTexture( "NormalTexture0",textures[0] )
  53. Uniforms.SetTexture( "NormalTexture1",textures[1] )
  54. End
  55. Property Velocities:Vec2f[]()
  56. Return New Vec2f[]( Uniforms.GetVec2f( "Velocity0" ),Uniforms.GetVec2f( "Velocity1" ) )
  57. Setter( velocities:Vec2f[] )
  58. Assert( velocities.Length=2,"Velocities array must have length 2" )
  59. Uniforms.SetVec2f( "Velocity0",velocities[0] )
  60. Uniforms.SetVec2f( "Velocity1",velocities[1] )
  61. End
  62. End