well, as I said it was a very old project, and one of my first GL programs (well, I think actually my 3rd)... so the trees were pretty aweful... Yes, they are just 2 traignles at right angeles, but in the distance they fade off to a single billboard triangle..
for good looking trees, I think rally championship did the best combination of speed and looks.. their tress were both a single viewer facing billboard of a tree, and a fairly low detail model... the overall effect was probably only ~30 polys, but looked v.good.
yahn, yeah, I said that you could use alpha test to fake a clip plane, which is pretty much the same thing, and older nvidia drivers did do that if you requested a clip plane, but if the texture unit wasn't free, they resorted to software rendering... which was why they removed it (well, I know they removed support from D3D, I don't know if it's still in GL)... All in all it seems pretty weird, really...
| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |
[edited by - RipTorn on November 23, 2002 10:08:43 PM]
reflections
quote:
yahn, yeah, I said that you could use alpha test to fake a clip plane, which is pretty much the same thing,
The principle is the same, but it''s far better to use texkill. It will leave your alpha component untouched, so that you can use it for blending. You''ll also get more than one clipplane.
quote:
All in all it seems pretty weird, really...
Yeah, it''s not the best solution.
A couple of qustions have come up regarding the reflections (esp. the stencil buffer):
1) Why can''t I get the reflecting surface to be transparent at the same time? Here''s the pseudo code (pretty much based on a tut at Nehe''s) of what I''m using:
1 Enable stencil test, disable depth test
2 Draw the reflecting surface into the stencil buffer
3 Enable depth test
4 Push modelview, flip everything on y
5 Draw the reflection
6 Pop everything
7 Enable blend and draw the actual reflecting surface
8 Disable blend and draw the terrain - some of it is under water, but it won''t show up through the mirror surface
If I switch 8 and 9, I get the transparent surface, but no reflection. How do I combine these?
2) My terrain is normally culled against the frustum (internally by the class) - the reflected terrain, however has some strange artefacts regarding frustum culling - do I have to flip something else as well when I flip the axis for drawing the reflection (glScale3f(0, -1, 0)
Crispy
1) Why can''t I get the reflecting surface to be transparent at the same time? Here''s the pseudo code (pretty much based on a tut at Nehe''s) of what I''m using:
1 Enable stencil test, disable depth test
2 Draw the reflecting surface into the stencil buffer
3 Enable depth test
4 Push modelview, flip everything on y
5 Draw the reflection
6 Pop everything
7 Enable blend and draw the actual reflecting surface
8 Disable blend and draw the terrain - some of it is under water, but it won''t show up through the mirror surface
If I switch 8 and 9, I get the transparent surface, but no reflection. How do I combine these?
2) My terrain is normally culled against the frustum (internally by the class) - the reflected terrain, however has some strange artefacts regarding frustum culling - do I have to flip something else as well when I flip the axis for drawing the reflection (glScale3f(0, -1, 0)

Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
When i originally wrote my Island Demo i was experimenting with different ways to do reflections. I hated how you had to draw the scene twice to produce the effect. The solution i came up with sort of goes like this:
1. Create a texture out of the stuff in the frame buffer (like in the radial effect tutorial)
2. Load a matrix, which represents the reflection about the plane that represents your water, into OGLs texture matrix
3. Texture the water with the matrix (sphere mapping might also work)
I sort of got fed up after continously trying to implement it so i gave up. But if im right, it should be faster than redrawing the entire scene. The only problem is that you wont get the right perspective on the reflected surface, but it should be close.
"Free advice is seldom cheap."
-- Rule of Acquisition #59
1. Create a texture out of the stuff in the frame buffer (like in the radial effect tutorial)
2. Load a matrix, which represents the reflection about the plane that represents your water, into OGLs texture matrix
3. Texture the water with the matrix (sphere mapping might also work)
I sort of got fed up after continously trying to implement it so i gave up. But if im right, it should be faster than redrawing the entire scene. The only problem is that you wont get the right perspective on the reflected surface, but it should be close.
"Free advice is seldom cheap."
-- Rule of Acquisition #59
quote:
Original post by llvllatrix
1. Create a texture out of the stuff in the frame buffer (like in the radial effect tutorial)
2. Load a matrix, which represents the reflection about the plane that represents your water, into OGLs texture matrix
3. Texture the water with the matrix (sphere mapping might also work)
Ok me be dumb:
1) draw the scene normally without first translating/rotating/reflecting any matrices etc?
2) reflect the current modelview matrix from the water''s plane (equation)
3) render whatever is visible to a texture and map the water?
This (order of events) should pose a problem in terms of the reflected stuff being culled by the frustum.
RipTorn - you seem to be describing the same thing:
quote:
Original post by RipTorn
the way this was done was by reflecting the view matrix realitive to the mirror (really roughly, since the mirror - the water - is flat along the z axis)...
I can do that
quote:
then it was a matter of using the texture matrix to project the texture onto the water (again, really roughly done)..
Please elaborate. Is it that you draw the scene once for the reflection after loading the reflected view matrix and project the texture (how?), and then draw the scene as it is actually seen? This would mean doing double drawing just like stencilling... Sorry if I make little sense - it seems a bit complicated at first - besides, what I get through the stencil buffer isn''t too nice either... at least so far.
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
I wasw saying that what I did in the demo I showed the image of was very roughly done...
I did render the scene twice.. copying from the colour buffer to texture, not a pixel buffer (considerably faster, usually)...
since, in my demo, the mirror line was flat along the z axis, the flip of the view matrix wasn''t really a real flip, it was simply a rough guess rearranging matrix rotation orders, etc... (I didn''t know too much matrix mathematics then, so a true reflection was above my head)... Then it was a matter of using object linear tex gen with a few mostly guessed texture matrix rotations/scales (once again, I was new to GL then) when drawing the water surface (which had the reflection texture applied)... using transparency, etc.
as for answering your original question, a case like this stencil would probably be out of the question.
the points already mentioned are still valid, ie, it''s very hard to make it transparent (unless you do some stencil assisted depth clearing, but even then, you could get overdraw issues), you can''t ''play with'' the reflection... and you also have to consider the extra fillrate going into the stencil buffer usage, and that you more than likly limit yourself to 32bit colour.. (I havn''t tried using a 1bit stencil with GL, but I know D3D offers it at least)..
Stencil reflections are good for one thing, perfect reflections along planes, and really, these don''t ever occur in nature... so why should they occur in games?
a lower res texture based approach using a pixel buffer would likly be faster overall as well, assuming the pbuffer is lower res than the display buffer... Even if it isn''t, you can still scissor rendering on it to the area that will actually be used, (ie, if the mirror is a long distance away) - or simply scale it up for better image quality...
| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |
I did render the scene twice.. copying from the colour buffer to texture, not a pixel buffer (considerably faster, usually)...
since, in my demo, the mirror line was flat along the z axis, the flip of the view matrix wasn''t really a real flip, it was simply a rough guess rearranging matrix rotation orders, etc... (I didn''t know too much matrix mathematics then, so a true reflection was above my head)... Then it was a matter of using object linear tex gen with a few mostly guessed texture matrix rotations/scales (once again, I was new to GL then) when drawing the water surface (which had the reflection texture applied)... using transparency, etc.
as for answering your original question, a case like this stencil would probably be out of the question.
the points already mentioned are still valid, ie, it''s very hard to make it transparent (unless you do some stencil assisted depth clearing, but even then, you could get overdraw issues), you can''t ''play with'' the reflection... and you also have to consider the extra fillrate going into the stencil buffer usage, and that you more than likly limit yourself to 32bit colour.. (I havn''t tried using a 1bit stencil with GL, but I know D3D offers it at least)..
Stencil reflections are good for one thing, perfect reflections along planes, and really, these don''t ever occur in nature... so why should they occur in games?
a lower res texture based approach using a pixel buffer would likly be faster overall as well, assuming the pbuffer is lower res than the display buffer... Even if it isn''t, you can still scissor rendering on it to the area that will actually be used, (ie, if the mirror is a long distance away) - or simply scale it up for better image quality...
| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |
quote:What do you mean by that ? You want the reflected scene to be colored by blue because the mirror is blue for instance ?
Why can''t I get the reflecting surface to be transparent at the same time?
quote:What is 9 ?
If I switch 8 and 9, I get the transparent surface, but no reflection. How do I combine these?
quote:
Original post by RipTorn
(I didn't know too much matrix mathematics then, so a true reflection was above my head)...
I'm here right now...
quote:
I wasw saying that what I did in the demo I showed the image of was very roughly done...
Does it matter if it looks good?
quote:
I did render the scene twice.. copying from the colour buffer to texture, not a pixel buffer (considerably faster, usually)...
since, in my demo, the mirror line was flat along the z axis, the flip of the view matrix wasn't really a real flip, it was simply a rough guess rearranging matrix rotation orders, etc...
render the scene twice from which viewports? I'm sorry, but I'm having trouble understanding the concept here - there aren't too many smaples available on the Web either...
quote:
Then it was a matter of using object linear tex gen with a few mostly guessed texture matrix rotations/scales (once again, I was new to GL then) when drawing the water surface (which had the reflection texture applied)... using transparency, etc.
It's all very nice and general, but, again, I don't quite follow... I need/want to understand this since it's a school project and I'm going to have to defend it the upcoming spring...
quote:
Stencil reflections are good for one thing, perfect reflections along planes, and really, these don't ever occur in nature... so why should they occur in games?
perfect (stencil) reflections would be nice - I'd like to implement them as an option for faster systems. as for the last sentence - I think most things (such as refraction which doesn't really come very close to real life either) are there because they're cool. I mean, you can't see particle effects every day, and I urge you to give me an exmple where you personally saw a lens flare without the help of a camera...
quote:
Original post by vincoof
What do you mean by that ? You want the reflected scene to be colored by blue because the mirror is blue for instance ?
Here's a screenshot:

Notice the reflection - that's fine, but the terrain also exists underneath it. I'd like the reflective surface to be transparent in the "real" (not reflected) world.
Another problem I cannot understand is - if you look closely at the "waterline", you can see that there is a gap between reflected terrain and the real one. Simple transposition doesn't cover that up. Furthermore, why is it there in the first place? The world is drawn y=[0, 255] and water level is at 20, so the mirrored terrain is y=[0, -255]. When transposing it, it is not clipped above 0 level (I can see it when I move the camera under the mirror), but doesn't show up through the mirror either, leaving a gap...
quote:
What is 9 ?
oops - i meant 7 and 8
Crispy
edit: screenshot
[edited by - crispy on November 25, 2002 8:26:27 AM]
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Ok I think I got your problem with stencil reflections.
If you perform 1-2-3-4-5-6-7-8 (in order) you see your reflections (good) and there is the water surface over it (good) but the terrain underwater is not visible (bad).
If you perform 1-2-3-4-5-6-8-7 (in order) you don''t see your reflections (bad) but you can see the underwater terrain (good) and the water surface too (good).
But you would like to see underwater terrain, reflected terrain and water surface simultaneously, is that right ?
If you perform 1-2-3-4-5-6-7-8 (in order) you see your reflections (good) and there is the water surface over it (good) but the terrain underwater is not visible (bad).
If you perform 1-2-3-4-5-6-8-7 (in order) you don''t see your reflections (bad) but you can see the underwater terrain (good) and the water surface too (good).
But you would like to see underwater terrain, reflected terrain and water surface simultaneously, is that right ?
quote:
Original post by vincoof
Ok I think I got your problem with stencil reflections.
If you perform 1-2-3-4-5-6-7-8 (in order) you see your reflections (good) and there is the water surface over it (good) but the terrain underwater is not visible (bad).
If you perform 1-2-3-4-5-6-8-7 (in order) you don''t see your reflections (bad) but you can see the underwater terrain (good) and the water surface too (good).
But you would like to see underwater terrain, reflected terrain and water surface simultaneously, is that right ?
Exactement!
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement