rgbgen const on vertex shaders?


(mslaf) #1

I’d like to change the shader/texture luminosity on vertex lighted shader. Is it possible BTW?

This is how I can do it for the lightmapped version:

textures/fallen/wall1_lite
{
	{
		map $lightmap
	}
	{
		map textures/fallen/wall1.tga
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen const ( 0.80 0.80 0.80 )
	}
}

But have no idea how to convert it to the vertex shaded version. I would appreciate you help.


(MindLink) #2

try the following :


textures/fallen/wall1_lite_vertex
{ 
   { 
      map $whiteimage
      rgbGen vertex
   } 
   { 
      map textures/fallen/wall1.tga 
      blendFunc GL_DST_COLOR GL_ZERO 
      rgbGen const ( 0.80 0.80 0.80 ) 
   } 
} 

I don’t think that it’s possible with one shader pass tho. If the $whiteimage stuff doesn’t work (should normally) simply use a small pure white colored .tga instead.


(mslaf) #3

Works great! Thanks MindLink.


(ratty redemption) #4

for a totally vertex lit version you try this:

edit: doesn`t work as intended, see my next post

textures/fallen/wall1_lite_vertex2 
{
    qer_editorimage textures/fallen/wall1.tga
    q3map_nolightmap
   { 
      map textures/fallen/wall1.tga 
      rgbgen const ( 0.80 0.80 0.80 ) 
   } 
}

(MindLink) #5

ratty that one is not vertex lit but has a constant gray lighting. :slight_smile:


(MindLink) #6

Ah and mslaf, put a “surfaceparm pointlight” in your shader before the first texture stage, forgot that :slight_smile:


(mslaf) #7

Ok, maybe it will be useful for someone.

UPDATED

  1. Normal vertex shader (no RGB change)
  2. MindLink’s example
  3. Ratty redemption’s example

Quake 3:

Shaders:

// shader #1 on screenshot
textures/fallen/wall1_vx
{
   qer_editorimage textures/fallen/wall1
   q3map_nolightmap
   {
      map textures/fallen/wall1.tga
      rgbGen vertex
   }
}

// shader #2 on screenshot
textures/fallen/wall1_dark_vx1
{
   qer_editorimage textures/fallen/wall1
   q3map_nolightmap
   {
      map $whiteimage
      rgbGen vertex
   }
   {
      map textures/fallen/wall1.tga
      blendFunc GL_DST_COLOR GL_ZERO
      rgbGen const ( 0.50 0.50 0.50 )
   }
}

// shader #3 on screenshot
textures/fallen/wall1_dark_vx2
{
   qer_editorimage textures/fallen/wall1
   q3map_nolightmap
   q3map_vertexscale 0.5
   {
      map textures/fallen/wall1.tga
      rgbGen vertex
   }
}

Although these are fine for me but may someone give an example of these new q3map2 features ydnar was writing about. Sorry, but I’m the shader ‘lame’ and couldn’t do that;) How to use the q3map_rgbGen option for example?


(ydnar) #8

Quake 3’s vertexlight mode collapses shaders to a single stage, so the whiteimage trick won’t work. Unfortunately, there is no per-stage rgbMod command to multiply the vertex RGB.

On that note, the development version of Q3Map2 has the following new/fixed features, available now:


q3map_colorGen -or q3map_rgbGen
q3map_rgbMod -or- q3map_colorMod
q3map_alphaGen

These new keywords are synonyms for q3map_alphaMod, except where color requires 3 values:

q3map_rgbMod scale ( R G B )
q3map_rgbMod set ( R G B )
which is the same as
q3map_rgbGen const ( R G B )

In addition to:

q3map_backShader <target shader>
Which works again, so you don't have to use q3map_cloneShader + q3map_invert anymore.

q3map_remapShader <target shader>
so you can remap q3map_rgbGen const shaders to a single shader to optimize the map

q3map_noVertexLight
on the target shader to prevent Q3Map2 from overriding the BSP-phase set rgb color.

More later…


(ratty redemption) #9

ratty that one is not vertex lit but has a constant gray lighting

ah, good point, sorry guys… I should of been more awake before posting that… yes for a surface to be vertex lit, it needs to have an rgbgen vertex, or rgbgen oneminusvertex, although it still wouldn`t need a blendfunc or lightmap stage, eg

textures/fallen/wall1_dark_vx3 
{ 
   qer_editorimage textures/fallen/wall1 
   q3map_nolightmap // or surfaceparm pointlight
   { 
      map textures/fallen/wall1.tga
      rgbgen vertex 
   } 
}

ratty redemption vertex lit example - doesn’t work, looks same like #1

although my first example doesn`t do what it was ment to, it does “technically” work, as it changes the overall color at each vertex, ie the corners will be all the same with no shadow or highlights.

the reason you couldn`t see a difference is the values were too bright, but low values like ( 0.1 0.1 0.1 ) or mixed values like ( 0.1 0.05 0 ) would be noticeable, the latter example turning the tex a dark orange color.

I use rgbgen const a lot to mix colors for tex like water, neon signs and light fittings, where the surfaces don`t need shadows… admittedly, there is little use for this on a wall tex, so my mistake there :wink:

anyway, re reading mslaf`s original post, and me now being more awake, I realized he could use a shader like this:

textures/fallen/wall1_dark_vx4 
{ 
   qer_editorimage textures/fallen/wall1 
   q3map_nolightmap // or surfaceparm pointlight
   q3map_vertexscale 0.25
   { 
      map textures/fallen/wall1.tga
      rgbgen vertex 
   } 
}

although MindLinks version is just as good, as it sets the shadow, highlight values in his first stage and sets the luminosity in his 2nd stage... both methods could produce the same results using slightly higher values in MindLinks then mine.

incidentally, a lightmapped version of this would look like this:

textures/fallen/wall1_dark_vx5 
{ 
   qer_editorimage textures/fallen/wall1 
   q3map_lightmapgamma 0.25
   { 
      map $lightmap 
   } 
   { 
      map textures/fallen/wall1.tga
      blendfunc filter
   } 
}

hth, and Ill edit my previous post to say it doesnt work as intended.


(ratty redemption) #10

ydnar, posted before Id finished typing and interesting post ydnar, Im especially pleased you re enabled q3map_backshader as I didn`t like using that clone shader for back faces.


(mslaf) #11

Works fine now. I have updated my previous post.

Thanks ratty redemption;)


(ratty redemption) #12

cool :slight_smile: