With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
For all you mappers out there!

Moderators: Pardner, Joe Kari, TheDoctor, Breli

Trouble with high res external lightmap and texture blending

Postby JeanMarcLeProut » Mon Sep 19, 2011 5:45 pm

Hi

I use terrain blending for a new br map.
I use standard sg shader like this one :

Code: Select all
// Dirt to Sand2
textures/sg_blend/dirt_to_sand2
{
   q3map_lightimage textures/sg_sand/sand_desert2.tga
   qer_editorimage textures/sg_blend/dirt_to_sand.tga
       surfaceparm dust
   q3map_shadeangle 70
   q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
   q3map_lightmapAxis z       
   {       
      map textures/sg_sand/sand_desert2.tga     
      rgbGen identity   
   }   
   {
      map textures/sg_dirt/dirt_brown3.tga
      blendFunc GL_SRc_ALPHA GL_ONE_MINUS_SRc_ALPHA
      rgbGen identity
      alphaGen oneminusvertex
   }
   {
      map $lightmap
      blendFunc GL_DST_cOLOR GL_ZERO
      rgbGen identity
      tcGen lightmap
   }
}


Then I instruct q3map2 to generate 1024x1024 lightmap

Code: Select all
// Dirt to Sand2
textures/vg_blend/dirt_to_sand2
{
   q3map_lightimage textures/sg_sand/sand_desert2.tga
   qer_editorimage textures/sg_blend/dirt_to_sand.tga
    surfaceparm dust
   q3map_shadeangle 70
   q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
   q3map_lightmapAxis z       
     q3map_lightmapSize 1024 1024
 q3map_lightmapBrightness 2.0
  q3map_lightmapSampleSize 4
  q3map_lightmapMergable
{
    tcgen lightmap
    map $lightmap
    rgbGen identity
  }
   
   {       
      map textures/sg_sand/sand_desert2.tga     
      rgbGen identity   
   }   
   {
      map textures/sg_dirt/dirt_brown3.tga
      blendFunc GL_SRc_ALPHA GL_ONE_MINUS_SRc_ALPHA
      rgbGen identity
      alphaGen oneminusvertex
   }
   {
      map $lightmap
      blendFunc GL_DST_cOLOR GL_ZERO
      rgbGen identity
      tcGen lightmap
   }
}


the lm_000x.tga external images are generated in the map/mymap directory. The q3map2_mymap.shader is generated in the scripts directory, but the image is not used in game and the terrain is fully illuminated (like when not using q3map2 -light phase)

Something is probably missing in the runtime part of the shader, but what ?

Any idea someone ?

Thanks.
JeanMarcLeProut
Drifter
 
Posts: 7
Joined: Thu Apr 28, 2011 8:25 pm



Postby Pardner » Mon Sep 19, 2011 6:30 pm

Howdy and welcome to SG forums! There are two topics covering highres lightmaps: Joe's Tutorial and this help thread.

Looking at your script, it looks like you have two lightmap stages and you are missing blendFunc filter in the first stage. Try this:

Code: Select all
// Dirt to Sand2
textures/vg_blend/dirt_to_sand2
{
   q3map_lightimage textures/sg_sand/sand_desert2.tga
   qer_editorimage textures/sg_blend/dirt_to_sand.tga
   surfaceparm dust
   q3map_shadeangle 70
   q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
   q3map_lightmapAxis z       
   q3map_lightmapSize 1024 1024
   q3map_lightmapBrightness 2.0
   q3map_lightmapSampleSize 4
   q3map_lightmapMergable
   {       
      map textures/sg_sand/sand_desert2.tga     
      rgbGen identity   
   }   
   {
      map textures/sg_dirt/dirt_brown3.tga
      blendFunc GL_SRc_ALPHA GL_ONE_MINUS_SRc_ALPHA
      rgbGen identity
      alphaGen oneminusvertex
   }
   {
       tcgen lightmap
       map $lightmap
       rgbGen identity
       blendFunc filter
   }
}


