Jump to content

  • Log In with Google      Sign In   
  • Create Account

Shaders - Simple Q&A :)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Nexian   Members   -  Reputation: 118

Like
0Likes
Like

Posted 14 August 2012 - 06:07 PM

I can't find anything that answers this directly, but you can only have ONE shader on a game object, correct?

i.e. I cannot make two completely separate shaders and run both on the same object without it just rendering twice.

Assuming the above is true, how do most programmers create objects with multiple shader effects?

For example:

A Wall
- Bumpmap shader
- Rain shader (streaming water)
- Lighting shader (for any nearby lights (p.s. how does it pick the dynamic lights?))
- Projectile shader (bullets hitting the wall, etc)

Also, speaking of shaders. One effect that I can't quite see how to do is a targeting effect that covers multiple objects, similar to those found on AoE abilities in WoW or LoL. I can only guess it has to use the mouse position combined with the camera position and view along with the position and normal of the surface to draw a section of the defined "target" texture?

Sponsor:

#2 jefferytitan   Crossbones+   -  Reputation: 2242

Like
2Likes
Like

Posted 14 August 2012 - 06:51 PM

I am by no means an expert, but my understanding is as follows:
  • Sometimes one bumper shader is used that has lots of features, e.g. I am writing a shader that has relief mapping, splat maps and lighting.
  • Sometimes multi-pass shaders are used, although I'm not sure how much re-usability this offers.
  • Sometimes it's suitable to just overdraw effects, e.g. you draw your bullet mark decal over your bump-mapped wall.
  • If completely different types of shaders are involved, there may be no conflict, e.g. one is a vertex shader, one is a pixel shader, one is a full-screen post-processing effect.
But essentially shaders may interfere with each other in undesirable ways if you don't think it through. For example, underwater level with bullet damage. If you draw the bullet decals last, they won't be affected by the water effect, which would look weird. That's one reason why (in my opinion) getting a game looking AAA pretty is so hard.

#3 phil_t   Crossbones+   -  Reputation: 4092

Like
0Likes
Like

Posted 14 August 2012 - 11:28 PM

Assuming the above is true, how do most programmers create objects with multiple shader effects?


It completely depends on which effects you're talking about. Sometimes they would be (manually) combined in one shader, sometimes it would be done by drawing the same object again (with the current blend equation determining how the result is combined with what's currently on screen), sometimes it would be done by drawing separate objects on top.

For example:

A Wall
- Bumpmap shader
- Rain shader (streaming water)
- Lighting shader (for any nearby lights (p.s. how does it pick the dynamic lights?))
- Projectile shader (bullets hitting the wall, etc)


Typically, bumpmapping and lighting would be combined in one shader. If using deferred rendering, lighting is calculated separately, but as a post-process effect, not an effect specifically on the object.

Streaming water and projectile marks, it seems to me, would be separate things laid on top (although I've never looked into making a streaming water effect, so I'm not sure of the typical manner in which it's done).

It's a bit of an art determining how a particular effect should be implemented, so there isn't necessarily any hard and fast rule.

#4 dimitri.adamou   Members   -  Reputation: 329

Like
0Likes
Like

Posted 15 August 2012 - 05:11 AM

You can use multiple shaders via multiple-passes. (Meaning you can either use a Technique and re-iterate through all its passes, or you can manually iterate and change the effect with another pass)

#5 Nexian   Members   -  Reputation: 118

Like
0Likes
Like

Posted 15 August 2012 - 06:32 AM

Thanks all,

This has been good, direct feedback. Feels good to be a little less uncertain :P




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS