VividGL 2D_Example 3

Community Forums/Showcase/VividGL 2D_Example 3

AntonyWells(Posted 2004) [#1]
Shall be releasing the first 3d demo tonight or tomorrow hopefully, however, in the meantime here is the 3rd 2d demo.

http://www.excess.eclipse.co.uk/2D_Example3.rar (2.7mb)

This one shows off a variety of things,

1. Pixel shader 2.0 fx again.(The logos shimmer.)

2.Vivid's (C++ wrote) particle system. Despite being 3d, it works fine in 2d(Has a seperate 2d renderer)..when using it in 2d, Z = the particles size. Used to render flaming stars with vapour trails.

3.Using direct (Not wrapped) openGL code natively within a vivid product. (Not that you ever have to, this is just an example of how easy it is to acctually write plugins for the 3d/2d engine.

The gl portion renders the starfield.



Also, there's a hidden 'cheat' that lets you specify how many stars to render. I'll give you a clue..it happens at start up, or not at all.

Also, since we last meet the Texture engine has been rewrote from the ground up in C++(Overdue.) and now much like b3d, uses freeimage to load media...so any problems in that area.

As always, please report any bugs, performance issues etc, and I'll do my best to fix them before release.



Here's the blitz source

Include "Includes\VividGL_Lite.bb"
Graphics_Init(640,480,32,2)
glSetbuffer Graphics_Back()

Global NumStars= 1100

Global starTex=Texture_Load("Media\smoke1.png")
Texture_Blend starTex,2
If starTex=0 End

Global StarParticle=CreateParticle( starTex) 
Particle_SetAlpha StarParticle,1,0.02
Particle_SetWeight starParticle,0

Const logos=2
Local Logo[logos+5]
For j=1 To logos
	logo[j]=Texture_Load("Media\logo"+j+".jpg")
	Texture_Blend logo[j],2
Next

blurSkin=Skin_BlurTexture()
Whoosh=LoadSound("Dat\move1.wav")
FadeIn=LoadSound("Dat\FadeIn1.Wav")
blurFactor#=0.3
SoundPitch(fadeIn),12000
PlaySound(FadeIn)
InitStars() ;-Demo function, not a part of vivid. See below.
cLogo=2
While Not KeyDown(1)
	glCls(False)
	
	If KeyDown(2) blurFactor=0.5
	skin_blurFactor(blurSkin,blurfactor)
	blurFactor#=blurFactor*0.975
	If blurFactor#<0.001 And slideOut=0
		Chan=PlaySound( Whoosh)
		SlideOut=True
	EndIf
	If SlideOut
		logoX=logoX+16
		blurFactor=blurFactor*1.01
		If logoX>1000
			logoX=0
			PlaySound(FadeIn)
			slideOut=0
			blurFactor=0.3
			cLogo=cLogo-1
			If cLogo<1 cLogo=2
		EndIf
	EndIf
	Particle_Update()
		lock2d()
			Render_Particle2D()
			demo_Stars()
		unlock2d()
		
            lock2D()
		      FxSkinOn(blurSkin)
 	  		Texture_Activate logo[clogo],0
				Cls_Z()
				Render_Begin()
						Render_QuadFast(320-160+LogoX-LogoAd,240-80-LogoAd,320+LogoAd*2,160+LogoAd*2)
				Render_End()
				FxSkinOff()
		Unlock2D()
	glText 1,1,"Move mouse Left/Right to change blur factor"
	glFlip(False)
Wend


;--[ Star Lib]-[ Demo Code Only.]

Const Star_X=1,Star_Y=2,Star_Z=3
Dim star#(NumStars+100,8)
Global starTo,starFrame

Function initStars()
	Dim star#(NumStars+100,7)
	For j=1 To numStars
		star(j,1)=Rnd(-0.5,1)
		star(j,2)=Rnd(0.5,1)
		If Rand(3)=1
			star(j,1)=-star(j,1)
		EndIf
		If Rand(3)=1
			star(j,2)=-star(j,2)
		EndIf 
		star(j,3)=Rnd(0,0.01)
		star(j,4)=320
		star(j,5)=240
		If Rand(400)=1
			star(j,6)=1
		EndIf
	Next
	starTo=numStars
	starFrame=4
End Function
Const zAmp# = 255*256
Global camp#,camt#,camr#
Function Demo_Stars() ;Demonstrates how you can blend pure native gl code with vivid seemlessly.
glPushMatrix()
glLoadIdentity()
Local starPos=CreateBank(128*4)
glBegin(GL_LINES)
		For j=1 To NumStars
				dx#=320+star(j,1)*star(j,3)
				dy#=(240+star(j,2)*star(j,3))
				cv#=star(j,3)/255
				cv=cv*0.2
				If cv<0 cv=0
				If cv>1 cv=1
					
				glColor4f cv,cv,cv,1
				If star(j,6)=0
				glVertex2f dx,dy
				glColor4f cv/3,cv/3,cv/3,1
				glVertex2f star(j,4)+(star(j,4)-dx)*8,star(j,5)+(star(j,5)-dy)*8
				Else
					emitParticle( starParticle,dx,dy,star(j,3)*0.15,Rnd(-0.4,0.4),Rnd(-0.4,0.4),Rnd(-1,1)) 
				EndIf
				star(j,4)=dx
				star(j,5)=dy
				star(j,3)=star(j,3)+8
				If dx<0 Or dx>640 Or dy<0 Or dy>480
	                  	star(j,1)=Rnd(-1,1)
		                  star(j,2)=Rnd(-1,1)
				      star(j,3)=0.01
					star(j,4)=320;star(j,1)
					star(j,5)=240;star(j,2)
				EndIf
		Next
glEnd()
glPopMatrix()
Return 
End Function








Michael Reitzenstein(Posted 2004) [#2]
I'll give you a clue..it happens at start up, or not at all.

You pass it via command line?


GameCoder(Posted 2004) [#3]
This looks cool ant.

It runs smooth and fast. I like the blur routines on the images.

Well Done. :)


AntonyWells(Posted 2004) [#4]
Thanks amon.

Micheal, not a bad idea, but nope.


hub(Posted 2004) [#5]
'user lib not found' is there a pb with my config ?


AntonyWells(Posted 2004) [#6]
That means a .dll is missing. Please make sure you have installed all .dlls from the archive in the same folder as the exe.

I'm tempted to say it must work, as it ran for Amon..although I'm not sure if amon is going by the shot or the demo, because there are no blurring routines.(amon?)


slenkar(Posted 2004) [#7]
it 'worked' for me coz I got a 'cant do pixel shaders error'

please include an option to run without pixel shaders,for the 3d demo
also,for a laff gis the same demo in blitz 3d so we can compare FPS.
OpenGL (some people say) renders better than DX.
My models always look better in Ultimate Unwrap than blitz for example

Its only a model....shhhh!


AntonyWells(Posted 2004) [#8]
Slenker, a non pixel shader version will be uploaded after dinner. :)

But, in all seriousness I can't replicate this in Blitz3D, as blitz3D does not have high-speed 3d powered 2d, nor does it have pixel shaders support, nor does it have a built in 2d/3d particle engine.

Not to say I couldn't kludge together something that purely in terms of final outcome looks the same, it would be done in a very different(Much more complicated) fashion.
VividGL is about freeing your mind to create. I really want to have a system in which you never have to code a sub-system to compliment it.


AntonyWells(Posted 2004) [#9]
Just to clarify, when I say I could not do this in Blitz3D, I mean using B3d's built in engine.
All these vivid demos are obviously coded in blitz3D the language(Vivid it's self coded in C++/Blitz/Pb)


slenkar(Posted 2004) [#10]
ah ok nice one lad but i was talking about a demo of 300 animated soldiers or 300 spinning cubes so we can compare the FPS


GameCoder(Posted 2004) [#11]
Hey,

What I meant by the bluring is the way the images of dreamspace and vividgl blur. It states on screen to move the mouse left or right to alter the blur.

I thought the startfield was cool also by the way.

Nice job :)


AntonyWells(Posted 2004) [#12]
Slenker, Oh, gotcha. That will happen sooner rather than later.

It should be interesting to compare a 1.2million poly scene side by side with blitz.

But, just to give you an idea of what to expect,
If you had a g5, a scene consisting of 100 spheres, totalling 1.2million polys, one version will get roughly 90fps, the other will get roughly 1fps.
-

Amon, OK thanks for clearing that up. Thought you had one too many and everything was getting blurry :)


Picklesworth(Posted 2004) [#13]
Pretty cool. The images changing was a bit fast though - I didn't get a great idea of the blur shader.


TeaVirus(Posted 2004) [#14]
"Unable to compile pixel shader >CG ERROR: The profile is not supported."

Darn. I guess the graphics chipset in my work laptop is too old. I think it's the equivalent of a Radeon 7000 or somehting like that (Radeon Mobility). I'll have to wait until I get home. Screenshot looks nice though!


Perturbatio(Posted 2004) [#15]
I get userlib not found.


TartanTangerine (was Indiepath)(Posted 2004) [#16]
I get "Internal Error" :(


AntonyWells(Posted 2004) [#17]
Tea Virus, this demo requires pixel shaders2.0(g5+ or similar ati card)

You can use pixel 1(I.e g3) shaders and g2 vertex shaders, plus it works with emulation mode drivers.(Meaning you can run g6 code on a g4, in software. Not that you would want to, but the option is there)
-

I really can't think what .dll is missing. The fact it works for some,and not of yous makes it even stranger.
Think it's time I merged everything into a single runtime .dll..


puki(Posted 2004) [#18]
Worked okay for me - no problems - AMD 64bit - 9800 Radeon


Vorderman(Posted 2004) [#19]
Can you please hurry up and release the 3D demo ? :)

I like using OGL and all this waiting is boring.


AntonyWells(Posted 2004) [#20]
Heh, doing my best. But I do have the first(official first that is) 3d demo up and running...shows off normal-mapping, without pixel/vert shaders, on a very nice door model did by the artist i'm working with on the uber tech demo.

So, hopefully soon. I'm tempted to say 'tonight' but we all know what happens when I say that...


Paul "Taiphoz"(Posted 2004) [#21]
runs slow here.

Why not add a fps counter so we can see just how fast its running.

it could be doing 15 frames per second and still look smoth so just going by how smoth it looks isnt enough.


Dreamora(Posted 2004) [#22]
yepp second the fps counter, it is quite hard to say how many fps it has ... ( a problem with all Vivid samples so far )


AntonyWells(Posted 2004) [#23]
Fps count was not the point of these demos. In those where fps is central to the 'demonstration', for example Lod and octree demos, there will be fps counters.


Klaas(Posted 2004) [#24]
got a
"unable to compile pixel shader >CG ERROR: The profile is not supported"

on a NVIDIA GeForce4 Ti 4600 with the latest drivers


Sweenie(Posted 2004) [#25]
Don't think GF4 Ti 4600 supports PShader 2.0


angel martinez(Posted 2004) [#26]
The example runs very well in my computer(G5).
In Rendermonkey 1.5( the shader tool from Ati) there is a nice example of an ocean-water effect(refraction and such) made with OGL.Is going to be possible to code anything like that with VividGL?
I hope so !!!


AntonyWells(Posted 2004) [#27]
Is it possible? Most definitely. :)

In fact, I've just coded a segmented patch creator to aid with water/terrain, so perhaps in the next demo.


angel martinez(Posted 2004) [#28]
Cool!, Thanks.