Jump to content
  • Advertisement
Sign in to follow this  
Sereath

OpenGL Animated OpenGL water texture (without GLSL)

This topic is 2443 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I am creating a 2D game using openGL and I would like to add some water in it.

I have a very little understanding of OpenGL yet so many questions about it but I will do my best to keep things simple and clear.

So basically I have two textures : the water texture and a perlin noise texture. What I would like to do is to alterate the positions at which OpenGL look into the water texture using values of the perlin noise texture.

so basically something like :

looping trough all pixels to draw on screen for the water quad
{
texel_coordinate = glMagic();

texel_offsetXY = perlinNoise_texture[pixel_coordinate].redValue(); // Or .intensity().... idk

glSetTexelCoordinatesToUseIsteadOfWhatOpenGLIntentedAtFirst(
texel_coordinate.X + texel_offsetXY, texel_coordinate.Y + texel_offsetXY)

{
// keep looping for all the pixels to draw


...and all that, without using a shading language (GLSL).

is it possible ?
is it stupid ?
is it extremely computer intensive? (if it is possible of course)
is there a shader technique that is widely supported trough all computer between now and 2000 or does all GLSL are just as bad on the compatibility issue (if you never experience any compatibility issue with GLSL, this question isn't for you).


PS : I don't want to start a debate on what people think of how many computer they know support GLSL. I just want to know if it's possible & viable to draw water with a texel displacement effect without the use of GLSL.

Share this post


Link to post
Share on other sites
Advertisement
You're not going to get an acceptable solution for this that doesn't involve some kind of shader - what you're talking about is a dependent texture read and that needs shaders (or some other kind of per-fragment programmability). The only way I can think of would be to tesselate your geometry really really heavily (such that one triangle approximately maps to one pixel), keeping the noise texture in system memory, and doing your coord modification per-vertex. That's not going to run well at all - a combination of heavy tesselation and needing to resubmit all the texcoords for it every frame will pull down performance badly.

So, on to shaders.

The main question I'd ask is "are you really certain that you need to run on hardware going back to the year 2000?" That's 12-year old hardware now, and assuming that you can even find any that still works, would somebody who's clinging on to such ancient junk even be considered part of your target audience? On the surface, it has to be said, you seem to be being a great deal over-conservative here, and that's a requirement that I seriously recommend you rethink.

Let's move on and assume that some kind of shader support is acceptable as a baseline requirement.

Here we have a number of options. Something like the old NV register combiners would work if you really want to target older hardware, but they're not going to be so broadly available. ARB assembly programs are another option (moving up a little more) and they will meet your requirement while still maintaining very broad hardware compatibility - even integrated Intels from 6 years back will support them. They are more limited (and more complex to write - although the C interface is simpler) than GLSL however. And that brings us to GLSL itself where the compatibility problem is really not so bad. Shooting for something like the GL 2.1 version of GLSL will give you very good hardware compatibility across the vast majority of hardware you'll find in people's machines today - it's only the really old integrated Intels I mentioned before that won't support it (more recent ones do) so the question changes to one of "do you need to run on ancient integrated Intels?"

Bear in mind here that these Intels were really only ever found in business PCs, laptops, and el-cheapo high-street "multimedia" PCs and it comes back again to you needing to think more about who your target audience are. That's the first thing you need to define before any definitive recommendation on how to go forward can be given.

Share this post


Link to post
Share on other sites
you seem to be being a great deal over-conservative

I am being over-conservative because of a lack of knowledge on so many levels reguarding this issue.

From what I could find on the web (along with what I could not find) (and along with your helpful reply) i will make the assumption that some shaders has to be used for this feature to be implemented in a intelligent way.

ARB assembly programs are another option

I have been digging this possibility for a while (with some true interrest) yet found very little ressource on the subject. Many time I've read ARB fragments being called "outdated" and such, which made me wonder if they would even be supported by newer graphic cards (another issue that may not exist but concern me as well)... or maybe they are not supported by the latest versions of OpenGL which seem to remove support for old stuff from time to time (from what I have reed).

And that brings us to GLSL itself where the compatibility problem is really not so bad.
A debate for which I have read good argument on both sides. Without any real statistics on the subject, I would rather take the conservative side unless I dont have the skills for it (which is another possibility). I'm not here to debate on how peoples that would like to play my game can play GLSL games, I have no stats to back me up.

"do you need to run on ancient integrated Intels?"[/quote]
I have no idea, but as I said, without stats il take the concervative choice. I for myself own a not so old computer (5 years) with an integrated graphic card (intel I guess) that doesn't support GLSL, yet it can play some pretty decent games, go figure.

who your target audience are[/quote]
People who don't have the money to buy games that will undoubtly be better than mines.

...from there I can only guess some subcategories such as :
- people who can only afford old computers.
- people who spent money on bad games and are now looking for free games (yet own a good computer)




Now that I have read your replie I have a better understanding of my choices.
I will now aim at some ARB fragment shaders (since I believe it might not be too hard) (say the guy who know nothing about anything) since this animated water will most likely be the only and single aspect of my game using shaders (thus worth a little extra effort).

Also, I will take a look into GLSL 2.1. If I'm lucky enough, Nvidia has a software (that is hopefully free) that will allow me to code the shader once and export it to GLSL 2.1 and ARB. From there il let my game probe the computer it is run from and decide from there if GLSL 2.1 shaders are supported or if ARB shaders are supported.

Thanks you very much for your help mhagain !

Share this post


Link to post
Share on other sites
Assembly programs are going to remain supported for quite some time yet - reason why is that Doom 3 used them, so no hardware vendor is going to be too willing to drop Doom 3 support.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!