CreateShaderMaterial()

Syntax

Result = CreateShaderMaterial(#Material, ShaderID)
Description
Creates a new shader based material.

Parameters

#Material A number to identify the new material. #PB_Any can be used to auto-generate this number.
ShaderID The shader identifier. CreateShader() is used to create a new shader. The ShaderID field must contain either
- the ID of a shader previously created with CreateShader()
- the ID of a predefined shader:
  #PB_Material_ColorShader
  #PB_Material_PerpixelShader
  #PB_Material_BumpShader
  #PB_Material_SkyShader
  #PB_Material_WaterShader
  #PB_Material_WaterShaderRTT
  #PB_Material_OceanShader
  #PB_Material_PointSpriteSphereShader
  #PB_MaterialShader_CubicEnvShader
  #PB_MaterialShader_CubicEnvBumpShader
Description of the predefined shaders:
  ___________________________________________________________________________________________
  #PB_Material_ColorShader
  
  Effect: uniform color in 'perpixel'.
  
  texture(s) : none
  
  MaterialShaderParameter : none
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor|#PB_Material_DiffuseColor, color)
  - MaterialShininess(#Material, Shininess , SpecularColor)
  - AmbiantColor
  - Fog
  - ScaleMaterial / ScrollMaterial / RotateMaterial
  
  ___________________________________________________________________________________________
  #PB_Material_PerpixelShader
  
  Effect: material in 'perpixel'
  
  texture(s) :
  - 0: sampler2D color
  
  MaterialShaderParameter : none
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor|#PB_Material_DiffuseColor, color)
  - MaterialShininess(#Material, Shininess , SpecularColor)
  - LightAttenuation
  - AmbiantColor
  - Fog
  - ScaleMaterial / ScrollMaterial / RotateMaterial
  
  ___________________________________________________________________________________________
  #PB_Material_BumpShader
  
  Effect: material with relief
  
  texture(s) :
  - 0: sampler2D color
  - 1: sampler2D normal
  
  MaterialShaderParameter :
  #PB_Shader_Fragment
  - float bumpy - default value: 1 (relief amplitude)
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor|#PB_Material_DiffuseColor, color)
  - MaterialShininess(#Material, Shininess , SpecularColor)
  - LightAttenuation
  - AmbiantColor
  - Fog
  - ScaleMaterial / ScrollMaterial / RotateMaterial
  
  remark(s):
  - the tangents must be defined (use 'BuildMeshTangent')
  ___________________________________________________________________________________________
  #PB_Material_SkyShader
  
  Effect: displays a sky with clouds and sun
  
  texture(s) :
  - 0: uniform sampler2D color (clouds)
  
  MaterialShaderParameter :
  #PB_Shader_Fragment
  - vec3 speed - default value: 10 0 0 (speed of clouds (X Z))
  - float height - default value: 200 (height of the 1st cloud layer)
  - int layer - default value: 2 (number of additional cloud layers)
  - float scale - default value: 4000 (texture scale)
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor, color): color of the sun sky at the zenith
  - SetMaterialColor(#Material, #PB_Material_DiffuseColor, color): color of the sky sun on the horizon
  - Fog
  
  ___________________________________________________________________________________________
  #PB_Material_WaterShader
  
  Effect : allows you to display a water surface
  
  texture(s) :
  - 0: sampler2D normal
  
  MaterialShaderParameter :
  #PB_Shader_Fragment
  - float scale - default value: 0.1 (texture scale)
  - float height - default value: 1 (wave height)
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_DiffuseColor, color): water color (Alpha: opacity)
  - SetMaterialColor(#Material, #PB_Material_SpecularColor, color): sky reflection color
  - Fog
  
  ___________________________________________________________________________________________
  #PB_Material_WaterShaderRTT
  
  Effect : allows to display a water surface with reflection (via RTT)
  
  texture(s) :
  - 0 : sampler2D normal
  - 1 : sampler2D RTT (render to texture)
  
  MaterialShaderParameter : none
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_DiffuseColor, color): water color (Alpha: opacity)
  - Fog
  - ScaleMaterial / ScrollMaterial / RotateMaterial
  
  ___________________________________________________________________________________________
  #PB_Material_OceanShader
  
  Effect : allows to display a water surface with waves
  texture(s) :
  - 0: sampler2D normal
  - 1: sampler2D color (foam)
  
  MaterialShaderParameter :
  #PB_Shader_Vertex
  - float wavebig - default value: 0.5 (wave amplitude)
  - float swell - default value: 0.5 (swell amplitude)
  #PB_Shader_Fragment
  - float wavelittle - default value: 0.5 (amplitude of "small" waves)
  - float foam - default value: 0.5 (foam)
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor, color): water color
  - SetMaterialColor(#Material, #PB_Material_DiffuseColor, color): color of the sky reflection
  - Fog
  
  remark(s):
  - the alpha value of the texture 'normal' contains the height of the wave
  
  ___________________________________________________________________________________________
  #PB_Material_PointSpriteSphereShader
  
  Effect: displays spheres at the vertices of the mesh
  
  texture(s) : none
  
  MaterialShaderParameter : none
  
  Taking into account :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor|#PB_Material_DiffuseColor, color)
  - MaterialShininess(#Material, Shininess , SpecularColor)
  - AmbientColor
  - Fog
  
  remark(s):
  - the material must be of type PointSprite : SetMaterialAttribute(0,#PB_Material_PointSprite,1)
  - the mesh must be of type PointList : CreateMesh(#Mesh,#PB_Mesh_PointList)
  - the radius of the sphere is defined by the texture coordinate U
  - the color of the sphere is defined by the vertex color
  example: MeshVertex(posX, posY, posZ, 10, 0,RGB(255,0,0))
  
  _______________________________________________________________________________________
  #PB_MaterialShader_CubicEnv
  
  Effect: reflection via cubic texture
  
  texture(s) :
  - 0: samplerCube cubemap
  - 1: uniform sampler2D color
  
  MaterialShaderParameter :
  #PB_Shader_Fragment
  - float glossy - default value : 0.5 (reflect intensity)
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor|#PB_Material_DiffuseColor, color)
  - AmbiantColor
  - Fog
  - ScaleMaterial / ScrollMaterial / RotateMaterial
  
  remark(s) :
  - cubic textures must be 'clamped': SetMaterialAttribute(#texture, #PB_Material_TAM, #PB_Material_ClampTAM)
  
  ___________________________________________________________________________________________
  #PB_MaterialShader_CubicEnvBump
  
  Effect: reflection via cubic texture with relief
  
  texture(s) :
  - 0: samplerCube cubemap
  - 1: sampler2D color
  - 2: sampler2D normal
  
  MaterialShaderParameter :
  #PB_Shader_Fragment
  - float glossy - default value : 0.5 (reflect intensity)
  - float bumpy - default value : 1 (relief amplitude)
  
  Taking into account of :
  - SetMaterialColor(#Material, #PB_Material_AmbientColor|#PB_Material_DiffuseColor, color)
  - MaterialShininess(#Material, Shininess, SpecularColor)
  - AmbiantColor
  - Fog
  - ScaleMaterial / ScrollMaterial / RotateMaterial
  
  remark(s) :
  - cubic textures must be 'clamped' : SetMaterialAttribute(#texture, #PB_Material_TAM, #PB_Material_ClampTAM)
  - the tangents must be defined (use 'BuildMeshTangent')

Return value

Nonzero if the shader based material was successfully created, zero otherwise. If #PB_Any was used for the #Material parameter, then the generated number is returned on success.

Supported OS

All

<- CreateShader() - Material Index - DisableMaterialLighting() ->