Forum

Dark spots/edges near sky when using sky lighting in Quake2

Discuss the construction of maps and the tools to create maps for 3D games.

Moderator: InsideQC Admins

Dark spots/edges near sky when using sky lighting in Quake2

Postby jitspoe » Thu Feb 26, 2015 9:49 pm

If you have a wall directly up against a sky ceiling, you'll get some weird shadowy edges on it. I'm pretty sure ArghRad fixed this, and maybe some other compilers. Anybody know how this fix was done?
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby qbism » Sat Feb 28, 2015 4:06 pm

The same thing goes for light emitting faces. At intersections it looks like a series of point lights that don't overlap enough. Maybe argh increases the radius, decreases the spacing, or uses a different fall-off function. This is just a guess for now. But here's the place where the reflectivity of radiosity is seen to double as light emitter. Excerpt from MakePatchForFace in patches.c
Code: Select all
   // non-bmodel patches can emit light
   if (fn < dmodels[0].numfaces)
   {
      BaseLightForFace (f, patch->baselight);

      ColorNormalize (patch->reflectivity, color);

      for (i=0 ; i<3 ; i++)
         patch->baselight[i] *= color[i];

      VectorCopy (patch->baselight, patch->totallight);
   }
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby qbism » Sat Feb 28, 2015 7:57 pm

Getting some improvement with inverse-square falloff rather than straight inverse. Changes the character of lighting throughout the map, however. Much more even.
In GatherSampleLight
Code: Select all
inv = 0.15 / sqrt(dist); //qb: was 1.0f / dist;
The 0.15 number is something to play with to try to match the overall intensity of the original function.
Not as good as arghrad this way. Maybe an average of inverse and inverse-square, or something more complex.
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby jitspoe » Sun Mar 01, 2015 2:48 am

Hmm, changing that would effectively change the falloff of light in general to be less accurate, wouldn't it?
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby qbism » Sun Mar 01, 2015 5:32 pm

Definitely inaccurate. Real-world light is inverse square, DeWan qrad3* is inverse, and other choices include inverse square.

One possibility is to use different functions for different things- inverse for point lights and something else for emitters.

My first guess for arghrad was that is uses a hybrid: inv = 1.0/ (dist * A + sqrt(dist) * B) where A and B are static values. But I haven't been able to duplicate that look. Perhaps A and B are based on distance. Or maybe it's a single factor in a power function? The assumption is that we want to 'smear' the lighting near the emitting source patch to hide darkspots but transition to typical inverse lighting further out.

*edit1: not sure about vanilla, it's written differently than DeWan's GatherSampleLight.

