I know this has alot of different names for it. And it's been a dream of mine to try and do, put sadly have tried many times, without any success.
All, I know is that it uses a blur routine and somehow layers the main effect pixels, so it looks as though it's feeding back, i guess alpha plays apart.
I use the array method, when I render stuff. Ie, ARGBScreen(x,y)=Colour. So if you could show me, how to pull this effect off, I'd appreciate it if the code can be that way. As Im not too hot on using banks at the moment. Once I know the basics to it, and can grasp it, i'll proceed onto banks: banks to me are Dim ARGBScreen( XRES * YRES ). I find im better at using ARGBScreen( XRES, YRES )
If anyone knows how to do this, that would be awesome and thankyou times infinity. It'll be a dream come true :)
Cheers and hugest thanks,
Clyde.
I might be wrong here because I have never coded a radial blur routine, I've seen many demos with it done though and I'd imagine that you need to be able to grab the image you want to blur as a texture, blur the image and scale it, pasting it many times in a circle around the centre of the image, scaling it up as you rotate around the object.
Probably the cheapest way of doing this would be to do say 4 passes per frame, drop your four images around in a circular motion, re-grabbing the screen into the texture and scaling up as you go.
I know how to do it using sprites or billboard mesh (I always know the lazy way :) )
Grab the screen to a texture buffer apply the texture to the billboard
Overlay the billboard mesh over the main screen with an offset (sin cos or size change) and alpha blending
Grab that screen and do over as many times as you want the blurr.
really no blur needed if the alpha and offsets are used correctly
final screen will look like blur or video feedback depending on alpha applied and radius of the blur.
Probably not the best way but one way using 3dengine.
Some demos use shaders to do the effect - which is hardware dependent
Since I don't know anything about FB I would say this would be done in software by buffer arrays.
I'm after doing this in 2D and not 3D, cheers matey though.
Thanks Shockie, that sounds so easy explained like that. But for some reason I cant seem to get it down into code. :(
Cheers and many thanks,
Clyde.
Do you have any demo example that show it ?
Because "Radial Blurring" and "Video Feedback" are two different things for me.
To me they are the same matey. Sadly, I dont. All i've got for Radial Blurring if it is different, is the one by optimus in his Keftdes demo.There was a demo at BlitzCoder, which I dont have on this machine.
Check out this webpage, this is what I know by video feedback effect.
http://freespace.virgin.net/hugo.elias/graphics/x_feed1.htm
Im not too sure mate. Looks good and might be the ticket.
What im hoping to do, is to apply this to a good proportion of the screen.
But i wont be going anywhere unless, I can get the brain in gear to do this. hehe
Cheers,
Clyde
Radial Blur is as I understand it where you blur everything from a center point and out in a circle and various radius of that circle is more blured as you move away from the center point. I think it might be rather difficult to pull this one off in software rendering, and very few does it using 3D hardware because it takes a good number of rendering each frame.
Video Feedback is where you keep the last screen and draw something on top of it and then each frame the previous frame is usually rotated and blended. Easy to do with 3D hardware, probably not easy to do with software rendering since its an entire screen you need to manually rotate and blend each frame.
Could you show us what you have so far code wise and perhaps we can better help you along. [edit] an example of how the effect you are after looks like would help a lot in understanding what you are trying to do.
I'd love to show you some code, but unfortuneatly where I am at the moment I dont have access to Freebasic, as all my stuff is back at home. If I can find the demo i saw done in B2D from BlitzCoder Showcase, or even once I am home in a couple of days I'll show you what I mean. And I vaguely remember it being called Feedback loops. And Shockie is on the right track me thinks, I just need to try it out. The theory is there in my mind, im just having probs replicating it in code.
Thanks for the responses dudes,
Cheers and all the best Clyde.
Optimus did a nice radial blur in his Keftedes demo, there were two versions of it, one was GFXlib2 based, the other was SDL. I'd agree with Zawran that it will probably be slow to do in software.
Ok, I'll have a look at those when I get home later. Im not bothered with speed issues.
It requires alot of overdrawing which is way it's going to be slow in software, was this kind of effect i originally tried to do before I made Visible Echos, but it didn't really turn out that way and looked more like a fake glow which didnt seem to go down that well. Even in hardware using 3d it can be a frame rate killer, I think nowadays it would likely be done with a shader.
http://rel.betterwebber.com/junk.php?id=1
3rd or fourth effect. In QB so it would be easy to translate. :*)
Cheers Relsoft :)
I'll take a look as soon as Im awake. Thankyou.
Im having big difficulties in converting the Feedback stuff into FreeBasic dude, mainly as I've not touched QBasic ever. It's a little confusing.
I'll put this on my to do list for the future.
Cheers,
Clyde.
Well,. there is a diferrence between these terms I'll try to explain.
For me there is a diferrence between radial blur and feedback effect.
First of all, the way that people usually do radial blur in hardware acceleration differs from the one in software. In the hardware accelerated demos what people call radial blur, is what looks like radial blur but is actually more similar to video feedback in technique. That's why perhaps some people confuse radial blurring with the feedback effect.
The pure feedback effect is like those nifty WinAMP visualizations, where you draw small shapes and those zoom and blur towards your view. I've done this in my old quickbasic demo "Into The Fight" and it all involves, 1) Writting the original shapes in buffer1, 2) Calculating a slightly zoomed version (the magnitude can be 1.05x or 1.1x or 1.25x, but to be only a bit slightly bigger than 1x is better, though by changing the value in realtime you can make cool stuff) of the original buffer and writting the resulting screen in buffer2, 3) blurring this one in buffer2. In the next frame you have to zoom and blur the already zoomed and blurred buffer! Zoomblur of zoomblurred buffer of zoomblurred buffer,etc. creates that effect of smokey shapes coming into your face. Maybe from one part to the other one you need many diferrent buffers, but I think it's only essential for the zooming thing (originally, I zoomed from buffer1 to the same one but I got the zoomed pixels to zoom them again and not from the original shape, that was wrong and produced wrong results. But for the blurring, even if others insist to use diferrent buffers, I have no problems to do it in one and the same buffer). Someone can add rotation too, something I had not done by the time but I am willing to try again.
As for the radial blur, smokes don't come. You just see a static blurring in radial way of a 2d shape, 3d scene or anything. And for an explanation, if you blur by using: up+down+left+right pixel values and then divided by 4, you get the most simple blur (used in fire effects and stuff). Then I had discovered that if you blur: left+right divided by 2, you get horizontal blur. So, the idea here is that the direction of the way you sample pixels, results in the direction of the blurring in the screen. So, in radial blur, it seems like the blurring direction comes from the pixel you want to blur towards the center of the screen in the same radius. So,. when I first wanted to code that effect I thought. Mmm,. I have a big array for each pixels which tells me the direction to blur for each pixel (Some dx, dy) and I multiply that direction by a small number I get the neighbour pixels towards that radius. Add and divide then..
..but. When I did this, I said what the heck? There was hardly any good result, I didn't got the true radial blur of the demos. What I had discovered is: In order to get this, I had to grab a big ammount of pixel samples (could be from 64 to 256) towards the radius of each pixel, only this way I could blur enough radialy my image, which was of course way TOO slow. I was searching desperately for a tutorial on that but I think I found one with a solution (of how most democoders do the radial blur working fast and looking neat in software), no more helping tutorials in this subject though (That's why I am thinking to write one more for a basic diskmag in the near future). The concept is maybe hard to explain and can't find the link to the original tutor right now. Someone can still sample only few ammount of pixels (2,3,4 at worst 8) and have great results. There is no need for excessive pixel sampling here. It evolves something like... mmm.. do you remember at the previous paragraph I said that if source and destination of zooming/blurring/sampling is from the same buffer or from buffer1 to buffer2, is questionable? Here,. the trick is to use that problem to our advance. There are 4 loops. Each one starting from the center of the screen. The screen is divided in 4 windows. For the upper left, you start calculating the radial blur from the center pixel of the screen, moving to the left and up. For the upper right, the direction of your loop through your pixels is right and then up to the next line middle pixel to the left, and right. Hard to explain. But if doing this blur from buffer1 to buffer1, the same one, it's like you are blurring pixels the you already blurred before and put the result in the same buffer. So, some pixels are blurred and reblurred, as we get pixel samples from the already blurred pixels,. it's like a feedback in pixel sampling I'd say ;). This way, there is overblurring like the blurring multiplies itself and you get the radial blur effect with only 4 neigboor pixels towarsd the center and not 64 as it was needed at first. The problem here is that (and seen in many PC demos, it's very common visual bug in many classic demos) there is an annoying cross in the middle of the screen, slightly seen. Maybe blurring with a regular blur at those points would hide it more..
Maybe I'll find the tutorial and post it here. But I am thinking now more of writting one tutorial on both feedback and radial blur for QBCM or so.
Oh and in the accelerated world, they do radial blur in a much easier way. There is a function which is I think RenderToTexture something, and you can take your video buffer of the 3d scene you are rendering and use it as a bitmap for a texture. So you can have 3d upon cubes in OpenGL too. And stuff like that. This is OVERused in 3d accel demos on PC. For doing something that people call radialblur on PC accel demos and it really looks like radial blur, though it's not exactly the same technique as the pixel software thing. Simply, render your scene, get the buffer of that scene as a texture and now render it slightly closer (like you are zooming it a bit by 1.25x for example, reminds the feedback explanation) and blend the zoomed scene in the real scene. Now! The blend of those two is one new scene. Repeat the previous thing and you have two blended scenes zoomed a bit and blended with the originals. Four blends. Now do the same and you see that you have 8 blended and one more zoomed than the other. Render the scene, render to texture, zoom and blend the texture to the orig screen, get the result and repeat. You understand the recursivety, that produces a blend of several screens zoomed that really looks like radial blur in a way if done well (I don't know because I haven't tried it on OpenGL yet). The good thing is that 16 blended screens, really need 4 blends in reality, because of the technique (Getting the blended of the blended of the blended). 256 screens need only 8 blends of the render buffer. So,. for so many blends that radial blur needs, only few blends of the OpenGL are needed (and 3d accelerators do this fast enough today, but software would be still too slow with 8 alpha blends I think, the software radial blur algorithm is better for software but maybe much harder to implement)
I wrote too much here so I stop. Maybe I'll write more comprehensible stuff in my article..
Yeah, here's is the GL radial blurring:
'Radial blur byt relsoft
Option Explicit
'$Static
'$INCLUDE: "\gl\gl.bi"
'$INCLUDE: "\gl\glu.bi"
'$INCLUDE: "\gl\glfw.bi"
'$INCLUDE: "\gl\glext.bi"
const SCR_WIDTH = 640 'Width of the screen
const SCR_HEIGHT = 480 'height of the screen
const BITSPP = 32 '32 bits per pixel format
const GL_TEXT_WID = 512
const GL_TEXT_HEI = 512
const PI = 3.141593
const TWOPI = (2 * PI)
CONST S_SLICES= 32
CONST S_BANDS = 32
CONST S_RADIUS = 1.0
Type DisplayType
W As Uinteger
H As Uinteger
R_BITS As Uinteger
G_BITS As Uinteger
B_BITS As Uinteger
A_BITS As Uinteger
D_BITS As Uinteger
S_BITS As Uinteger
MODE As Uinteger
GlVer As Zstring Ptr
As Single FOVy, Aspect, zNear, zFar
End Type
type polytype
p1 as integer 'vertex 1 of our triangle
p2 as integer 'huh?
p3 as integer
u1 as single
v1 as single
u2 as single
v2 as single
u3 as single
v3 as single
col as single
end Type
Type Supa_shape
as single a,b
as single m
as single n1,n2,n3
End type
type vector3d
as single x
as single y
as single z
end type
type textuv
as single u
as single v
end type
Declare Sub Init_GL_Window( Display As DisplayType )
declare SUB Init_GL_SCREEN()
declare sub vector_normalize (v as vector3d)
declare sub super_shape_torus (model() as vector3d, modeltext() as textuv, byval radius as single,_
byval slices as single, byval bands as single, byval a as single, byval b as single,_
byval m as single, byval n1 as single, byval n2 as single, byval n3 as single)
declare sub glDraw()
declare sub lathing (model() as vector3d, poly() as polytype, rings, bands)
declare function init_glow_texture() as GLuint
declare sub RenderToTexture()
declare sub RenderGlow( times as integer)
declare sub draw_torus()
declare sub glEnable2D()
declare sub glDisable2D()
Dim Display As DisplayType
Init_GL_Window Display
Init_GL_SCREEN()
redim shared model ((S_SLICES * (S_BANDS + 1) )-1) as vector3d
redim shared model_text((S_SLICES * (S_BANDS + 1))-1) as textuv
redim shared model_norm((S_SLICES * (S_BANDS + 1))-1) as vector3d
dim as single ss_a, ss_b, ss_m, ss_n1, ss_n2, ss_n3
ss_a = 1
ss_b = 1
ss_m = 8
ss_n1 = 1.26
ss_n2 = 1.0
ss_n3 = .7380
super_shape_torus (model(), model_text(), S_RADIUS,S_SLICES,S_BANDS,_
ss_a, ss_b, ss_m, ss_n1, ss_n2, ss_n3)
redim shared model_tri(1) as PolyType
lathing (model(), model_tri(), S_SLICES, S_BANDS)
Dim FileNam as String
Dim shared torus_texture as GLUINT
dim shared glow_texture as GLUINT
GlEnable GL_Texture_2D
GlGenTextures 1, @torus_texture
glBindTexture GL_Texture_2D, torus_texture
Filenam = "bloodrock.tga"
If NOT GlfwLoadTexture2D( FileNam, GLFW_BUILD_MIPMAPS_BIT) Then
GlfwTerminate()
Print "Failed to load image!!!"
sleep
End
End If
glow_texture = init_glow_texture()
dim time_start as single
Do
GlClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT OR GL_STENCIL_BUFFER_BIT
GlMatrixMode GL_MODELVIEW
GlLoadIdentity
glDraw()
do
loop until timer - time_start >= (1/60)
time_start = timer
GlfwSwapBuffers
Loop Until glfwGetKey( GLFW_KEY_ESC )
GlfwTerminate()
sub glEnable2D()
dim vPort(3) as integer
glGetIntegerv(GL_VIEWPORT, @vPort(0))
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glOrtho(0, vPort(2), 0, vPort(3), -1, 1)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
end sub
sub glDisable2D()
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
end sub
function init_glow_texture() as GLuint
dim as GLuint txtnumber
dim as unsigned integer ptr texture_data
texture_data = callocate((GL_TEXT_WID * GL_TEXT_HEI)* 1 ,Len(unsigned Integer))
glGenTextures(1, @txtnumber)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, txtnumber)
glTexImage2D(GL_TEXTURE_2D, 0, 4, GL_TEXT_WID, GL_TEXT_HEI, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
deallocate (texture_data)
glDisable(GL_TEXTURE_2D)
return txtnumber
end function
sub RenderToTexture()
'render geometry
draw_torus()
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, glow_texture)
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, GL_TEXT_WID, GL_TEXT_HEI, 0)
glClearColor(0.0, 0.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glDisable(GL_TEXTURE_2D)
end sub
sub RenderGlow( times as integer)
'ViewOrtho
glEnable2D()
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, glow_texture)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
dim i as integer
dim as single zoom= 0
glBegin(GL_QUADS)
for i = 0 to times-1
zoom = i/75.0f
glColor4f(1.0, 1.0, 1.0, 0.53/i)
glTexCoord2f(0+zoom,0+zoom)
glVertex2f(0,0)
glTexCoord2f(0+zoom,1-zoom)
glVertex2f(0,SCR_HEIGHT)
glTexCoord2f(1-zoom,1-zoom)
glVertex2f(SCR_WIDTH,SCR_HEIGHT)
glTexCoord2f(1-zoom,0+zoom)
glVertex2f(SCR_WIDTH,0)
next i
glEnd()
glDisable2D()
glDisable(GL_BLEND)
glEnable(GL_DEPTH_TEST)
glDisable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D,0)
end sub
sub glDraw()
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
GlMatrixMode GL_MODELVIEW
glLoadIdentity()
glViewPort 0,0,GL_TEXT_WID,GL_TEXT_HEI
RenderToTexture()
'return to screen size
glViewPort 0,0,SCR_WIDTH,SCR_HEIGHT
RenderGlow(20)
end sub
sub draw_torus()
static as integer theta = 0
dim as integer i
theta += 1
glPushMatrix()
glTranslatef(0.0,0.0,-5)
glRotatef(theta, 1, 0, 0)
glRotatef(theta, 0, 1, 0)
glRotatef(theta, 0, 0, 1)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, torus_texture)
glBegin GL_TRIANGLES
for i = 0 to Ubound(model_tri)
glNormal3fv @model_norm(model_tri(i).p1).x
glTexCoord2fv @model_text(model_tri(i).p1).u
glVertex3fv @model(model_tri(i).p1).x
glNormal3fv @model_norm(model_tri(i).p2).x
glTexCoord2fv @model_text(model_tri(i).p2).u
glVertex3fv @model(model_tri(i).p2).x
glNormal3fv @model_norm(model_tri(i).p3).x
glTexCoord2fv @model_text(model_tri(i).p3).u
glVertex3fv @model(model_tri(i).p3).x
next i
glEnd
glDisable(GL_TEXTURE_2D)
glPopMatrix()
end sub
sub super_shape_torus (model() as vector3d, modeltext() as textuv, byval radius as single,_
byval slices as single, byval bands as single, byval a as single, byval b as single,_
byval m as single, byval n1 as single, byval n2 as single, byval n3 as single)
'a1 = abs(cos(m*theta/4)/a)^n2
'a2 = abs(sin(m*theta/4)/a)^n3
'r(theta) = (a1+a2)^(-1/n1)
'
'x = r*(theta) * cos(theta) * r*(phi)* cos(phi)
'y = r*(theta) * sin(theta) * r*(phi)* cos(phi)
'z = r*(phi) * sin(phi)
'
'-pi/2 <= phi <= pi/2
'-pi <= theta <= pi
dim as integer i, sliceloop, bandloop
dim as single phi, theta
i = 0
dim as single r1, r2, a1, a2
static as single text_off=0
text_off += 0.0000041926 '* gtime
dim as single Tpi_d
Tpi_d = (TWOPI)/Bands
dim as single Ppi_d
Ppi_d = (TWOPI)/slices
phi = -Pi/2
FOR SliceLoop = 0 TO Slices - 1
a1 = abs(cos(m*phi/4)/a)^n2
a2 = abs(sin(m*phi/4)/b)^n3
r2 = (a1+a2)^(-1/n1)
r2 *= radius * 0.6
phi += Ppi_d
theta = -Pi
FOR BandLoop = 0 TO Bands
a1 = abs(cos(m*theta/4)/a)^n2
a2 = abs(sin(m*theta/4)/b)^n3
r1 = (a1+a2)^(-1/n1)
r1 *= radius
Model(i).x = cos(theta) * (r1 + r2* cos(phi))
Model(i).y = sin(theta) * (r1 + r2* cos(phi))
Model(i).z = r2 * sin(phi)
model_norm(i).x = Model(i).x
model_norm(i).y = Model(i).y
model_norm(i).z = Model(i).z
vector_normalize (model_norm(i))
modeltext(i).v = (((BandLoop) / (bands) ) * 4) +text_off
modeltext(i).u = (((SliceLoop) / (slices) ) * 4) +text_off
i = i + 1
theta += tPi_d
NEXT BandLoop
NEXT SliceLoop
end sub
sub lathing (model() as vector3d, poly() as polytype, rings, bands)
dim as integer maxpoint,i
MaxPoint = (Rings) * (Bands+ 1)
dim Maxtri as integer
maxtri = MaxPoint * 2
redim Poly(maxtri) as polytype
'lathing
dim s as integer, u as integer
dim maxvert as integer
dim slice as integer
maxvert = MaxPoint
i = 0
for s = 0 to rings - 1
slice = s * bands
for u = 0 to bands 'duplicate texture ( not bands - 1)
poly(i).p1=(u+bands+1+(slice)) mod maxvert
poly(i).p2=(u+bands+(slice)) mod maxvert
poly(i).p3=(u+(slice)) mod maxvert
poly(i).col=rnd
poly(i).u1=0
poly(i).v1=0
poly(i).u2=1
poly(i).v2=0
poly(i).u3=1
poly(i).v3=1
poly(i+1).p1=(u+(slice)) mod maxvert
poly(i+1).p2=(u+1+(slice)) mod maxvert
poly(i+1).p3=(u+bands+1+(slice)) mod maxvert
poly(i+1).col=rnd
poly(i+1).u1=1
poly(i+1).v1=1
poly(i+1).u2=0
poly(i+1).v2=1
poly(i+1).u3=0
poly(i+1).v3=0
i = i + 2
next t
next s
end sub
Sub Init_GL_Window( Display As DisplayType )
Display.W = SCR_WIDTH
Display.H = SCR_HEIGHT
Display.R_BITS= 8
Display.G_BITS= 8
Display.B_BITS= 8
Display.A_BITS= 8
Display.D_BITS= BITSPP
Display.S_BITS= 8
Display.MODE = GLFW_WINDOW
If glfwInit() Then
'Successful!
Else
Print "Failed to initialize GLFW!"
Sleep 1000
End
End If
If glfwOpenWindow( _
Display.W , _
Display.H , _
Display.R_BITS, _
Display.G_BITS, _
Display.B_BITS, _
Display.A_BITS, _
Display.D_BITS, _
Display.S_BITS, _
Display.MODE ) _
Then
GlfwSwapInterval 1
Display.GlVer = glGetString(GL_VERSION)
Else
GlfwTerminate()
End
End If
End Sub
SUB Init_GL_SCREEN()
'screen information
dim w as integer, h as integer
'OpenGL params for gluerspective
dim FOVy as double 'Field of view angle in Y
dim Aspect as double 'Aspect of screen
dim znear as double 'z-near clip distance
dim zfar as double 'z-far clip distance
'using screen info w and h as params
glViewport 0, 0, SCR_WIDTH,SCR_HEIGHT
'Set current Mode to projection(ie: 3d)
glMatrixMode GL_PROJECTION
'Load identity matrix to projection matrix
glLoadIdentity
'Set gluPerspective params
FOVy = 80/2 '45 deg fovy
Aspect = SCR_WIDTH / SCR_HEIGHT 'aspect = x/y
znear = 1 'Near clip
zfar = 200 'far clip
'use glu Perspective to set our 3d frustum dimension up
gluPerspective FOVy, aspect, znear, zfar
'Modelview mode
'ie. Matrix that does things to anything we draw
'as in lines, points, tris, etc.
glMatrixMode GL_MODELVIEW
'load identity(clean) matrix to modelview
glLoadIdentity
glShadeModel GL_SMOOTH 'set shading to smooth(try GL_FLAT)
glClearColor 0.0, 0.0, 0.0, 1.0 'set Clear color to BLACK
glClearDepth 1.0 'Set Depth buffer to 1(z-Buffer)
glEnable GL_DEPTH_TEST 'Enable Depth Testing so that our z-buffer works
'compare each incoming pixel z value with the z value present in the depth buffer
'LEQUAL means than pixel is drawn if the incoming z value is less than
'or equal to the stored z value
glDepthFunc GL_LEQUAL
'have one or more material parameters track the current color
'Material is your 3d model
glEnable GL_COLOR_MATERIAL
'Enable Texturing
'glEnable GL_TEXTURE_2D
'Set blending parameters
glBlendFunc GL_SRC_ALPHA, GL_ONE
'Tell openGL that we want the best possible perspective transform
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST
'Enable Backface culling
'GlEnable GL_CULL_FACE
glPolygonMode(GL_FRONT, GL_FILL)
'lighting
dim as glFloat mat_ambient(0 to 3) = { 0.5, 0.5, 1.0, 0.15 }
dim as glFloat mat_specular(0 to 3) = { 1.0, 1.0, 1.0, 0.15 }
dim as glFloat mat_shininess = 10.0
dim as glFloat light_position(0 to 3)= { -7.0, 8.0, -6.0, 1.0 }
dim as glFloat light_ambient(0 to 3)= { 0.5, 0.5, 0.5, 1.0 }
dim as glFloat mat_twister(0 to 3) = { 0.75, 0.75, 0.0, 1.0 }
dim as GLfloat fBrightLight(0 to 3) = { 1.0, 1.0, 1.0, 1.0 }
glMaterialfv(GL_FRONT, GL_AMBIENT, @mat_ambient(0))
glMaterialfv(GL_FRONT, GL_SPECULAR, @mat_specular(0))
glMaterialfv(GL_FRONT, GL_SHININESS, @mat_shininess)
glMaterialfv(GL_FRONT, GL_DIFFUSE,@mat_twister(0))
glMaterialfv(GL_FRONT, GL_SPECULAR, @fBrightLight(0))
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR)
glLightfv(GL_LIGHT0,GL_AMBIENT, @light_ambient(0))
glLightfv(GL_LIGHT0,GL_DIFFUSE, @light_ambient(0))
glLightfv(GL_LIGHT0, GL_POSITION, @light_position(0))
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
END SUB
sub vector_normalize (v as vector3d)
'makes v a unit vector
dim mag as single
mag = 1/sqr(v.x * v.x + v.y * v.y + v.z * v.z)
if mag <> 0 then
v.x = v.x * mag
v.y = v.y * mag
v.z = v.z * mag
else
v.x = 0
v.y = 0
v.z = 1
end if
end sub
Thankyou both immensly, for the detailed descriptions Optimus and the OGL routine Relsoft.
Cheers and bless you both,
Clyde.
Hmm, your OGL code posted above doesn't work on my PC Relsoft, once run from FB it simply disappears and has to be stopped in the task manager. Not looked over it to see if I can spot why yet. I have an ATI radeon card not sure but I think Clyde has nvidia.
Not sure of the process involved in a Radial Blur, but I gave it a go. I named it Fake Radial Blur:
(http://www.tetrahedron.me.uk/FRBScreen.png)
http://www.tetrahedron.me.uk/FakeRadialBlur.zip - EXE and Code included
This one is made in blitz, not got FB installed atm.
Its a bit rough and slow, and by no means exact but it gives a similar effect and has a few parameters to change the look. There's also a couple optimization you can make if u used static Alpha values, and massive speed gain if u use a color pallet, rather than blending complete rgb values.
Mite be usefull to you as an alternative.
Thanks for the excellent explanation Optimus, I noticed the vague square in the centre of the screen of Keftedes but it was barely noticeable, a lot would depend on the effect it was being used with.
I'm going to be trying to do the effect myself in software before long.
Cheers for the source Rel, again you come up with the goods.
Last but not least, I couldn't believe my eyes when I saw a post from you here Tetra :) It's great that you're around and your radial blur looks pretty authentic to me :)
Cheers all, extremely helpfull. And I'll be concocting a few new prods with all this new info.
Humble thanks,
Clyde Radcliffe.
Tin Dragon: You'd have to supply the TGA texture yourself. :*) Some of my posts have TGA's. or you could DL this and use the TGA file for the effect. :*)
http://rel.betterwebber.com/junk.php?id=61
Simple answer why it doesnt compile on some peoples machines, is that about 3 updates ago they did away with using the NOT command.
Thanks for the snippets dudes, one day I'll see about trying to convert the QBasic routine in Mono And Disco to FreeBasic. Still get probs with doing it.
Cheers and thanks,
Clyde.
DOH
Told you I never looked at the code, if I had would have spotted the need for a texture :-[
:whack: have that for not telling me sooner ;)
hehehehe. remember to change the texture name. :*)
O0
I've tried to transfer over the Feedback in mono and disco, to FB; and doing one myself. And im afraid im going to have to throw the towel in on this one. Thanks for all your time and help on this; I do appreciate it.
Thanks,
Clyde.
I dont suppose relsoft dude, you'd mind converting the Feedback part from Mono+Disco into FB. Just so that i can get the gist of it all please matey?
Cheers and many thanks,
Clyde
I'll see what I can do. I'm doing some GL bloom and glow effects for the kart game though.
Ok mate, no hurry. And thanks so much dude.