Jump to content
  • Advertisement
Sign in to follow this  
McZ

create a render path

This topic is 4976 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

well.. I have been fighting with this but I still can't figure out a good way that I like.. I liked the idea that was brought up in the Material/Shader thread but I don't like the thing that you have to write the same stuff in several places, lets say I have one shader that turn on lights and set the color and another that turn on lights and set a texture and so on... well just in thoose two shaders I have written the lighting part twice and alot more code to keep track of when debuging. I got the bright idea of split each shader into parts of a whole shader, so that lighting become one shader coloring another and texturing a third and transparency a fourth shader, so then my engine dynamicly choose the shaders it needs for that particular mesh. I created the shaders so that if I write a new shader that handles both lighting and texturing that one will be choosen before the other one if the mesh is lit and textured at once even if they have the same priority.. the problem I have is how I can implement shadow maps in my engine, I understand how shadow mapping works but I can't figure out where to start. how can I make sure that it will be the Shadow shader that decides how the render passes are created? for exampel a single lit cube with one texture only need one pass if it is rendered without shadows, but if it is shadowed engine will need one depthmap pass (this isn't to hard) but then it will need to split the one pass into two passes one for ambient lighting and one for the rest of the light with blending on and depthmap test on, if I don't remember wrong it could be done in one pass with a fragment shader but what if I don't have support for it.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by McZ
well.. I have been fighting with this but I still can't figure out a good way that I like.. I liked the idea that was brought up in the Material/Shader thread but I don't like the thing that you have to write the same stuff in several places, lets say I have one shader that turn on lights and set the color and another that turn on lights and set a texture and so on... well just in thoose two shaders I have written the lighting part twice and alot more code to keep track of when debuging.

Thats where the shader tools interface becomes useful, such as
tools->SetLights(LIGHTS_CLOSEST, 3);

Quote:

I got the bright idea of split each shader into parts of a whole shader, so that lighting become one shader coloring another and texturing a third and transparency a fourth shader, so then my engine dynamicly choose the shaders it needs for that particular mesh.

seems kind of inefficient to have a shader just do glEnable(GL_BLEND); or glColor3f(r, g, b);

Especially if you have a mesh go through 4 shaders just to set up the renderstate before being rendered.

Do you actually need this much abstraction

Quote:

I created the shaders so that if I write a new shader that handles both lighting and texturing that one will be choosen before the other one if the mesh is lit and textured at once even if they have the same priority..


1 shader to do it sounds better then going through many to set one renderstate.

Quote:

the problem I have is how I can implement shadow maps in my engine, I understand how shadow mapping works but I can't figure out where to start. how can I make sure that it will be the Shadow shader that decides how the render passes are created?


set the meshes effectId to the shadowed effect and either have the shadow shader do some rendering (also bouncing to others) or have it act as a proxy and just set up the bounce chain to render the mesh.

Quote:

for exampel a single lit cube with one texture only need one pass if it is rendered without shadows, but if it is shadowed engine will need one depthmap pass (this isn't to hard) but then it will need to split the one pass into two passes one for ambient lighting and one for the rest of the light with blending on and depthmap test on, if I don't remember wrong it could be done in one pass with a fragment shader but what if I don't have support for it.


I haven't implemented shadow maps yet so i dont know if you can do it in one pass without a fragment program.

How exactly are you linking the shaders together, from the original thread it was through an EffectId (so the frontend didn't care how the backend rendered it, just as close as possible).

You could implement the two passes over a forwarding shader, have a shadowmap shader for pass1 and pass2 and then just forward/bounce from one to the other for the second pass.

HTH

Share this post


Link to post
Share on other sites
Quote:

Thats where the shader tools interface becomes useful, such as
tools->SetLights(LIGHTS_CLOSEST, 3);


I find that breaking the shader choosing of my system, maybe I want to use different ways of turning on lighting, depending on user settings and hardware capabilities.

Quote:

seems kind of inefficient to have a shader just do glEnable(GL_BLEND); or glColor3f(r, g, b);

Especially if you have a mesh go through 4 shaders just to set up the renderstate before being rendered.

Do you actually need this much abstraction


the transparency shader handles everything that has anything with transparency to do (except set the value of the alpha channel yet)

if the shader is already active it will not re-enable renderstates already active for exampel glEnable(GL_BLEND); this will be called once upon activating the shader and not turned of until the shader isn't needed anymore.. two meshes that are transparent after each other will make only one call to glEnable(GL_BLEND); even if one is textured and the other not, but if I use 2 different shaders that do the whole thing the first shader calls a glDisable(GL_BLEND) when disabled and the other one will do a call to glEnable again if there is no checking if it is already enabled/disabled before doing it..

Quote:

1 shader to do it sounds better then going through many to set one renderstate.


I know it will be alot of iterating through shaders for each mesh, but still the engine will choose the shader that covers most of each part of the material, for exampel if I write a shader that do both lighting and texturing that one will be choosen before the two that does the same but are split into two shaders (if they don't have higher priority)

Quote:

set the meshes effectId to the shadowed effect and either have the shadow shader do some rendering (also bouncing to others) or have it act as a proxy and just set up the bounce chain to render the mesh.


I have been thinking of having one shader that do the shadowing, and it will bounce the lighting/texturing stuff to the other shaders so they do that part in the passes that the ShadowShader decide for them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!