News:

Function Finder  Find all the functions within source code files

Main Menu

Super Sampling Demo

Started by kevin, March 27, 2020, 10:02:59 AM

Previous topic - Next topic

kevin

PlayBASIC Source Code -  Super Sample Demos -  (28th March 2020)


This little demo is a combination of some older effects, written many years ago that dabbled with doing super sampling approximations in PlayBASIC in plain old software rendering.

 The effects are drawn to an external buffer that's twice the needed size,  then blurred and bilinear filtered when drawn.  Which gives a fairly nice looking result.  The demo is frame limited, but even without that, it's pretty slow.  Would be more efficient to do the sampling and blurring together.


 Video:
 


For example code & tutorials
http://playbasic.com  / https://underwaredesign.com


Music:  Heaven_and_Hell  by Jeremy Blake


PlayBASIC Code: [Select]
; PROJECT : Super Sampling Demos
; AUTHOR : Kevin Picone - PlayBASIC TUTOR
; CREATED : 26/03/2020
; EDITED : 28/03/2020
; ---------------------------------------------------------------------

positionscreen getscreenxpos(),getscreenypos()-50
Screen=NewFxImage(getscreenwidth()*2,GetScreenHeight()*2)

Type tCamera
x#,y#
X1#,y1#
x2#,y2#
Angle#
AngleStep#
EndType

Dim Camera as tCamera
Camera = new Tcamera

Camera.x1=GetImageWidth(Screen)/2
Camera.y1=GetImageHeight(screen)/2

Camera.x2 = Camera.x1
Camera.y2 = Camera.y1

Camera.AngleStep = rndrange#(1,2)

frames=30
setfps 20


do

Super_Sampled_Particle_Sprinkler(Screen)
Super_Sampled_Tunnel(screen)
Super_Sampled_Ring(Screen)

frames-=1

loop spacekey()=true or frames <0
end

Function NewCamPosition(Screen)

StartX=Camera.x2
StartY=Camera.Y2


Radius# =rndrange(50,150)
Angle# =rnd#(360)

EndX=StartX+CosRadius(Angle#,Radius#)
EndY=StartY+SinRadius(Angle#,Radius#)

Camera.x1=StartX
Camera.y1=StartY

pad=250
Camera.x2 =cliprange(endx,pad,GetImageWidth(Screen)-pad)
Camera.y2 =CLIPRANGE(endy,pad,GetImageHeight(screen)-pad)

Camera.AngleStep = rndrange#(1,5)
EndFunction


Function StepCamera(Screen)
Status=false
angle#=Camera.Angle + Camera.AngleStep
if angle#>90
NewCamPosition(Screen)
Angle#=0
Status=true
endif

X1=Camera.x1
Y1=Camera.Y1
X2=Camera.x2
Y2=Camera.Y2


// max distance from point 1 to point 2
Dist#=GetDistance2d(x1,y1,x2,y2)

// Compute Radius
Radius#=sin(Angle#)*Dist#

// normal from point 1 to point 2
nx#=(x2-x1)/Dist#
ny#=(y2-y1)/Dist#

// compute new point along the line from p1 to 2
// at this radius
x#=x1+nx#*RAdius#
y#=y1+ny#*RAdius#


Camera.x =x#
camera.y = y#
Camera.Angle#=Angle#

EndFunction Status


Function Super_Sampled_Tunnel(screen)


repeat


rendertoimage Screen
inkmode 1+2048
boxc 0,0,GetImageWidth(Screen),GetImageHeight(screen),true,$f8e8a8
inkmode 1

x=Camera.X
y=camera.y

Offset=MOd(Offset+10,80)
inkmode 1+64

for lp=0 to 100
Depth=100+(lp*80)+Offset
size=(500*500)/Depth
TunnelRing(Angle#+lp,x,y,size)
next

angle#=wrapangle(angle#,2)

inkmode 1
Blurimage Screen,9.1
rendertoscreen
drawrotatedimage screen,0,0,0,0.50,0.50,0,0,false+8

Sync

until StepCamera(Screen)=true


EndFunction


Function TunnelRing(Angle#,x,y,size)

StepValue=10

For lp=0 to 359 step StepValue
angle2#=wrapangle(angle#,lp)
x2=x+cos(angle2#)*size
Login required to view complete source code



Related Articles

     - Into the Light  (Shape Tunnel Variant)