Jump to content
System downtime for updates - Sunday 13 July 2025 ×
The Dark Mod Forums

Recommended Posts

Posted

Eleven years working on this mod and I still don't understand shaderparms.

You, me and a lot of other people. I would hazzard a guess and say that this is one of the few wholy under used features of the engine.

bhm_banner.jpg

Posted (edited)

Especially the way they interact with lookup tables. https://www.iddevnet.com/doom3/materials.phpintroduces tables by saying, 'In Quake3, you could do all kinds of neat things with sin waves, saw tooth waves, square waves and other types of waves'--but doesn't say what they are.

 

(Edit: by the second 'they' I mean the neat things in all their kinds, not the wave types.)

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

ShaderParms, tables, and a handfull of internal variables are used in mathematical expressions. Anywhere in a material shader where a numerical value is used, you can usually substitute it with an expression. Because expressions are evaluated every frame it means you have the ability to animate some aspects of materials.

 

 

  • time: Forever increasing floating point value that returns the current time in seconds
  • parm0-parm11: Parameters that can be set a number of ways (discussed above)
  • global0-global7: Not used right now
  • fragmentPrograms: Constant that is 1 if ARB fragment programs are available. This is mostly used for disabling a stage by specifying "if ( fragmentPrograms == 1 )"
  • sound: The current sound amplitude of the entity using this material. This is used to create light materials that pulse with the sound.

 

 

A cursory look over the material keywords that accept numerical values will give you an idea of what can be animated. A few examples of properties you could animate would be rotation, scale, translation, shear, brightness, and transparency.

 

Time is used in virtually every expression. It's similar to a frame counter. It starts at zero and increments.

 

Still with me? Good. Here's where we test what you've learned. Here's a stage with an expression...

{
   translate time, time
   map textures/custom/foo.tga
}

What's this doing? Remember, time starts at zero. Then it's one. Then two, three, four, and so on.

 

 

If you said scroll the texture horizontally and vertically you'd be correct.

 

 

Okay. One more example that's a bit more difficult.

{
   translate time * 0.1, time * 2
   map textures/custom/foo.tga
}

 

If you said scroll the texture slowly on the horizontal, and fast on the vertical you'd be correct.

 

 

It helps a great deal if you have a mathematical mind, are familiar with operators like modulo (%), and can graph functions. It's algebra and you're solving for x.

 

Tables are just that. Tables with values in them.

table myNumbers {0.5, 1, 0.5, 1, 0.6, 1, 0.5, 0.8, 0.5, 1, 0.5, 0.6 }

You might use these values to make something flicker...

{
  rgb myNumbers[time]
  map textures/custom/foo.tga
}

In this case, time is the index. It's asking for the value in position zero. Then one, two, and so on.



			
		
  • Like 1
Posted
table myNumbers {0.5, 1, 0.5, 1, 0.6, 1, 0.5, 0.8, 0.5, 1, 0.5, 0.6 }

table myNumbers {{0.5, 1, 0.5, 1, 0.6, 1, 0.5, 0.8, 0.5, 1, 0.5, 0.6 }}

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted
It helps a great deal if you have a mathematical mind

 

 

I definitely do not. :)

 

But I do understand most of what you posted already...just not how shaderparms fit into that. Are they just floating values that can be added to an entity by a spawnarg somehow?

Posted

It's another set of parameters you can use in your expressions. The difference being that these parameters are set at the entity level.

 

For example, say you have two lights that pulse using the same material shader. If "time" is the only parameter you're using to control the effect, then all lights using that shader will pulse in sync. Maybe you don't want that. So you use a shaderparm to act as an offset. Maybe the original expression looks kinda like this...

sinTable[time * 0.01]

You'd modify it like this...

sinTable[(time + parm1) * 0.01]

And now in DR you can simply add a parm1 key/value pair to every light using this material to change it's offset.

  • Like 1
Posted

Just to check, though: are you looking at the inherited spawnargs list, and still seeing the old setting greyed out?

No, it changes to black (as it should I guess).

 

I haven't noticed that problem, but I always hit Enter to set a spawnarg. You can see whether it's changed if you look at the panel above (you might need to turn off inherited spawnargs).

Maybe that was the problem. I always looked at the gray value and it didn't seem to change...

 

Thanks!

Posted

Shaderparms can also be used conditionally, as in this example from id's page:

models/weapons/soulcube/soulcube3fx
{
    noSelfShadow
    translucent
    noShadows
    {
        if ( parm7 > 3 )
        blend add
        map models/weapons/soulcube/soulcube3fx
        rgb scTable[ time * .5 ] 
    }
}

The entire blend add stage gets drawn or not drawn depending on the current value of parm7.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

