Jump to content
The Dark Mod Forums

Vary amount of transparency: material or shaderParm howto..?


Bikerdude

Recommended Posts

Interesting. The interaction shaders have a specific vertex.color attribute.

 

I am suspecting that your shader should be

 
!!ARBvp1.0
OPTION ARB_position_invariant;

MOV vertex.color, {0.5, 0.5, 0.5, 1.0};

END
 

instead.

 

But I still think that this operation must be done at the vertex stage just before:

 
MAD        result.color, vertex.color, program.env[16], program.env[17];
 

in a full light interaction called from the material (how Prey does it).

 

Now that I've bruised my brains on this, time to make the glprog and material def.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

  • Replies 90
  • Created
  • Last Reply

Top Posters In This Topic

Here's the material syntax:

 
translucent/example

{



    // one set comprised of a normal map and diffuse map utilizing the vertexcolor keyword



    {

        blend add

        program    translucent_hack.vfp

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1

        fragmentMap        1        normalmap.tga

        fragmentMap        2        diffusemap.tga

        fragmentMap        3        specularmap.tga

        vertexcolor

    }



    // a second set using the same images with the inversevertexcolor keyword



    // the scale function here is "inverting" the normal map so that it catches light from the opposite side.



    {

        blend add

        program    translucent_hack.vfp

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1

        fragmentMap        1        scale(normalmap.tga, 1, 1, 0, 1)

        fragmentMap        2        diffusemap.tga

        fragmentMap        3        specularmap.tga

        inversevertexcolor

    }
 
}

and I've attached the VFP.

 

 

What this should do is an additive blend of an entire light interaction operation which is equivalent to what the engine does on a whole but we are now only doing it for this material type. What I didn't get a chance to sort out is whether the vertex parms from our old enhanced ambient would be appropriate here.

 

I didn't have time to test.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Maybe you have to pass the vertex color to the fragment color in a fragment program as well?!

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

What this should do is an additive blend of an entire light interaction operation which is equivalent to what the engine does on a whole but we are now only doing it for this material type. What I didn't get a chance to sort out is whether the vertex parms from our old enhanced ambient would be appropriate here.

 

I didn't have time to test.attachicon.giftranslucent_hack.vfp.txt

I assume I just dump this file in the glprogs folder, how do I then point to it in a material def..?

Link to comment
Share on other sites

Yes, that goes into glprogs. (needs to be renamed without the *.txt extension).

 

The example material def I posted above will already find it there. ( "program translucent_hack.vfp")

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

So using that I have the following -

translucent/wallpaper_fancy_red
{

    // one set comprised of a normal map and diffuse map utilizing the vertexcolor keyword

    {
        blend    	textures/darkmod/paint_paper/wallpaper_fancy_red
        map    	 	textures/darkmod/paint_paper/wallpaper_fancy_red
        vertexcolor
    }
    {
        blend    	textures/darkmod/paint_paper/wallpaper_fancy_r
        map    		textures/darkmod/paint_paper/wallpaper_fancy_r
        vertexcolor
    }

    // a second set using the same images with the inversevertexcolor keyword

    // the scale function here is "inverting" the normal map so that it catches light from the opposite side.

    {
        blend    	textures/darkmod/paint_paper/wallpaper_fancy_local
        map    		scale(normalmap.tga, 1, 1, 0, 1)
        inversevertexcolor
    }
    {
        blend    	textures/darkmod/paint_paper/wallpaper_fancy_r
        map    		textures/darkmod/paint_paper/wallpaper_fancy_r
        inversevertexcolor
}
Link to comment
Share on other sites

Here is a fixed version:

 

 

 
translucent/wallpaper_fancy_red
{

   {
    // one set comprised of a normal map and diffuse map utilizing the vertexcolor keyword
    
    blend add

        program    translucent_hack.vfp  // program that forces vertex color to grey and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1

        fragmentMap        1        textures/darkmod/paint_paper/wallpaper_fancy_local

        fragmentMap        2        textures/darkmod/paint_paper/wallpaper_fancy_red

        fragmentMap        3        _black // specular

        vertexcolor

    }
   
    {
    
       
    // a second set using the same images with the inversevertexcolor keyword
    // the scale function here is "inverting" the normal map so that it catches light from the opposite side.

        blend add

        program    translucent_hack.vfp    // program that forces vertex color to gray and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1

        fragmentMap        1        scale(textures/darkmod/paint_paper/wallpaper_fancy_local, 1, 1, 0, 1)

        fragmentMap        2        textures/darkmod/paint_paper/wallpaper_fancy_red

        fragmentMap        3        _black // specular

        inversevertexcolor

    }

}
 

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Hmm.

 

I think:

 
fragmentMap 2
 
fragmentMap 3
 

needs to be

 
fragmentMap 4  texture // diffuse
 
fragmentMap 5 texture // specular
 

I guess Biker might let me know before I get a chance to test tonight. :) ?

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