edit2: try this (2 changes):
Code: Select all
...
         else
         {
            inv = 4.5f / (dist * sqrt(dist)); //qb: was 1.0f / dist;
            delta[0] *= inv;
            delta[1] *= inv;
            delta[2] *= inv;
         }

         dot = DotProduct(delta, normal);
         if (dot <= 0.001)
            continue;   // behind sample surface

         if (l->adjangle == 1.0f)
            adj = dot;
         else if (l->adjangle = 0.0f)
            adj = 1.0f;
         else
         {
            adj = pow(dot, l->adjangle);
         }

         switch (l->type)
         {
         case emit_point:
            // linear falloff
            scale = (l->intensity - (l->wait * dist)) * adj;
            break;

         case emit_surface:
            dot2 = -DotProduct(delta, l->normal);
            if (dot2 <= 0.001)
               goto skipadd;   // behind light surface
            //scale = (l->intensity / (dist * dist)) * dot * dot2;
            scale = (l->intensity * inv * 0.15) * dot * dot2;  //qb: was (l->intensity * inv * inv) * dot * dot2;

            break;
...
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby jitspoe » Sun Mar 01, 2015 11:10 pm

I'll try to play around with this soon.

I would have thought the problem would come from the DotProduct check, as the black edge would be where the dot product is at/near zero. I wonder if adding a small fraction to the DotProduct result would help with this (but might cause light to bleed into areas it shouldn't).
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby qbism » Mon Mar 02, 2015 6:04 pm

You might be looking at a different artifact if it's a completely black area vs a gradient. What I'm seeing with DeWan tools is like a series of point lights around sky openings and large light-emitting surfaces, and the points get further apart with larger -chop sizes. When I tried the code above it 'works' near these conditions but produces splotchy dark patches elsewhere. So next I will try 1/sqrt(dist) for patches and the original 1/dist for spots and point lights.

I haven't been able to find any other Q2 code that deals with altering radiosity. Alien Arena and q2world tools have modified features but both source code bases remove emitting surfaces.
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby jitspoe » Tue Mar 03, 2015 3:44 am

This is what I'm referring to:

If I put a sky (or I guess any light emitting surface) flat along the top of a map, I get this (note the dark edges):
Image

It's possible to work around this by building the sky up vertically (building walls of sky) and having a higher sky ceiling:
Image
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby qbism » Wed Mar 04, 2015 2:58 am

I haven't run into that type of artifact. I built a little test map and tried 'flat sky' vs 'raised sky' but no edge problems on the test map. On the other hand, I was able to find an example of seemingly random splotchy or linear lightmap artifacts that I've been getting. Screenshots below- the first is vanilla GPL map tools and the second is modified DeWan qrad3, currently: inv =3.0f / (dist * sqrt(dist)) and emit_surface scale = (l->intensity * inv * 0.3) * dot * dot2

Since I compiled both from scratch, I wonder if it is related to the floating point Quake lightmap glitch posted around here a few months ago.

Image

Image
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby qbism » Wed Mar 04, 2015 3:19 am

OK, so I added a long skinny brush on the wall to eventually make it a light. But simply adding the brush made the artifact disappear. This doesn't solve the underlying issue but it shows the nature of the problem.
Image
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby jitspoe » Wed Mar 04, 2015 7:46 am

I noticed a similar issue (horizontal line on a wall) in my test map. Not sure what causes it. Maybe it's at the max edge when the lighting util is forced to chop the geometry? Maybe adding another brush caused qbsp to break the geometry up differently?

There are certainly some weird little nuances that are difficult to debug.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby mankrip » Wed Mar 04, 2015 8:11 am

jitspoe wrote:This is what I'm referring to:

If I put a sky (or I guess any light emitting surface) flat along the top of a map, I get this (note the dark edges):
Image

It looks like a raytracing problem. At the very edges, the wall is perfectly orthogonal to the sky surface, so it's impossible to trace a beam from any point in the sky surface to the top edge of the wall.

To fix that, the lighting tool would have to manually set the lightmap values at the shared edges of surfaces that shares edges with the sky surface, as long as the planes of those surfaces are < 180 degrees and >= 90 degrees in relation to the plane of the sky surface. Or something like that.

Another solution would be for the lighting tool to interpret sky surfaces as if they were boxes, and trace from behind the sky surfaces instead of tracing from the actual location of their planes.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby Spike » Wed Mar 04, 2015 10:04 am

aye, a co-planar ray tracing issue will do it.
your traceline will have start==0 and end==0 as it traces horizontally along the plane. if your code considers dist=0 to be an impact then it'll consider the wall to be behind the sky instead of infront, and thus won't light those light samples.
you can change your code to consider both start and end equal to 0 to not be a trace, but doing so potentially allows leaking light due to tracing between brushes.
probably the easiest/safest way to fix it is to nudge the world coord of those surface points towards the center of the wall polygon somehow, avoiding the worst of any coplaner issues, but can still have precision issues, and might give neighbouring surfaces different light levels for the same point (resulting in harsh lines at the boundary between light/shade).
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby mankrip » Wed Mar 04, 2015 10:40 am

Spike wrote:aye, a co-planar ray tracing issue will do it.
your traceline will have start==0 and end==0 as it traces horizontally along the plane. if your code considers dist=0 to be an impact then it'll consider the wall to be behind the sky instead of infront, and thus won't light those light samples.
you can change your code to consider both start and end equal to 0 to not be a trace, but doing so potentially allows leaking light due to tracing between brushes.
probably the easiest/safest way to fix it is to nudge the world coord of those surface points towards the center of the wall polygon somehow, avoiding the worst of any coplaner issues, but can still have precision issues, and might give neighbouring surfaces different light levels for the same point (resulting in harsh lines at the boundary between light/shade).

But there's no need to do any tracing. We already know that the lighting in the top edges of those walls should have the maximum value emitted by the sky surface, so it's just a matter of setting that value into their corresponding positions in the lightmap.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Re: Dark spots/edges near sky when using sky lighting in Qua

Postby qbism » Wed Mar 04, 2015 6:03 pm

Aren't light-emitting surfaces simulated by a grid of point lights? The top edge of the wall should see a point light as well as any other point on the wall. Can the sky plane itself obscure a light-emitting point on the plane?
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Next

Return to Mapping

Who is online

Users browsing this forum: No registered users and 2 guests