It's another set of parameters you can use in your expressions. The difference being that these parameters are set at the entity level.

 

For example, say you have two lights that pulse using the same material shader. If "time" is the only parameter you're using to control the effect, then all lights using that shader will pulse in sync. Maybe you don't want that. So you use a shaderparm to act as an offset. Maybe the original expression looks kinda like this...

 

sinTable[time * 0.01]
You'd modify it like this...

sinTable[(time + parm1) * 0.01]
And now in DR you can simply add a parm1 key/value pair to every light using this material to change it's offset.

That's helpful, thanks.

Posted

Hello, I am back with another mapping question:

I made some readables, but I want some of them not to be frobable (for instance, on a bulletin board, the player should be able to read 2 of them, not all 10).

How do I accomplish this? (I tried using 'frobable 0' but that makes the readable blank)

Posted

I never noticed this before, but you're right. Apparently being frobable tells the renderer to paint the text even when the readable isn't highlighted. Not frobable = no text painting.

 

Since the renderer will paint the text even when the readable isn't highlighted, there's nothing that forces the player to frob the readable in order to read the text. He could just stand there and read it.

 

Is that unacceptable?

Posted
Since the renderer will paint the text even when the readable isn't highlighted, there's nothing that forces the player to frob the readable in order to read the text. He could just stand there and read it.

 

 

That's the way it is designed to work. The play can potentially use the spyglass to read things from a distance.

 

I think what he's trying to do is make a readable that can ONLY be read from a distance, not frobbed and read close-up.

Posted

 

I think what he's trying to do is make a readable that can ONLY be read from a distance, not frobbed and read close-up.

 

Correct. But even if it's frobable, and lights up when the player is near it, it's still readable w/o the player actually frobbing it.

 

I guess we need to hear why this isn't acceptable.

Posted

Rather than creating a readable, you can use this method to create text of any size on any background.

 

Place a model sheet of paper on a wall, and create the text gui and place it right up against the paper.

 

You'll be able to read the text w/o anything being frobable.

Posted

From left to right: what I drew in Krita, what I see after saving as TGA and loading in IrfanView, and what I see when loading the TGA in an in-game GUI.

banding.png

I can fix the brightness in IrfanView, but is there anything that can be done about the colour banding in the right-hand image?

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

On my monitor, there's banding in the original too. Less visible than in #3, but that could be due to the brightness difference. Subtle colour gradients don't look good brightened. #2 looks like the bands have been hidden by oversaturation. The gradient has been lost too, but that could just be in the screenshot given that some detail is back in #3 -- hard to tell without seeing what #3 looks like when the brightness is lowered again. You can tweak the rgb channels in the material shader.

Posted

Does anyone know a way to force textures to be opaque in DR? The "forceOpaque" keyword is used by dmap, but it seems it doesn't work in DR.

 

I tried changing portalsky to be a blended material to fix a problem with it drawing over lit decals, but now it's semi-transparent in DR which might drive people nuts.

Posted

The editor image is opaque (well, a normal image), but DR is rendering it 50% transparent presumably because its only diffuse stage is a blend stage.

 

I could try hacking it around, but I wondered if there was an editor_ keyword or some other good way to fix it.

Posted

Does anyone know of an FM that has water flow? i'm trying to get it to work myself but it just doesn't work.. I've created the func_forceshield as per the wikis recommendation but it just doesn't flow... as soon as the player hits the water flow it just slowly moves them.

 

Thanks!

Posted

Does anyone know of an FM that has water flow?

Yes, Arcturus made a demo map and I have a copy. I never got around to learning how it worked so I could implement it in a map etc. I've included a copy of the famous grass map with the fish in the pond. -

 

- mega

bhm_banner.jpg

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

    • JackFarmer

      "The Year of the Rat." 
      😄

      Al Stewart must be proud of you!
      Happy testing!
      @MirceaKitsune
      · 1 reply
    • datiswous

      I posted about it before, but I think the default tdm logo video looks outdated. For a (i.m.o.) better looking version, you can download the pk4 attached to this post and plonk it in your tdm root folder. Every mission that starts with the tdm logo then starts with the better looking one. Try for example mission COS1 Pearls and Swine.
      tdm_logo_video.pk4
      · 2 replies
    • JackFarmer

      Kill the bots! (see the "Who is online" bar)
      · 3 replies
    • STiFU

      I finished DOOM - The Dark Ages the other day. It is a decent shooter, but not as great as its predecessors, especially because of the soundtrack.
      · 5 replies
    • JackFarmer

      What do you know about a 40 degree day?
      @demagogue
      · 4 replies
×
×
  • Create New...