testing it now...

 

So as follows.?

translucent/wallpaper_fancy_red
{
   {
    // one set comprised of a normal map and diffuse map utilizing the vertexcolor keyword
    
    blend add

        program    translucent_hack.vfp  // program that forces vertex color to grey and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump
        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular
        vertexParm        2        global2, global3, global4, 1

        fragmentMap        0        cubeMap env/gen1
        fragmentMap        1        textures/darkmod/paint_paper/wallpaper_fancy_local
        fragmentMap        4		textures/darkmod/paint_paper/wallpaper_fancy_red
        fragmentMap        5        _black // specular

        vertexcolor
    }
 
    {       
    // a second set using the same images with the inversevertexcolor keyword
    // the scale function here is "inverting" the normal map so that it catches light from the opposite side.

        blend add

        program    translucent_hack.vfp    // program that forces vertex color to gray and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump
        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular
        vertexParm        2        global2, global3, global4, 1

        fragmentMap        0        cubeMap env/gen1
        fragmentMap        1        scale(textures/darkmod/paint_paper/wallpaper_fancy_local, 1, 1, 0, 1)
        fragmentMap        4        textures/darkmod/paint_paper/wallpaper_fancy_red
        fragmentMap        5       _black // specular

        inversevertexcolor
    }
}
Link to comment
Share on other sites

The last thing I can think of is to add fragmentMap values for the light projection and falloff textures.

 

Eg:

 
fragmentMap 2 _noFallOff  // falloff texture
 
fragmementMap 3 textures/lights/brightround // projection texture
 

This would be a little odd because it would mean that no mater what light shader you use, this material

will act like a specific light projection is hitting it. Might not be too bad but it would definitely mismatch things

like the window projections.

 

I presume you tried both 2/3 and 4/5 mappings with the same results?

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I had another thought.

 

Perhaps adding a black diffuse stage above the program stage would force the engine to include the surface in vertex cache.

 


{

{

Diffusemap _black

}

{

Blend add

Program translucent_hack.vfp

Etc

}

VertexColor

}

Oh, and the material will need the "twosided" keyword.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Complete example if someone wants to try before I do:

 

 

 
translucent/wallpaper_fancy_red
{
twosided


  {
    // one set comprised of a normal map and diffuse map utilizing the vertexcolor keyword
    
    {
    
    diffusemap _black // force lighting pass into vertex cache
    
    }
    
    {
    
    blend add

        program    translucent_hack.vfp  // program that forces vertex color to grey and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1

        fragmentMap        1        textures/darkmod/paint_paper/wallpaper_fancy_local

        fragmentMap        2        textures/darkmod/paint_paper/wallpaper_fancy_red

        fragmentMap        3        _black // specular


    }
      vertexcolor
      
  }  
  {
          
       
    // a second set using the same images with the inversevertexcolor keyword
    // the scale function here is "inverting" the normal map so that it catches light from the opposite side.
    
    {
    
    diffusemap _black
    
    }
    {
        blend add

        program    translucent_hack.vfp    // program that forces vertex color to gray and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1

        fragmentMap        1        scale(textures/darkmod/paint_paper/wallpaper_fancy_local, 1, 1, 0, 1)

        fragmentMap        2        textures/darkmod/paint_paper/wallpaper_fancy_red

        fragmentMap        3        _black // specular

     

    }
   inversevertexcolor
   }
}
 

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I can say that this doesn't work but I've made progress this evening.

 

