How to stop a shader from emitting light?


(Apprentice) #1

For one of my maps, I had to device a shader which included the q3map_notjunc to prevent the compiler from hitting the MAX_EDGE_LINES error and therefor stopping the compilation. Now I’ve got a problem that the shader emmits light as the following images displays:


Original wall and floor


After the shader was applied

Is there a way to stop shaders from emmitting surface light or did I forget something in my shaderscript ??

textures/AB_cargo/wallbase
{
    qer_editorimage textures/cargo/wallbase.tga
    q3map_notjunc
    {
        map textures/cargo/wallbase.tga
    }
}

(obsidian) #2

There is no lightmap stage so it is rendered in full bright.

Also, enabling q3map_notjunc is not the best solution. You’re trying to fix the effect rather than the cause of the problem. You almost certainly have some bad building techniques that can be better optimized. See here:

http://www.splashdamage.com/forums/showthread.php?t=323


(Apprentice) #3

And how do I do that with my current script ?? I’ve already tried q3map_surfacelight 0 or any other q3map_ * that involves light and they didn’t work . . .

Also, enabling q3map_notjunc is not the best solution. You’re trying to fix the effect rather than the cause of the problem. You almost certainly have some bad building techniques that can be better optimized. See here:

http://www.splashdamage.com/forums/showthread.php?t=323

And that’s gonna be a problem. The original map is 'bout close to 28.000 brushes and q3map2 still compiles it normally. The moment I optimize my map and reduces that number to say 100 brushes less, the compiler gives a MAX_EDGE_LINES error, therefor deciding that to add the q3map_notjunc to some structual wallbrushes . . .


(obsidian) #4

Check out most normal shaders in whatever game you are mapping for to find an example. 80% of shaders should have a lightmap stage somewhere, it shouldn’t be hard to figure it out.

If still in doubt, read the shader manual in my signature, under Q3Map2.


(Apprentice) #5

I need a little more 'cause I’ve been spitting through every shader the game has and went through the manual(s) several times now and the only thing I can find in there, is how to let a shader emit light but nothing about the opposite . . .


(murka) #6

Lightmap stage like this:

textures/AB_cargo/wallbase
{
    qer_editorimage textures/cargo/wallbase.tga
    q3map_notjunc
    {
        map $lightmap
        rgbGen identity
    }
    {
        map textures/cargo/wallbase.tga
    }
}

(Apprentice) #7

[QUOTE=murka10;223149]Lightmap stage like this:

textures/AB_cargo/wallbase
{
    qer_editorimage textures/cargo/wallbase.tga
    q3map_notjunc
    {
        map $lightmap
        rgbGen identity
    }
    {
        map textures/cargo/wallbase.tga
    }
}

[/QUOTE]
Thanks for the answer but unfortunately, that didn’t work either. The wall and floor remains just as bright as displayed earlier . . . :frowning:


(obsidian) #8

The wall is certainly NOT emitting light. Lightmaps work in reverse, everything is first rendered in full bright and then the lightmap darkens (shadows) the surface using a subtractive blend. The problem is you are missing a lightmap stage, so there is no darkening of the surface.

http://robotrenegade.com/q3map2/docs/shader_manual/ch6.html#map

See the section under $lightmap, then also see the example shader below it. The first stage is the texture, the second is the lightmap with a subtractive blendfunc. The 3rd and 4th are extra additive effects that you probably don’t need. Most shaders are set up the exact same way, so you might want to learn exactly how this works.


(Apprentice) #9

Finally managed to get it right:

textures/AB_cargo/wallbase
{
    qer_editorimage textures/cargo/wallbase.tga
    q3map_notjunc
    {
        map textures/cargo/cargowall_base.tga
        rgbGen identity
    }
    {
        map $lightmap
        rgbGen identity
        blendfunc gl_dst_color gl_zero
    }
}

Was puzzling, but thanks for the heads-up :slight_smile:


(obsidian) #10

As an extra note, that shader you have renders the base texture first and then draws the lightmap over top of it with a filtered blendfunc. It’s also possible to reverse the order by making the lightmap draw first (in the first stage) followed by the base texture in the second stage with the blendFunc. The result is the same, but there may be times when reversing the order is desirable for certain effects.