Grainy camera effect

Blitz3D Forums/Blitz3D Programming/Grainy camera effect

Grovesy(Posted 2006) [#1]
Hi there i'm after a visual effect that makes the camera view look grainy/ slightly pixelated, does anyone know how I can acheve this?

It doesn't need to be particually fast as its not going to be used to render every frame, its being used for just one frame every now and then.

Cheers


John Pickford(Posted 2006) [#2]
perhaps render to a smaller viewport - say 1/4 the screen size. Copy that to a texturebuffer and then draw a sprite using that texture which fills the screen. Should look quite blocky and be reasonably fast. You might be able to draw this with some transparency over the normal image rather than as a total replacement.


stayne(Posted 2006) [#3]
put a cube just in front of the camera with low alpha, a grainy texture and then maybe randomize the UVs?


Jams(Posted 2006) [#4]
Ahoy Grovesy,

I would put a sprite in front the camera with a simple monochrome noise texture on it, then shifting the texture a suitably long distance in random directions should make it look like authentic white noise being generated each frame.

Adjusting the size of the noise texture would give you a more blurred or sharper result..


big10p(Posted 2006) [#5]
If it's a whitenoise/interference effect you're after, try this:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1183


skyfire1(Posted 2006) [#6]
if you want a half-life type grainy you can turn off mimapping.


Grovesy(Posted 2006) [#7]
Pickford: Like your idea of stretching the image to make it pixely but have not idea how to code this lol. Any change of a simple demo?

I might then combine this with the big10p piece of code which i will alter slightly. Hope thats ok big10p :) you will both get a thanks in the credits :)

Cheers guys


big10p(Posted 2006) [#8]
Code in the archives is public domain. You're free to do whatever you please, with it. :)


Grovesy(Posted 2006) [#9]
Hate to post just to bump my post to the top of the list (Bad me :( ) but I really could do with some code to do what John Pickford said
Quote:
"perhaps render to a smaller viewport - say 1/4 the screen size. Copy that to a texturebuffer and then draw a sprite using that texture which fills the screen. Should look quite blocky and be reasonably fast"

Cheers


Sir Gak(Posted 2006) [#10]
This request is a scream. Pixelation has been the bane of programers who try to make true-to-life appearing graphics, and you WANT to look pixelated? LOL


Jams(Posted 2006) [#11]
Umm i don't see what's so funny about it Gak, it's obvious he's only doing it as a special effect in certain situations....


Stevie G(Posted 2006) [#12]
Something like this .... untested and you'll need to play with the texturescale and spritescale due to power of 2 textures etc.. and screen aspect etc...


global QGW = graphicswidth()*.25
global QGH = graphicsheight()*.25
global MainCam = createcamera()
global PixelCam = createcamera()
global PixelTex = createtexture( QGW , QGH )
global PixelSprite = createsprite( MainCam )
positionentity PixelSprite , 0, 0, 1
scalesprite PixelSprite , ?? , ?? ; 
scaletexture PixelTex, ??, ??
textureblend PixelTex , 3  ; additive blend or maybe use entityalpha 


In the main loop ....

Cameraprojmode MainCam, 0
Cameraprojmode PixelCam, 1
renderworld()
copyrect 0,0, QGW, QGH , 0, 0, backbuffer(), texturebuffer( PixelTex )
cameraprojmode PixelCam, 0
cameraprojmode MainCam, 1
renderworld()
flip


This should give you a basis, if you need a working example then give me a shout.

Stevie