; Short fur on an original animated plush bear. Extended mode only.
Include "_common\ShowcaseCamera.bb"
Include "_common\FurPlush.bb"

Graphics3D 960,600,0,2:SetBuffer BackBuffer():HDRRendering True:AntiAliasMode 3
font=LoadFont("Segoe UI",16):If font Then SetFont font
camera=CreateCamera():PositionEntity camera,0,1.6,-6:CameraClsColor camera,26,39,49
aim=CreatePivot():PositionEntity aim,0,1.4,1:PointEntity camera,aim
AmbientLight 55,60,68
light=CreateLight():RotateEntity light,28,-35,0:LightColor light,255,231,192
LightShadows light,True,10
floor=CreateCube():ScaleEntity floor,6,.06,8:PositionEntity floor,0,-.08,3:EntityColor floor,85,106,113
fur=LoadShader("builtin:fur")
If fur=0 Then RuntimeError "Unable to load built-in fur"
ShaderFloat fur,"Length",.045:ShaderFloat fur,"Tiling",64:ShaderFloat fur,"Thickness",.6
ShaderFloat fur,"Density",.85:ShaderFloat fur,"WindStrength",0
reference=CopyShader(fur):ShaderInt reference,"ShellCount",0
bear=LoadFurPlush("showcase\assets\fur_plush.glb",fur,-1.35,0,1)
smooth=LoadFurPlush("showcase\assets\fur_plush.glb",reference,1.35,0,1)
length#=.045:density#=.85:shells=16:paused=False:wind=False:enabled=True:aa=3
ResetShowcaseCameraTimer()
furLastTime=MilliSecs()
While Not KeyHit(1)
    now=MilliSecs():dt#=(now-furLastTime)/1000.0:furLastTime=now
    If dt>.1 Then dt=.1
    UpdateShowcaseCamera camera,3,65
    If KeyHit(57) Then enabled=Not enabled
    If KeyHit(25) Then paused=Not paused
    If KeyHit(35) Then wind=Not wind
    If KeyHit(20) Then aa=(aa+1) Mod 4:AntiAliasMode aa
    If KeyHit(2) Then shells=0
    If KeyHit(3) Then shells=8
    If KeyHit(4) Then shells=16
    If KeyHit(5) Then shells=24
    If KeyHit(6) Then shells=32
    If KeyDown(26) Then length=length-dt*.035
    If KeyDown(27) Then length=length+dt*.035
    If length<0 Then length=0
    If length>.15 Then length=.15
    If KeyHit(51) Then density=density-.05
    If KeyHit(52) Then density=density+.05
    If density<0 Then density=0
    If density>1 Then density=1
    ShaderFloat fur,"Density",density
    ShaderFloat fur,"Length",length
    count=shells:If Not enabled Then count=0
    ShaderInt fur,"ShellCount",count
    windAmount#=0:If wind And (Not paused) Then windAmount=.3
    ShaderFloat fur,"WindStrength",windAmount
    If Not paused Then UpdateWorld dt*60
    RenderWorld
    Color 20,30,38:Rect 0,0,960,128,True:Rect 0,560,960,40,True
    Color 245,235,215:Text 16,14,"FUR / ANIMATED PLUSH     LEFT: coat     RIGHT: smooth reference"
    Text 16,36,"1-5 shells 0/8/16/24/32: "+shells+"    [ / ] world length: "+length
    Text 16,58,"SPACE coat: "+enabled+"   P paused: "+paused+"   H wind: "+wind+"   T AA: "+aa+"   ,/. density: "+density
    Text 16,80,"Short coats work best. Long lengths expose shell layers at grazing angles."
    Text 16,102,"Eyes, nose and paw pads retain separate materials. Pause removes wind deflection."
    DrawShowcaseCameraHelp 570:Flip
Wend
End
