Give 3d objects a pixelated 3d fx by Cliff Mellangard 3DEGS11th Aug 2018 13:45
|
---|
Summary I neaded a fx to give my 3d a snes look. Description This uses the render to image to give all 3d a pixelated look without shaders. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com // Project: pixel 3d fx // Created: 2018-08-11 // show all errors SetErrorMode(2) // set window properties SetWindowTitle( "pixel 3d fx" ) SetWindowSize( 1024, 768, 0 ) SetWindowAllowResize( 1 ) // allow the user to resize the window // set display properties SetVirtualResolution( 1024, 768 ) // doesn't have to match the window SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts obj=CreateObjectBox(10,10,10) for t=1 to 1000 ob=instanceobject(obj) //CreateObjectBox(10,10,10) setobjectposition(ob,0-200+random(0,400),0-50+random(0,100),0-180+random(0,360)) setobjectcolor(ob,random(0,255),random(0,255),random(0,255),255) next t setcameraposition(1,0,240,-350) setcamerarotation(1,45,0,0) ang=0 pixel_scale=2 Capture=CreateRenderImage( 1024/pixel_scale, 1024/pixel_scale, 0, 0 ) canvas=1 spr=createsprite(0) Setspritesize(spr,1024,1024) time=120 do //setobjectvisible(obj,1) SetRenderToImage(Capture,0) //setspriteposition(spr,0-10000,0) displayed=0 dec ang,2 for t=obj to obj+1000 setobjectrotation(t,0,ang,0) setobjectvisible(t,1) if GetObjectInScreen( t ) then inc displayed DrawObject(t) setobjectvisible(t,0) next t SetRenderToScreen() if getimageexists(canvas) then deleteimage(canvas) canvas=copyimage(Capture,0,0,1024/pixel_scale,1024/pixel_scale) SetImageMagFilter(canvas,0) SetImageMinFilter(canvas,0) setspriteimage(spr,canvas) //setspriteposition(spr,0,0) print("No shader realtime 3d pixel fx in app game kit by the gamecreators.") print("Experimental fx for not another retro pixel game") print("All source code at the gamecreators forum") print("objects = "+str(displayed)) Print( ScreenFPS() ) dec time if time<0 time=120 inc pixel_scale,2 if pixel_scale>20 then pixel_scale=2 deleteimage(capture) Capture=CreateRenderImage( 1024/pixel_scale, 1024/pixel_scale, 0, 0 ) SetImageMagFilter(capture,0) SetImageMinFilter(capture,0) endif Sync() SetRenderToImage (Capture,0) ClearScreen() //sleep(6000) loop |