projecting textures

Originally posted by zed:
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?)

You might be able to “dot3 light” your bullet quads instead of using unique texturing. It could be problematic for bullet holes on comples meshes but it’ll save a lot of memory.

I have implemented shadowmapping now by first rendering a model to a texture and then projecting it onto the environment.
Is there any extensions/tricks to speed-up render-to-texture process?
When the model is too close to the light source. it can’t fit to the texture, show could this be fixed?
Have any ideas of how to find only those polygons where the shadow is projected?

>>You might be able to “dot3 light” your bullet quads instead of using unique texturing. It could be problematic for bullet holes on comples meshes but it’ll save a lot of memory.<<

yes i can see problems with that. i like to keep things simple.
ive been using unique base textures for years for everything (normally at a lowerresolution so even on my riva128 4mb this was viable) unique textures help with certain things (less repition in the scene, object space bumpmapping + a couple of other neat things ) true memory is the biggest drawback but i get around this by generation textures (also meshes) on the fly.

>>
Have any ideas of how to find only those polygons where the shadow is projected?<<

u project the texture like a frustum be it orthogonal or perspective (ie like the view frustum) thus u can use the same code check the 6 (or less) planes of the projecting textures frustum against your scenegraph to see whats in + whats not.

Can you tell me if there’s any more faster ways to render to texture than using glCopyTeximage2D?

Have anyone checked NaTe:s tutorial about dynamic lighting? There’s another way to project a texture, but can anyone tell me more specificly about that?

Well there are some extensions you can try. They are: WGL_ARB_render_texture, WGL_NV_render_depth_texture (which can be good for shadow mapping), and WGL_NV_render_texture_rectangle. Well actually the last two there require WGL_ARB_render_texture but they add some extra cool stuff. Maybe there is something there that will work good for you.

Have you also tried glCopyTexSubImage2D(XXX) ? That could save some speed by letting you only copy the part you need.

-SirKnight

glCopyTexSubImage2D(…) is faster than glCopyTexImage2D even if you copy to the entire texture. Currently, I copy an 800x600 screen to a 1K x 1K texture and still running at full speed ( the performance is not far from WGL_render_texure on my machine ).

glCopyTexSubImage2D(…) is faster than glCopyTexImage2D even if you copy to the entire texture.

I kind of thought it was but actually I have never used it (I know shame on me) so I didn’t know first hand but I thought I remembered someone saying on this msg board that it was faster for even the whole texture.

So PH since you have done this stuff quite a bit before (obviously) what are your thoughts on the WGL_render_texture compared to using glCopyTexSubImage2D?

-SirKnight

speedwise
ati likes ARB_render_texture better
nvidia likes copytexsubimage better (or have they fixed render_texture yet?)

I think zed’s right. I remember Matt saying something about ARB_render_texture not neccessarily being faster than copy_to_texture on NV hardware. Poor Matt almost got flamed for saying that . I haven’t compared the performance of CTT and RTT on GeForce3 with some of the newer drivers, so I can’t say if it’s been fixed yet ( if at all possible ).

On my 8500 RTT is faster than CTT. Right now I just use CTT since it allows me to save memory, it’s so much easier to use and it’s still very fast. RTT and contexts can be a real pain to manage. Using shared contexts is possible but that means making the pixelformat of you pbuffer identicle to your main context ( meaning you’ll need depth, stencil, double buffers, etc in your pbuffer ).

Some numbers for identicle scenes on Radeon 8500 ( per-pixel lighting without shadows, approx. 8000 triangles rendered twice, 800x600 screen ) ,

(close-up view)
RTT: 190fps
CTT: 150fps

(far-away)
RTT: 300fps
CTT: 192fps

[This message has been edited by PH (edited 08-27-2002).]

Some screenshots of the above ( with shadows though, so it’s more fill limited but still shows an increase ).

The fps is very poor, about 3f in 1024768 and 32bit. Only there is is a scene that consists from two boxes and an animated model about 900 polygons and a skybox.
I cast two shadows size of 512
512 from the model to the scene. So the model and the scene are rendered three times.
First the model is rendered to the textures (both of them), then I render the scene and the model with base textures and finally render the scene twise to project both shadow textures. The fps is very poor if thinking to implement this in a larger scene.

Add:
If you want to test my app just post your e-mail address and I’ll sent it to you.

[This message has been edited by blender (edited 08-27-2002).]

What graphics card are you using ? Did you you try glCopyTexSubImage2D ? Also, you should specify GL_RGBA8 as your internal format ( for a 32 bit framebuffer ). If you use GL_RGBA as your internal texture format, then you might get a 16-bit texture, thus forcing the driver to do a conversion.

Gosh what a big difference in performance for rendering to a texture with those two methods. I’m going to play around with those two methods on my GeForce 4 Ti w/ latest drivers here and see what happens. I’m very curious now.

I’d like to test your app. My email is in my profile.

-SirKnight

I sent my app to you in zip file it’s somthing about 1.8mb.
I did try glCopyTexSubimage2D, but I didn’t notice any speed differences. I’m using
GL_RGB texture mode for shadow textures, but doesn’t it include 3 channels? If I use the texture for shadows, I would really need only one (grayscale). Can this be done and if it can, does it speed up?

The key point to getting good performance is using a texture internal format that matches the framebuffer exactly. So if your framebuffer is 32-bits, you have to use GL_RGBA8 regardless of what you’re using the texture for ( note the 8 in the above ). Change it to that and your performance will improve.

Using GL_RGB with a 32-bit framebuffer will in most cases not be very fast ( might be on future hardware but not in general ).

PH, do you mean this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGP8, texture->width,texture->height,0,RGP8, GL_UNSIGNED_BYTE,texture->data);

or what? Becouse that turns everything to white.

No, like this

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture->width,texture->height,0,GL_RGBA, GL_UNSIGNED_BYTE,texture->data);

[This message has been edited by PH (edited 08-27-2002).]

It worked and I think fps increased by 10 or something at close range. I have a problem viewing in fullscreen mode (I have a topic about this one becouse it’s weird one),
so it might be a little more faster in fullscreen.

Damn, wrong guess. It didn’t speed up (
In 102476832 fps is at close range 45, when rendering one skybox, scene of two boxes, the model and one shadow, no lighting.