[Gtkradiant] Realtime lighting approach issues.

Pablo Zurita gtkradiant@zerowing.idsoftware.com
Sun, 05 May 2002 17:31:08 -0500

I'm working on realtime lighting and when ever TTimo and I talk about it
we never manage to agree on the use of extensions so I decided that
everybody should have an opinion and maybe we can reach an agreement on
how I should approach this. My approach is the use of per-pixel lighting
and use a modified version of Carmack's reverse technique for shadows. To
do this in an effective way I need arb_multitexture, Nvidia's register
combiners, and the stencil buffer. This means that this feature would be
available for Nvidia's cards from the GeForce 1, but my plan is to add
support to ATI extensions(I don't own an ATI card but I know its pretty
easy to get ATI to send me a Radeon or something). TTimo basically is
against the use of extensions in GtkRadiant(TTimo: you may want to expand
on this). Ok, here are some lines of the talking, after you read this
post your own opinion.<br><br>
<b><i>&lt;TTimo&gt; well actually, I wonder why I found this function in
the core<br>
&lt;^Fishman&gt; just for the two textures(one is 1D, the other one is
&lt;TTimo&gt; 1D texture from a loaded 2D image ?<br>
&lt;TTimo&gt; I'm not sure I'm following you<br>
&lt;^Fishman&gt; two different textures, one is 1D, the other one is
&lt;^Fishman&gt; one for attenuation the other one for the actual shape
of the image(eventually I think I will have to generate the textures
instead of loading them in order to have a reliable representation)<br>
&lt;TTimo&gt; we are not at a point where we would want something that's
well integrated in the overall design, we just want some experimental
code that works, which we can design to fit in once we know how to do
&lt;^Fishman&gt; well, the lighting shows up if I just load the texture
from the face_t but it looks uber gay because the texture for the lighing
is the same as the texture of the brush<br>
&lt;TTimo&gt; I don't understand<br>
&lt;TTimo&gt; when you render, your first pass is the brush texture, the
second one is a greyscale image<br>
&lt;TTimo&gt; I don't see why you need to use the texture to build the
lightmap, but then again, I never looked at lighting code, so I don't
&lt;^Fishman&gt; that gets colored, but it looks just like if you just
changed the hue of the who thing<br>
&lt;^Fishman&gt; doesn't look like lighting<br>
&lt;^Fishman&gt; its not making any lightmaps, its just rendering a
texture over the affected brushes<br>
&lt;^Fishman&gt; which right now are all because I don't have the
attenuation code done<br>
&lt;^Fishman&gt; nor any kind of shadow code<br>
&lt;TTimo&gt; the card is doing the computation I suppose<br>
&lt;^Fishman&gt; yes<br>
&lt;TTimo&gt; you tell it 'that second pass is what you get from
per-pixel shadow computations'<br>
&lt;TTimo&gt; I suppose that means it builds a black and white, or a
lightgrey texture<br>
&lt;^Fishman&gt; no shadow, it just check lights the radius of image into
the scene, its like the dlights in Q2<br>
&lt;^Fishman&gt; TTimo: actually it can have any colors<br>
&lt;TTimo&gt; ah, it's even easier then? why would you use some weird nv
stuff to do that<br>
&lt;TTimo&gt; standard GL supports lights<br>
&lt;^Fishman&gt; so if I make an image with some color dots and make it
rotate in the scene then it will look like a disco light or
&lt;TTimo&gt; and what would be the use to radiant<br>
&lt;^Fishman&gt; gl lights only allow 8 lights rendered at the same time,
and you have to tesselate the geometry to make it look right<br>
&lt;TTimo&gt; well that sounds fine to me<br>
&lt;^Fishman&gt; no need to tesselate or any strange thing with
&lt;TTimo&gt; use an OOB to select the nearest lights, and render<br>
&lt;^Fishman&gt; and the disco light was just an example, I will actually
use per-pixel lighting to light the maps<br>
&lt;TTimo&gt; I am interested by the solution that's appropriate for the
editor, and that fits as many cards as possible<br>
&lt;TTimo&gt; I never cared about projected shadows either anyway, so I
don't care about nv stuff<br>
&lt;^Fishman&gt; per-pixel should work on any card after the TNT2
&lt;TTimo&gt; using GL light code binded with some intelligent
&lt;TTimo&gt; should lead us to something<br>
&lt;^Fishman&gt; the nv stuff is to speed up the code, eventually if I
manage to get an ATI I may use some of their extensions<br>
&lt;TTimo&gt; I don't think it would be any speedup<br>
&lt;TTimo&gt; if you do something that can be done with regular gl
lights, some weird extensions won't speed it up<br>
&lt;^Fishman&gt; using registers conviners improves the speed a lot when
doing per-pixel lighting. At least in the NV cards<br>
&lt;TTimo&gt; after that, it's a matter of cost, I don't want to spend
time integrating some light code that would be totally overkill<br>
&lt;^Fishman&gt; the problem with gl lights is that we would need to
tesselate the geometry A LOT(at least 5 times) to make them look half
&lt;TTimo&gt; is that such a problem<br>
&lt;^Fishman&gt; it is concedering the size of the maps now<br>
&lt;^Fishman&gt; it's not such a problem for q3dm17, but it is for maps
like q3dm7 and others<br>
&lt;TTimo&gt; well we probably don't want to render the whole level
lighted anyhow<br>
&lt;TTimo&gt; we only need it for some bbox around the view<br>
&lt;TTimo&gt; the only real important thing as a preview tool, being that
it stays close to the lighting in game<br>
&lt;^Fishman&gt; yeah, we could use the cubic clipping, but for example
you go to the room of the hellish mouth in Q3dm1 and after tesselating
the geometry too many tris will be generated<br>
&lt;^Fishman&gt; well, I believe per-pixel lighting will provide closer
results to the q3map than gl lighting<br>
&lt;TTimo&gt; true<br>
&lt;^Fishman&gt; and I have no idea how long it would take to make a good
tesselation code(its easy for bezier patches but hard for normal
&lt;TTimo&gt; I'm just annoyed by too much extension specific
&lt;^Fishman&gt; well, this is the first time that extensions get used in
gtk, the multitexture wasn't being used even though the code was there,
and now I just added the reg conviners<br>
&lt;^Fishman&gt; anyways, if it fails to load then we just put a msg in
the console<br>
&lt;^Fishman&gt; &quot;sorry mr, you are fucked, no lighting for
you!&quot; :P<br><br>
&lt;^Fishman&gt;: easy access to new drivers, techniques(after some
talking with SPoG I will have to work on shadows now and I'm looking
forward to some some of the nvidia stuff that isn't available in in the
normal dev site) and get some free hardware to test and shit<br>
&lt;TTimo&gt;: I still don't think we need to use any NV specific stuff
&lt;^Fishman&gt;: my intention would be to put my stuff in a plug-in so
people wouldn't be forced to use it or anything, and as I said before we
just check if the extension needed is supported or not. And it also
improves the program, like RtCW, they use NV fog tables and ATI's truform
to improve their game but its not like if you don't have those extensions
the game doesn't work.<br>
&lt;TTimo&gt;: dynamic lighting in Q3 or RTCW doesn't rely on any NV
specific stuff<br>
&lt;^Fishman&gt;: Q3 and RTCW have a compile process that takes hours, we
can't afford that.<br>
&lt;TTimo&gt;: that's not related to the compiling<br>
&lt;^Fishman&gt;: well, the lights are drawn on the lightmaps, we don't
have light maps. And also remember that I'm not making this stuff to
simulate dinamic lights, its more than just spheres of light. And also I
have to work on shadows(probably using Carmack's reverse