Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
forelle
Oct 9, 2004

Two fine trout
Nap Ghost

kewlpc posted:

Stay the hell away from NeHe's tutorials, they're terrible. Instead, start off with the ones by Nate Robbins, which are drat nice and even mentioned in the OpenGL Red Book.

I disagree with this. There is some good stuff in NeHe's tutorials. I've got to admit that I don't read the text, but I still find myself dipping into the code sections occasionally to remind myself of how something works.

Regarding Red and Orange books, just man-up and use the spec and extension definitions. :)

Seriously though, after a while, the spec is the only reference you really need. If you're doing any OpenGL programming you should have a copy of this handy.

http://www.opengl.org/registry/doc/glspec21.20061201.pdf

Adbot
ADBOT LOVES YOU

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

samiamwork posted:

drat. I was afraid of that. I was really hoping to avoid using FBOs, but if that's what I have to use, that's what I'll use.

Thanks guys.

edit: Typo.

Strange this should come up. I'm facing OpenGL fixed function blending woes right now myself.

The imaging extensions add a few more blending modes (min, max, and so on) which might help.

But the one that is really getting me, does anyone know of an efficient, NVidia compatible way, to perform a channel swizzle (copy A to R for example) that doesn't involve multiple buffer ping-ponging or using the color matrix extensions (which would be fine, but is a software only path even on Quadros)?

What I really want is

1. Render Something with blending
2. Render the same thing in a different mode that will copy the result R from step one into A
3. Render something else blending using the new A value.

Something like glCopyChannels(GL_RED,GL_GREEN, GL_BLUE, GL_RED) (which doesn't exists alas)

For efficiencies sake I really need to do this using the fixed function blending (or other) pipeline.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

kewlpc posted:

Again, use FBOs. Set up an FBO with two color attachments. Render Step 1 into color attachment 0. Switch to color attachment 1 and, using color attachment 0 as a texture, render a quad that covers the screen using a shader that just puts the red channel into the alpha channel.

Then, when rendering Step 3, use color attachment 1 as one of the textures, with a shader that uses color attachment 1's alpha as its own.

But that's the complicated way of doing it. The simpler way would be to set up an FBO with only one color attachment, render Step 1 into it, then switch back to the default FBO, and render Step 3 using a shader that takes in your FBO's color attachment as a texture and uses its Red channel as alpha.

Either method should be faster than the way you outlined since you'll only be rendering the scene from Step 1 once instead of twice.

Also, you do know that on modern hardware the fixed-function pipeline is just emulated, right? So using a well-optimized shader shouldn't be any slower than the "fixed-function" shaders that the driver loads. In fact, in either the upcoming version of OpenGL or the one after it all the fixed-function emulation is going to be removed.

Cheers for your reply.

As I mentioned in my post, for efficiencies sake I cannot afford to swap between two color attachments (ping pong) and keep them in sync.

I am rendering tens of thousands of particles, the results of which need to be correctly composited with the results of all the previous particles. Your method would require swapping on each particle which would slow us to a crawl.

The blending mode that we require cannot be directly implemented using the blending hardware (blending is still "fixed function" be it programable under the hood or not).

We can however split the function into two parts if we could efficiently swizzle the RGBA channels (i.e. render and blend some initial parameters in R, then render again, swizziling R into A before the blend).

The only way to do efficient Read-Modify-Write for large numbers of particles is using blending. We can swizzle channels using the color matrix functionality of the imaging subset (via an inplace copypixels and an appropriate matrix) but this drops to software on Quadro 4600 and 5600 cards.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

StickGuy posted:

Have you considered presorting your particles?

It is our last ditch approach. The particles are spawned based on user input (painting) and there can be a arbitary number of them created in a arbitrary order.

Pre-sorting would mean re-rendering at least a subset under the new particle for each new particle added rather than a much more efficient in place rendering.

If we can't find an elegant (read nasty hacky quick) solution we're gonna go this route.

For efficiency we will probably use a combination of bucketing and viewport / scissor / stencil buffer to minimise particle redrawing.

Roll on programmable blending.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

Mr_PK posted:

I don't know if this is what you need or not, but in OpenGL you can use glColorMask(). This lets you limit what channels you want to render to. For example, you can only render to R and B, then do a second pass render to render to G and A.

http://www.cs.utk.edu/~vose/c-stuff/opengl/glColorMask.html

Cheers for the reply.

We use color masking to control what gets written, but it is only half the solution. If only GL had a "render R as if it was blue" my life would be sooo much easier. :)

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

kewlpc posted:

But that's the complicated way of doing it. The simpler way would be to set up an FBO with only one color attachment, render Step 1 into it, then switch back to the default FBO, and render Step 3 using a shader that takes in your FBO's color attachment as a texture and uses its Red channel as alpha.

Thank you!!!!

I owe you an apology. We just got this method working a treat.

Yay completely accurate floating point Photoshop-style brush painting fully accelerated in hardware.

(Full speed with huge brushes that PS chokes on too)

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

kewlpc posted:

Glad I could help.

But in return you have to tell us more about your program.

I would love to be able to say something, but for the moment I'm NDA'd upto the hilt and I work for an organisation that takes that sort of thing VERY seriously.

I hope at some point in the near future to get permission to talk about it and even start giving it away. I'll make sure I post here first when I can.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

tyrelhill posted:

The hardware usually pads NPOT textures to POT textures anyway, might as well remove that overhead and do it yourself.

Do you have any literature backing this claim up?

Specifically OpenGL 2.0 on Nvidia.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

Stanlo posted:

Isn't that fairly well known? At least for older cards, which is what most people have.

I've not seen any official documentation stating this and would be VERY interested in reading some.

It's pretty important to me that I can keep an accurate handle on GPU memory usage. Yay for not having a glGetTextureMemoryUsage method.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

tyrelhill posted:

Not exactly what I said, but this quote is from this book:
http://www.amazon.com/gp/product/im...82225765&sr=1-3


I am actually taking a class where the author of this book is lecturing so I'll ask him tomorrow what exactly happens.

Cool, Sounds like an interesting course.

I'm not really bothered about pre-2.0 cards or low end cards either.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

TSDK posted:

Looking good so far.

This is a pretty good method for adding caustic effects, if you want to bump the bling up a notch.


Ooooh I invented something similar to this (but not as good) back in 2000ish.

http://www.patentstorm.us/patents/6809729.html

drat, "Don't publish but patent" companies.

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

TSDK posted:

What the hell? Issued 2004? Hell, I think I've almost got prior art on that sucker as well.

This is the patent I wrote, I can't imagine why they wanted to patent it though. I since found out about 4 other people who "invented" the same method at about the same time as me.

The main crux was the the ability to integrated pretty minimally into a fixed function GL pipeline. But it was first submitted in 2000 (in the UK at least)

forelle fucked around with this message at 01:34 on Apr 26, 2008

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

vanjalolz posted:

I hear that NeHe is bad, but there is a LOT more stuff on there than Nate's website.

I really really don't get the NeHe hate. Ok, it isn't professionally written, and they've stopped really updating it, so there are big gaps.

But what there is is useful. It provides little test bed applications you can download and quickly play with which is sometimes all you really need.

I've been coding professionally with OpenGL (both above and below the API) for 10 years now, and the NeHe stuff still comes in useful simply as repository of information in a compact form.

Adbot
ADBOT LOVES YOU

forelle
Oct 9, 2004

Two fine trout
Nap Ghost

MarsMattel posted:

http://flipcode.com/iotd/2012-08-29

Unfortunately not a terrain engine, but it is from the same guy who had the very first one 13 years ago. This makes me feel old :corsair:

http://www.flipcode.com/archives/01-31-2002.shtml



My IOTD from 31st January 2002. 10 years ago. Talk about feeling old. I've learnt a bit about marketing and UI design since then. :)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply