simulation@Posted: Tue Jun 05, 2007 2:47 pm :
I'm using a material on a model in a mainmenu.gui renderDef and altering the lightColor of the renderDef to dynamically colour the surfaces of the model - I can't think of another way because you can't get access to the shaderparms for a renderDef.

This works fine except that the whole model gets lit with the applied light. I'd like only certain shader stages to use the light color if that is possible.

For example...

Code:
material test_shader {
    // This stage is lit as normal,
    // with the colour of the light hitting the surface
    {
        blend diffuse
        map lit_stage_d.tga
    }
    {
        blend bumpmap
        map addnormals(lit_stage_local.tga,heightmap(lit_stage_h.tga, 5))
    }
    {
        blend specular
        map lit_stage_s.tga
    }
    // I want this stage to be lit with "white" light so that bump/spec
    // are rendered but the diffuse remains uncoloured by the light
    {
        blend diffuse
        map unlit_stage_d.tga
    }
    {
        blend bumpmap
        map addnormals(unlit_stage_local.tga,heightmap(unlit_stage_h.tga, 5))
    }
    {
        blend specular
        map unlit_stage_s.tga
    }
}


The best I've managed so far is to implement the "unlit" stage as "blend add", but thats not great because it bypasses the bump/spec stages and appears flat.

Code:
material test_shader {
    // This stage is lit as normal,
    // with the colour of the light hitting the surface
    {
        blend diffuse
        map lit_stage_d.tga
    }
    {
        blend bumpmap
        map addnormals(lit_stage_local.tga,heightmap(lit_stage_h.tga, 5))
    }
    {
        blend specular
        map lit_stage_s.tga
    }
    // This stage remains unlit fine but because it is "blend add"
    // it is "flat"
    {
        blend add
        map unlit_stage_d.tga
    }
}


This is how it looks with the above shader. The body is bump/specced fine (lit stage) but the arms, head and boots (blend add stage) look poor.

Image

Any suggestions?

Sim



rich_is_bored@Posted: Wed Jun 06, 2007 1:21 am :
I haven't played with renderDefs much. Is it possible to light a model with two or more lights?

If so, you can use the "spectrum" keyword on a per material basis. More on that here...

http://www.modwiki.net/wiki/Spectrum_%2 ... keyword%29



simulation@Posted: Wed Jun 06, 2007 7:29 am :
rich_is_bored wrote:
I haven't played with renderDefs much. Is it possible to light a model with two or more lights?

If so, you can use the "spectrum" keyword on a per material basis. More on that here...

http://www.modwiki.net/wiki/Spectrum_%2 ... keyword%29


Thanks Rich, but unfortunately not :( In Q4 the renderDef supports multiple light sources but not D3.

Even if it did, the light is simply defined as a Vec4:

lightColor r,g,b,x (not sure what it uses x for)

I'll have a dig through the materials and see if there is a default light material that it uses for the renderDef light source.

I've thought of using a spectrum as I've found that to be really useful for selective effects, but as far as I can see it is a shader keyword, not a stage keyword.

Sim



rich_is_bored@Posted: Wed Jun 06, 2007 10:24 am :
Let's say shaderparms worked. What would you be doing with them?



simulation@Posted: Wed Jun 06, 2007 11:13 am :
rich_is_bored wrote:
Let's say shaderparms worked. What would you be doing with them?


The idea is to adjust the R,G,B to allow a "colored" stage with a greyscale diffuse map to vary.

I've taken a slightly different approach and coerced the SDK into adjusting the material definition of my model skins on the fly. Finally managed to achieve my goal...

I've uploaded a preview of my work in progress menu...

http://www.the-emz.com/download/Movie_MD5.wmv

The body here is still a single material, but the diffusemap is in two parts. One is the area that does not get colored, the other is a greyscale.

I still can't get at the model's shaderparms but I'm now using this shader...

Code:
material skins/gui/marine/body {
   noselfShadow
   noOverlays
   clamp
   bumpmap      addnormals(models/characters/male_npc/marine/marine_local.tga,heightmap(models/characters/male_npc/marine/marine_h.tga, 5))
   {
      blend   diffusemap   
      map      scale(models/characters/male_npc/marine/marine_patch.tga,2,2,2,1)
      red      0.1
      green   0.2
      blue   0.3
   }
   {
      blend    diffusemap
      map      models/characters/male_npc/marine/marine_base.tga
   }
   specularmap   models/characters/male_npc/marine/mp1_s.tga
}


I dynamically adjust the red, green and blue values using the SDK to change the base material.

Sim



rich_is_bored@Posted: Thu Jun 07, 2007 10:56 am :
That's a very clean interface you have there. :)



simulation@Posted: Thu Jun 07, 2007 11:01 am :
rich_is_bored wrote:
That's a very clean interface you have there. :)


It still a work in progress but its getting better. I just uploaded a new version of the video (same link as above).