; WorldAssetShader Example ; ------------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ; The crate that will receive the shader crate=CreateCube() PositionEntity crate,0,1,0 EntityColor crate,80,170,255 ; Load the asset manifest world in the background manifest=LoadWorldAsync("../../../samples/worlds/asset-preload.world") While Not WorldReady(manifest) If WorldLoadState(manifest)=WORLD_LOAD_FAILED Then RuntimeError WorldLoadError(manifest) Cls Text 0,0,"Loading the asset manifest..." Flip Wend ; The shader asset uses manual loading policy: resolving the handle ; starts preparing its packaged bytecode in the background shader_asset=FindWorldAsset(manifest,"display-shader") shader=0 While Not KeyDown(1) error$=WorldAssetError(shader_asset) ; Once ready, WorldAssetShader returns an ordinary shader reference If shader=0 And WorldAssetReady(shader_asset) shader=WorldAssetShader(shader_asset) EntityShader crate,shader EndIf TurnEntity crate,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,"Arrow keys: move camera Esc: exit" If shader Text 0,20,"WorldAssetShader applied the 'World Asset Tint' shader to the crate" ElseIf error<>"" ; The packaged release ships the shader bytecode beside the manifest Text 0,20,"The shader asset could not be prepared:" Text 0,40,Mid(error,1,70) Text 0,60,Mid(error,71,70) Else Text 0,20,"Preparing the shader asset..." EndIf Flip Wend FreeWorld manifest If shader Then FreeShader shader End