I haven't tested this script yet, but here are some other things to check:
  • Check to see if there are any errors in the console. If there are errors about missing texture/shader, try zipping your scripts and lightmap images into a PK3
  • What switches are you using for the light stage of compile?
  • What do you have the _lightmapscale set to in the worldspawn?
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby JeanMarcLeProut » Tue Sep 20, 2011 9:05 am

Pardner wrote:Howdy and welcome to SG forums!


Thank you very much.

Pardner wrote:Looking at your script, it looks like you have two lightmap stages and you are missing blendFunc filter in the first stage.


Hum... seems you're right. I'll do some testing and post the result here.

jm
JeanMarcLeProut
Drifter
 
Posts: 7
Joined: Thu Apr 28, 2011 8:25 pm



Postby JeanMarcLeProut » Tue Sep 20, 2011 1:41 pm

Your shader works fine. Thank you very much !

But I ran in another problem

-- func_groups
I have 4 different func_groups for multiple parts of the terrain.
q3map2 outputs 4 different image, one for each func_group with a black border between them (I can see the black border between func_groups at runtime)
Should I merge all func_groups ?

-- _lightmapscale
_lightmapscale is set to 0.250. Is this a good value ?
Shoud I set _lighmapscale 0.250 for all wordspawn entities (which are not part of my terrain func_groups) ?

Thanks
JeanMarcLeProut
Drifter
 
Posts: 7
Joined: Thu Apr 28, 2011 8:25 pm



Postby Pardner » Wed Sep 21, 2011 12:28 am

JeanMarcLeProut wrote:-- func_groups
I have 4 different func_groups for multiple parts of the terrain.
q3map2 outputs 4 different image, one for each func_group with a black border between them (I can see the black border between func_groups at runtime)
Should I merge all func_groups ?

You shouldn't have to merge all the func_groups. I thought the high res lightmap was only applies to brushes that have the high res shader. I had this problem with Durango (last page of that help thread, I had the ground in a different func_group with a different _lightmapscale. So I guess, try making your highres lightmap brushes all in the same func_group. Just be careful because your texture blending also depends on func_groups.


JeanMarcLeProut wrote:-- _lightmapscale
_lightmapscale is set to 0.250. Is this a good value ?
Shoud I set _lighmapscale 0.250 for all wordspawn entities (which are not part of my terrain func_groups) ?


tweaking the _lightmapscale will adjust the size of the shadow image in the lightmap texture (maps/mapname/lm_000x.tga). Joe used 0.25 in Alamo, Red tried 0.125 and got good results, but 0.0625 yeilded no extra results.
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby JeanMarcLeProut » Sat Sep 24, 2011 2:05 pm

[quote]
You shouldn't have to merge all the func_groups.
[/quote]

But that's what I did and I solved the black border lightmap problem. (I don't understand why).

Thanks for all your help. I'll post the br map here soon.
JeanMarcLeProut
Drifter
 
Posts: 7
Joined: Thu Apr 28, 2011 8:25 pm



Postby JeanMarcLeProut » Mon Oct 10, 2011 12:11 pm

What is the use of "qer_editorimage" in this shader ? I'd like to know where this image is used (only for mean color of the brush face ?), if it needs to have an alpha channel, and what happends if I remove this line.

Thanks.
JeanMarcLeProut
Drifter
 
Posts: 7
Joined: Thu Apr 28, 2011 8:25 pm



Postby Joe Kari » Mon Oct 10, 2011 1:23 pm

It's the editor image (!), so it's not used ingame.
Radiant will use it.
User avatar
Joe Kari
SG Team
 
Posts: 878
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby JeanMarcLeProut » Mon Oct 10, 2011 4:24 pm

Oops ! Wrong copy and paste, I was speaking about the "q3map_lightimage" line.
JeanMarcLeProut
Drifter
 
Posts: 7
Joined: Thu Apr 28, 2011 8:25 pm



Postby Joe Kari » Mon Oct 10, 2011 9:31 pm

