Jump to content

  • Log In with Google      Sign In   
  • Create Account


Full Model Shader


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
10 replies to this topic

#1 riuthamus   Moderators   -  Reputation: 4838

Like
0Likes
Like

Posted 05 June 2014 - 01:56 PM

How would somebody go about creating a shader that would effect the full model ( without the need of a texture ). For example, say I wanted to create a highlight shader on a model for a bad enemy, or highlight a model when the mouse is over it? How would people normally go about doing this?



Sponsor:

#2 Shane C   Crossbones+   -  Reputation: 1185

Like
0Likes
Like

Posted 05 June 2014 - 02:09 PM

That's probably one of the easier shaders possible. Unfortunately, I can't write it for you since I'm not a shader writer. But I know some stuff about shaders.

 

Anyway, do you have a graphics programmer you can ask? Or better yet, do a google search for such a shader?


Edited by Shane C, 05 June 2014 - 02:10 PM.


#3 riuthamus   Moderators   -  Reputation: 4838

Like
0Likes
Like

Posted 05 June 2014 - 02:13 PM

Shane, I have a graphics programmer who doesnt know how... hence asking. I dont know what to "google" search since I am not a programmer. Any tutorials you may be able to link would be ideal and very helpful.


Edited by riuthamus, 05 June 2014 - 02:13 PM.


#4 Shane C   Crossbones+   -  Reputation: 1185

Like
0Likes
Like

Posted 05 June 2014 - 02:22 PM

Shane, I have a graphics programmer who doesnt know how... hence asking. I dont know what to "google" search since I am not a programmer. Any tutorials you may be able to link would be ideal and very helpful.

 

Ask the graphics programmer if they can set the RGB to 0.5, 0.5, 0.5.



#5 HappyCoder   Members   -  Reputation: 2565

Like
1Likes
Like

Posted 05 June 2014 - 02:53 PM

Are you using an existing game engine?
If you are using your own game engine, are you using OpenGL or DirectX?

#6 riuthamus   Moderators   -  Reputation: 4838

Like
0Likes
Like

Posted 05 June 2014 - 03:01 PM

All great questions:

 

1) We are using a 100% homebrew engine

2) We are using DirectX 11.1 ( so fresh so new )



#7 SeanMiddleditch   Members   -  Reputation: 5117

Like
3Likes
Like

Posted 05 June 2014 - 03:24 PM

What precisely are you stuck on? The question as posed is 100% trivial graphics API 101 kind of stuff, so I'm assuming there's some actually complex thing you're trying to do you should be asking about instead. You might have better luck having your graphics programmer post and respond to questions instead; I've never seen much success with having someone act as the middleman between two technical parties in an engineering discussion.

Regarding your question as posted:

Writing a shader that doesn't use a texture is as easy as writing the shader, and then not using a texture inside of it. It takes work to _add_ texture usage to a shader. Simply don't do that work and you have a shader that doesn't use a texture. The usual "shaders 101" tutorials out there will walk you through writing a shader that doesn't use a texture before they show how to add a texture.

Applying a different shader to a model is as easy as binding that shader to the context and then drawing the model. In your rendering code, before drawing a model, check which shader should be applied, apply that shader, then just draw the model like you were.

Regarding what I think your real question might actually maybe possibly be:

The hard part is deciding what you want the shader to actually do. What kind of highlight do you want? Some effects require several non-trivial effect-specific passes over the scene in order to achieve, while simpler effects require very little extra work. Here are two articles on two ways to do this (there are many more):

http://www.rastertek.com/dx11tut46.html
http://www.codeproject.com/Articles/156323/Stencil-Buffer-Glows-Part

Edited by SeanMiddleditch, 05 June 2014 - 03:24 PM.


#8 riuthamus   Moderators   -  Reputation: 4838

Like
0Likes
Like

Posted 05 June 2014 - 03:51 PM


What precisely are you stuck on? The question as posed is 100% trivial graphics API 101 kind of stuff, so I'm assuming there's some actually complex thing you're trying to do you should be asking about instead. You might have better luck having your graphics programmer post and respond to questions instead; I've never seen much success with having someone act as the middleman between two technical parties in an engineering discussion.

 

If i could get him to post, i would. He seems to think "nobody will help" so I am forced to do the brunt work. I will go through the rest of your post and keep you posted, thanks!



#9 Aardvajk   Crossbones+   -  Reputation: 5951

Like
1Likes
Like

Posted 06 June 2014 - 01:34 AM

How would somebody go about creating a shader that would effect the full model ( without the need of a texture ). For example, say I wanted to create a highlight shader on a model for a bad enemy, or highlight a model when the mouse is over it? How would people normally go about doing this?

 

I'm a little confused by the question, perhaps you aren't being fed good info by your graphics guy here.

 

Assuming you have a shader for normally rendering the object, and a different shader for rendering it highlighted, its a CPU-side decision as to which shader to use when you come to render the object - if the mouse is over the object, use shader B otherwise use shader A.

 

Not sure if that helps, I'm with Sean in suspecting the problem is more complex here.



#10 TheChubu   Crossbones+   -  Reputation: 4100

Like
3Likes
Like

Posted 06 June 2014 - 01:50 AM

Given the effects I've seen in RuinValor, I doubt switching shaders is his problem :D


"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

 

My journals: dustArtemis ECS framework and Making a Terrain Generator


#11 Ashaman73   Crossbones+   -  Reputation: 7123

Like
1Likes
Like

Posted 06 June 2014 - 03:24 AM

As always, it depends on your engine. Writing such a shader is not a problem, the issue is how to integrate it into your engine. Here is what I  have done in my engine to highlight objects (deferred engine):

 

1. ensure, that your engine is capable of rendering emissive pixels

2. extend the standard model pixelshader (which renders the color of your models to the color/material buffer):

- add a color parameter to the shader, so that you can choose an optional emissive color for each rendered model

- calculate the emissive color intensity by taking the normal into account (eg fresnel or just normal-z value)

- add color.rgb * color.a* normal_dependent_intensity to the emissive buffer

 

If you dont want to hightlight an object, just set the color to black or the alpha value to 0.






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