News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Anti Aliased Shape Rendering Effects (line mode)

Started by kevin, November 22, 2007, 12:27:08 AM

Previous topic - Next topic

kevin

 
   Here's some examples that use the Anti Alias shape (line mode) rendering features found in PB1.7x or above.


Tunnel Effect

This demo draws a bunch of ring shaped shapes perspectively, a bit like the old dot tunnel effect (from back in the day).  The main difference is that PB1.71a has anti aliased line rendering support for batched tasks like drawing the shape edges.



rings=500
RingSize#=600

FarDepth#=10000
NearDepth#=10

me=NewConvexShape(RingSize#,16)

Edges=GetShapeEdges(me,0)*rings


ClsColour=rgb(50,50,50)

Do
CLs ClsColour

ink $ffffff
mx=getscreenwidth()/2
my=getscreenheight()/2

thisrgb=rgb(50,20,210)
thisrgb= $ffffff

zstep#=(NearDepth#-FarDepth#)/Rings
near=0
far=fardepth#

projection#=400

For lp=0 to rings

x#=cos(angle#+lp*2)*455
y#=sin(angle#+lp)*255

z#=FarDepth#+(lp*zstep#)

ProjectedSize#=(RingSize#*projection#)/z#
Scale#=ProjectedSize#/RingSize#
rotateshape me,Angle#+(lp*10),Scale#

sx#=mx+((x#*projection#)/z#)
sy#=my+((y#*projection#)/z#)

ink RgbDepthCue(thisrgb,ClsColour,z#,near,far)

DrawShape me,sx#,sy#,1
next

ink rgb(255,255,255)
angle#=wrapangle(Angle#,1)

print fps()
print edges
Sync
loop






Ball Of Twine

This is slight variation of the previous demo,  this it's rendering 100K anti aliased lines. 


screenvsync on

rings =50
RingSize# =450

FarDepth# =5000
NearDepth# =510

me=NewConvexShape(RingSize#,15)

For lp=1 to 50
shape=NewConvexShape(RingSize#+(100*lp),17+lp)
MergeShape Shape,ME
DeleteShape Shape
next

ClsColour=rgb(50,50,50)


Surf=New3Dimage(GetScreenWidth(),GetScreenHeight())


Edges=GetShapeEdges(me,0)*rings

Do

CLs ClsColour
DrawAlphaIMage Surf,0,0,0.25,false



ink $ffffff
mx=getscreenwidth()/2
my=getscreenheight()/2

thisrgb=rgb(50,20,210)
thisrgb= $ffffff

zstep#=(NearDepth#-FarDepth#)/Rings
near=0
far=fardepth#

projection#=500

For lp=0 to rings
x#=cos(angle2#+lp*1)*255
y#=sin(angle2#+lp)*555

z#=FarDepth#+(lp*zstep#)

ProjectedSize#=(RingSize#*projection#)/z#
Scale#=ProjectedSize#/RingSize#
rotateshape me,Angle#-(lp*10),Scale#

sx#=mx+((x#*projection#)/z#)
sy#=my+((y#*projection#)/z#)

ink RgbDepthCue(thisrgb,ClsColour,z#,near,far)
; capturedepth z#

DrawShape me,sx#,sy#,1
next



ink rgb(255,255,255)
angle#=wrapangle(Angle#,1)
angle2#=wrapangle(Angle2#,1.1)





currentfps=fps()


text 0,0,CurrentFps
text 0,20,rings
text 0,40, edges

CopyRect 0,0,0,GetScreenWidth(),GetSCreenHeight(),surf,0,0

Sync

loop