TextureBlend texture,blend
Parameters
|
texture - texture handle blend - blend mode: 0: replace - no blend 1: alpha 2: multiply (default) 3: add 4: dot3 bump 5: multiply x2 |
Description
|
Sets how a texture blends with the texture layer below it. This is about combining texture layers within one material, not about blending with the scene (that's EntityBlend). Layer 0 combines with the entity's own colour, layer 1 combines with the result of layer 0, and so on up the stack - each layer using its own TextureBlend mode. Multiply, the default, darkens: perfect for lightmaps and dirt over a base texture. Add brightens - glow maps. Alpha lays the texture over the layers below using its alpha channel - decals. Multiply x2 is like multiply but doubles the result, so mid-grey leaves the base unchanged and brighter values lighten it, the classic lightmap trick when lightmaps should be able to over-brighten. Dot3 treats the two layers as normal-map data for simple per-pixel bump lighting. Set the layer a texture occupies with the index parameter of EntityTexture or BrushTexture. See also: EntityBlend, EntityTexture, BrushTexture, TextureCoords. |
Example
; TextureBlend Example ; -------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() RotateEntity light,45,45,0 cube=CreateCube() PositionEntity cube,0,0,5 ; Two texture layers: the logo on layer 0, chrome on layer 1. ; Layer 1 blends down onto layer 0 using its TextureBlend mode. tex0=LoadTexture("media/b3dlogo.jpg") tex1=LoadTexture("media/Chorme-2.BMP") EntityTexture cube,tex0,0,0 EntityTexture cube,tex1,0,1 blend=2 While Not KeyDown(1) ; Keys 1-6 select blend modes 0-5 for the top layer If KeyHit(2) Then blend=0 If KeyHit(3) Then blend=1 If KeyHit(4) Then blend=2 If KeyHit(5) Then blend=3 If KeyHit(6) Then blend=4 If KeyHit(7) Then blend=5 blend_name$="do not blend" If blend=1 Then blend_name="no blend / alpha" If blend=2 Then blend_name="multiply (default)" If blend=3 Then blend_name="add" If blend=4 Then blend_name="dot3" If blend=5 Then blend_name="multiply 2" ; Set the blend mode used by texture layer 1 TextureBlend tex1,blend TurnEntity cube,0,1,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Keys 1-6: blend mode for the chrome layer Arrows: camera Esc: exit" Text 0,20,"TextureBlend tex1,"+blend+" ("+blend_name+")" Flip Wend End
Index