If you provide a q3map_lightimage and if your shader is a light emitting one, the light emitted will use this texture.
User avatar
Joe Kari
SG Team
 
Posts: 878
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby JeanMarcLeProut » Tue Oct 11, 2011 9:22 am

Ok.

Some more questions :

- What is the effect of having an alpha channel in the q3map_lightimage (with the same shader described in this thread) ?
- Does this image have to be the same size as the blended texture images ?
- Does the blended images have to be the same size ?

Thanks.
JeanMarcLeProut
Drifter
 
Posts: 7
Joined: Thu Apr 28, 2011 8:25 pm



Postby Pardner » Tue Oct 11, 2011 3:53 pm

JeanMarcLeProut wrote:- What is the effect of having an alpha channel in the q3map_lightimage (with the same shader described in this thread) ?

I think the shader would cast different shadows. I am struggling to think of an example... I might be incorrect, but if the shader would not cast light in the areas that are transparent.

JeanMarcLeProut wrote:- Does this image have to be the same size as the blended texture images ?
- Does the blended images have to be the same size ?

They do not need to be the same size. I think the game draws both textures separately. This is why texture blending takes more resources than regular texturing. If you look at my NoNameCity, you can see that I have a grass texture blending with a dirt texture that are obviously different resolutions.
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby Joe Kari » Tue Oct 11, 2011 5:13 pm

Pardner wrote:
JeanMarcLeProut wrote:- What is the effect of having an alpha channel in the q3map_lightimage (with the same shader described in this thread) ?

I think the shader would cast different shadows. I am struggling to think of an example... I might be incorrect, but if the shader would not cast light in the areas that are transparent.

I really don't know what it could produce, and I don't see any logic at all with an alpha light :D

Pardner wrote:
JeanMarcLeProut wrote:- Does this image have to be the same size as the blended texture images ?
- Does the blended images have to be the same size ?

They do not need to be the same size. I think the game draws both textures separately. This is why texture blending takes more resources than regular texturing. If you look at my NoNameCity, you can see that I have a grass texture blending with a dirt texture that are obviously different resolutions.

At runtime, those 2 textures can have different resolution, however, at compile time, it can cause a lot of trouble... So... If your texture coordinate are computed at compile-time (99% of time) you can have few seams. In fact, as long as you use only the blending shader, it will work more or less, but if you try to mix your blending shader with other one, what you see in radiant will be different that what you get ingame.

All the trouble come from the fact that OpenGL texture coordinate works with the texture frequency but the Q3 .map format use pixel frequency instead.
User avatar
Joe Kari
SG Team
 
Posts: 878
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby Pardner » Tue Oct 11, 2011 6:11 pm

Joe Kari wrote:In fact, as long as you use only the blending shader, it will work more or less, but if you try to mix your blending shader with other one, what you see in radiant will be different that what you get ingame.


I am aware of this problem.... for example NNC ground texture (blended) has a seam with the hill texture (no blended). So if I make sure that both my blend textures are the same resolution, the seam would be less noticeable?
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby Joe Kari » Tue Oct 11, 2011 7:34 pm

Pardner wrote:
Joe Kari wrote:In fact, as long as you use only the blending shader, it will work more or less, but if you try to mix your blending shader with other one, what you see in radiant will be different that what you get ingame.


I am aware of this problem.... for example NNC ground texture (blended) has a seam with the hill texture (no blended). So if I make sure that both my blend textures are the same resolution, the seam would be less noticeable?

It can help.
For what I saw, the frequency is not the same for ground and for hills...

However, you will have hard time fixing it anyway, once you solve the frequency trouble there will be other issue...

You can try to project the texture along the z-axis, but your texture will be streched for the hills.

Sometime the best answer is to hide those seams behind some vegetation :D
User avatar
Joe Kari
SG Team
 
Posts: 878
Joined: Sun Sep 16, 2007 8:44 pm
Location: France




Return to Level Editing

Show Sidebar
Show Sidebar

User Control Panel