VividGL3D 2D_Example2

Community Forums/Showcase/VividGL3D 2D_Example2

AntonyWells(Posted 2004) [#1]
This one shows Pixel shaded 2d.


Requires a card capable of pixel shaders2.0.

http://www.excess.eclipse.co.uk/2D_Example2.rar

This one shows full screen image blurring. You can move the mouse left/right to make the image appear more shape/out of focus.

You can change the image in the media folder, if you wish.

Also, in the shaders folder is the cg file used(Just a pixel shader) in english script form. SO, you can actually edit play around with the shader and rerun.

If the shader is not compatible you'll get a error.

Here's the blitz source

Include "Includes\VividGL_Lite.bb"
Graphics_Init(640,480,16)
glSetbuffer Graphics_Back()
;-

smokeTex=glLoadTexture("Media\full.jpg",glMipMap)
blurSkin=Skin_BlurTexture() ;Blur texture is a built in skin, using pixel shaders2.0


While Not KeyDown(1)
	glCls(False)

	skin_blurFactor(blurSkin,blurFactor#)
      blurFactor#=(MouseX()/640.)*0.02
	fxSkinOn(blurSkin) ;activate pixel shader fx for all following ops. (For meshes, you can set fx on a per surface basis or use this method. both have their advantages)
      Lock2D()
	      activate_Texture(smokeTex,0)
		Render_Quad(0,0,640,480)
	Unlock2D()
	fxSkinOff() ;Turn off shader
	
	glText 1,1,"Move mouse Left/Right to change blur factor"
	glFlip(False)
Wend



Here's the actual pixel shader used. The blur happens in one pass.

struct vertout
{
	float4 position : POSITION;
	float3 texcoord0 : TEXCOORD0;
};

struct pixel
{
	float4 color : COLOR;
};

pixel main(vertout IN,
	   uniform sampler2D Texture: TEXUNIT0,
	   uniform float4 blur)
{
pixel OUT;
float3 comb,final;
float2 tempUV1=IN.texcoord0.xy;
float2 tempUV2;
float blurFactor=blur.x;
	tempUV2.x=tempUV1.x-blurFactor;
	tempUV2.y=tempUV1.y-blurFactor;
	comb=tex2D(Texture,tempUV2);
	tempUV2.x+=blurFactor;
	comb+=tex2D(Texture,tempUV2);
	tempUV2.y+=blurFactor;
	comb+=tex2D(Texture,tempUV2);
	tempUV2.y+=blurFactor;
	comb+=tex2D(Texture,tempUV2);
	tempUV2.x+=blurFactor;
	comb+=tex2D(Texture,tempUV2);
	tempUV2.y-=blurFactor;
	comb+=tex2D(Texture,tempUV2);
	tempUV2.x-=blurFactor*2;
	comb+=tex2D(Texture,tempUV2);
	tempUV2.y+=blurFactor;
	comb+=tex2D(Texture,tempUV2);
	tempUV2.x+=blurFactor*2;
	tempUV2.y-=blurFactor*2;
	comb+=tex2D(Texture,tempUV2);
	OUT.color.rgb=comb/9;
	OUT.color.a=1;
	return OUT;
}



Dreamora(Posted 2004) [#2]
hey why have you "pulled out" the file why I was downloading ;)


Braincell(Posted 2004) [#3]
same here >:\


AntonyWells(Posted 2004) [#4]
Yeah, sorry about that. It should be back up now.


Caff(Posted 2004) [#5]
yep works ok


GameCoder(Posted 2004) [#6]
Works nice here.


Dreamora(Posted 2004) [#7]
works fine :) ( ah a notebook with VS2, PS2 is just nice ;) )


Daz(Posted 2004) [#8]
No problems here on main PC.

Not going to bother using it on my laptop as its spec is shockingly bad!! :P


Paul "Taiphoz"(Posted 2004) [#9]
that just looks like you got 3 images with a slight alpha and your scalling em..

its nice though.


AntonyWells(Posted 2004) [#10]
Nope, for every texel the shader reads 9 texels pushed out by the blur factor, averages them down and then passes that out as the main color. The shader is editable in notepad, so you can mess about with it for yourself. That's the beauty of shaders, nothing hard-coded.


Rob(Posted 2004) [#11]
Works fine! Blurs, but the blur is more like doubling up...

I'd like to see a shader that does proper heat shimmer as that seems to be quite fashionable.


Caff(Posted 2004) [#12]
Yeah make a nice far cry-type sun glare effect :)


AntonyWells(Posted 2004) [#13]
Heh actually be meaning to do one..I'll do a little 3d-ish 2d demo with some cloudes, a sun, rain, and reflective water. Then i'll be moving onto some 3d examples though...so if any of you have anything 2d-wise you'd like to see demonstrated in it, ask now ;)

Rob, I have a depth of field with distance based heat-shimmer.(I.e pixels further in the distance shimmer, per-pixel) just need to find a level that shows it off well.

The blur method will be improved btw. It's on the right track, it looks fine(imo) until you blur it too much, and like you say it doubles up on it's self.


Jeremy Alessi(Posted 2004) [#14]
Cool.


jhocking(Posted 2004) [#15]
me no likey rar


Picklesworth(Posted 2004) [#16]
Nice effect. It's more like going cross-eyed than a blur, but I still like it, as always.


AntonyWells(Posted 2004) [#17]
Thanks SoggyBear. :) I've succeded where others havn't. (Wanted me to.) ;p

Pickle, ta. (Too camp? I'm really not you know...)


Jeremy Alessi(Posted 2004) [#18]

I've succeded where others havn't. (Wanted me to.) ;p



Just to clarify ... I've wanted you to get something done ... and I think anyone else around here who ever criticized you did too.

It was more a matter of this guy's got talent ... why does he talk so much and not make a finished product to sell ... so let's jump all over his case.

Great job again, and I'm sure you're going to clean up with Vivid, especially with no BMax 3D module to start with.


AntonyWells(Posted 2004) [#19]
Cheers J, but really, I don't honestly believe you or anyone wanted me to fail. Remember, 95% of what I post is not meant to be taken seriously, and the other 5% is.... not meant to be taken seriosuly.

If I'm being honest, I brought it on myself with all the wildly inaccurate release dates/demos that never appeared. (Not the trolling...I take no blame for the mental shortcomings of others, just the general aura of 'It'll never be released')