projecting textures

How can I project a texture on the environment, to get for example spotlights and bulletholes? Do you know some good tutorials or sample implementations?

-thanks

Cass made a good paper about this. It’s on the nvidia developer web site.

-SirKnight

nVidia’s papers and demos sucks if you ask me. I think the papers are too small and the demos include ~60% crap.

Try this: http://www.dorbie.com/uav.html#_cch3_887222955

I think NVIDIA’s white papers and demos are excellent. If you don’t like them try to do better yourself. You really sound like an undeserving ingrate when you complain that you only get 40% great code in their demos.

Well if you’re looking for a ‘hold my hand through every single line of code like im a kindergardner’ style of paper then I think you’re out of luck unless NeHe has a tutorial on this subject. The papers and demos do not suck though. I find them good enough for me to learn and understand. To me and most other people I know they are great and top notch. To learn from them, and most other graphics papers and demos for that matter, requires a bit of thinking on your part. Which really is the best way to learn graphics or any other programming topic. If you’re told exactly how to do every single little thing with out any thinking and reasoning from yourself then you wont be as good at it. But, if that is how you feel about the papers/demos then I really don’t know what to tell you. :stuck_out_tongue: Sorry.

EDIT: Silly grammer error.

-SirKnight

[This message has been edited by SirKnight (edited 08-21-2002).]

>>How can I project a texture on the environment, to get for example spotlights and bulletholes<<

why would u want to project a bullethole?

theres an example that comes with glut, but i wouldnt look at it cause it sucks

Originally posted by SirKnight:
[b]Well if you’re looking for a ‘hold my hand through every single line of code like im a kindergardner’ style of paper then I think you’re out of luck unless NeHe has a tutorial on this subject. The papers and demos do not suck though. I find them good enough for me to learn and understand. To me and most other people I know they are great and top notch. To learn from them, and most other graphics papers and demos for that matter, requires a bit of thinking on your part. Which really is the best way to learn graphics or any other programming topic. If you’re told exactly how to do every single little thing with out any thinking and reasoning from yourself then you wont be as good at it. But, if that is how you feel about the papers/demos then I really don’t know what to tell you. :stuck_out_tongue: Sorry.

EDIT: Silly grammer error.

-SirKnight

[This message has been edited by SirKnight (edited 08-21-2002).][/b]

I think the problem with NVIDIA demos is you have to kind-of hunt around for the interesting bits of code - because they hide everything behind their sdk libs - if you aren’t familiar with them, you’ll wonder what exactly is going on

I think nVidia’s demos (mostly the HW stuff) is meant to more advanced programmers than me and I think the sources are not so good as a tutorial, becouse of how they are commented & organized.
For example, I downloaded once a demo about shadowmaps just to see whats going on. It had about one single file over 4500 lines added to a lump and very poorly commented.
If reading such thing isn’t pain, what is?

I agree that nVidia’s demos must be grat, if you are a very good programmer and know much about graphics programming all ready.

I managed to project a texture on my scene by manipulating texture matrix, but I obviosly can’t project multiple textures in one pass, becouse I have to bind the texture on every polygon in my scene. Not very practical, but it was in many tutorials (including nVidia).
It must be possible to project multiple textures in at least one pass, but how?

You can use multitexture, but that’s not how bullet holes are done. Games tend to computationally figure out where bullet holse should land on the surface and draw a small polygon. With things like weapon lighting effects similar things are done. Projective texture is used for stull like spotlights and shadows under limited circumstances even then not many games use it.

Yes, bullet holes are probably best done with small polygons. I’m even starting to really like glPolygonOffset ( maybe even as far as to use dorbie’s previous suggestion for multipass effects…maybe ). Ahem, it’s great for shadow volumes btw, especially after chopping them up.

Sorry that I mentioned that bullethole thing, it just crossed my mind.
But anyway, how can I project all the textures in one pass?

Like dorbie said, using multitexture and some form of combiners ( RC’s, TexEnv, fragment shaders, etc ). How you combine the textures depends on what you want to achieve.

For example, something like the following will add all projected textures using glTexEnv,

glMatrixMode( GL_TEXTURE );
glActiveTextureARB( GL_TEXTURE0_ARB );
// **Load texture projection matrix for Tex0

glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glActiveTextureARB( GL_TEXTURE1_ARB );
// **Load texture projection matrix for Tex1

glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );

// etc

// Draw surfaces

Note that GL_ADD requires the EXT_texture_env_add extension ( or similar extension ) but most/all cards can easily handle this.

With GeForce1 level hardware you can project 2 textures per pass, GeForce3 can do 4, Radeon 8500 can do 6, etc. If I remember correctly, there are 2 texture cards that only have one hyperbolic interpolator and can thus only do 1 projected texture per pass ( the TNT I think ).

Projecting a texture is all in your texgen and your texture matrix. There’s one texgen and one texture matrix per multitexture unit. Thus, you just ActiveTexture() and set up your projections in turn.

I’m assuming you’re doing the “slide projector” projection, and use CLAMP_TO_BORDER with a black border color, and each texture in ADD texture env mode. Or make the border color white and use MODULATE.

How on earth do you think I can make dynamic lights if I must in the worst case render the scene once for a single light?
I assume the games out there does NOT project like this. How are hitman’s shadows projected or dynamic light of quake type game? I’m pretty sure not like this.

I remember Nate had one tutorial about dynamic lighting and it check the polygons from a fixed distance from a light and rendered only them to project the light.

This would work when using lights, but how about when rendering shadows; it would be quite difficult to check which polygons the shadow texture shold be projected on.
Especially when the shadow stretches far away into the scene.

im drawing my bulletholes straight into the base texture (actually using dot3 so they look more like holes)
u will need unique texturing though for this (u should have this anyway right?)

When I move the camera it affects to texture coordinate generation, what would be the best way to prevent this?

You must have texgen in eye space, you should texgen in object space or load the inverse view matrix on the texture matrix stack. That’s what the _OBJECT and _EYE means.

Thanks. It work pretty well now.