As I suspected, fragmentMap 4 and 5 map to diffuse and specular whilst 2 and 3 map to falloff and projection images. The problem being, how do we acquire the images from the light rather than hard code them here. If there were a _currentLight internal image that would be great but I suspect that this is not the case.

 

I'll try to resume this on Monday. I've got family stuff all weekend.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I didn't get any changes tested last night but I've finally wrapped my head around the VertexParm mappings.

 

VertexParm <number> == program.local[<number>]

 

global<number> == program.env[<number>]

 

I am still at a dead end about the light projection images unless FragmentParm can somehow grab them.

 

After decoding all this I am wondering if I can just plug a program.local[x] reference into the default interaction.vfp

in place of the vertex color attribute and then call it via VertexParm in the material def.

 

eg.

 

end of vp:

 
MOV vertex.color, program.local[0];
MAD        result.color, vertex.color, program.env[16], program.env[17];
 

and then

 

(inside the material def)

 
VertexParm   0       0.5, 0.5, 0.5, 1.0
 

I think this is how the RGB keywords (etc)

work so it should be possible to do it this way AFAIK. I don't recall seeing anything in the material parser that requires

VertexParm to be after a Program reference in the material def.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Well, with the added MOV statement in the ARB (vfp) it won't work, but you can evaluate the strangeness of the current example

if you comment that line out with a # symbol in translucent_hack.vfp and use this material:

 
translucent/wallpaper_fancy_red
{
twosided


    // one set comprised of a normal map and diffuse map utilizing the vertexcolor keyword
    
    {
    
    diffusemap _black // force lighting pass into vertex cache
    vertexcolor
    }
    
    {
    
    blend add

        program    translucent_hack.vfp  // program that forces vertex color to grey and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1
 
        fragmentMap        1        textures/darkmod/paint_paper/wallpaper_fancy_local
 
        framentMap          2        _noFalloff
 
        fragmentMap        3        textures/lights/brightround

        fragmentMap        4        textures/darkmod/paint_paper/wallpaper_fancy_red

        fragmentMap        5        _black // specular

     vertexcolor
    }
     
      
  
  
          
       
    // a second set using the same images with the inversevertexcolor keyword
    // the scale function here is "inverting" the normal map so that it catches light from the opposite side.
    
    {
    
    diffusemap _black
    inversevertexcolor
    }
    
    {
        blend add

        program    translucent_hack.vfp    // program that forces vertex color to gray and runs the lighting stages

        vertexParm        0        1, 1, 1, 1        // UV Scales for Diffuse and Bump

        vertexParm        1        1, 1, 1, 1    // (X,Y) UV Scale for specular

        vertexParm        2        global2, global3, global4, 1



        fragmentMap        0        cubeMap env/gen1

        fragmentMap        1        scale(textures/darkmod/paint_paper/wallpaper_fancy_local, 1, 1, 0, 1)
 
        framentMap          2       _noFalloff
 
        fragmentMap        3        textures/lights/brightround 

        fragmentMap        4        textures/darkmod/paint_paper/wallpaper_fancy_red

        fragmentMap        5        _black // specular

     
        inversevertexcolor 
    }
   

}
 

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

The indirect nature of this workaround seems to cause more problems than it solves. I think this and vertex colors are a dead end.

 

Instead of trying to control the contribution of each render pass during composite with vertex colors, how about darkening the diffuse stage of each pass by 50 percent? The result should be equivalent. It should look something like this...

translucent/example

{

    // first pass

    {
        blend    bumpmap
        map    normalmap.tga
    }
    {
        blend    diffusemap
        map    diffusemap.tga
        rgb    0.5
    }

    // second pass
    // the scale function here is "inverting" the normal map so that it catches light from the opposite side.

    {
        blend    bumpmap
        map    scale(normalmap.tga, 1, 1, 0, 1)
    }
    {
        blend    diffusemap
        map    diffusemap.tga
        rgb    0.5
    }
Edited by rich_is_bored
Link to comment
Share on other sites

Oh!

 

So the second diffuse stage acts like an additive blend (because the light passes are additive)?

 

Interesting. I guess that would also mean that you could ramp to black on each diffuse stage and the result would

be like blending. Not that useful in the context of a single material though (outside of this idea).

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 2 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...