Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


HLSL DirectX Rendering technique


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 LudoDesign   Members   -  Reputation: 100

Like
0Likes
Like

Posted 31 December 2011 - 04:55 AM

Hello everyone !

I am working on an independent game project for months and I am almost done with "technical part" of coding (terrain engine, lighting technique, animations) that will be use as construction set for the game.

I am using VB.net, DirectX 9 Managed and HLSL. I have a question regarding the global rendering technique. For now I am only rendering the terrain, water, skybox and sun of an outdoor scene. Soon I will add more meshes. My current rendering program is running like that and use only 1 HLSL effect file including 1 single technique and 4 passes (one for each item of the scene, terrain, water, skybox and sun) :
  • Device set appropriate render target
  • Clear Device
  • Device Begin scene
    • Update Effect file parameters
    • Effect Begin
      • For each pass in the effect file display the corresponding meshes: Pass 1: Terrain, Pass2: Water, Pass3: Skybox, Pass4: Sun
    • Effect End
  • Device End scene
  • etc...
Is it suppose to work this way ? Or is it more like each different material is isolated in an effect file with one or several techniques and you render the loop for each corresponding mesh like :
  • Effect 1 Begin / Display Terrain / Effect 1 End
  • Effect 2 Begin / Display Water / Effect 2 End
  • etc
I believe that it could be heavier for the program to run this way because of common parameters between effect files and the memory load to change of effect file instead of 1 "master" effect file, but I am not sure.Posted Image

Thank you for your thoughts ! It will be really helpful if someone as the answer to that. Posted Image

Sponsor:

#2 MJP   Moderators   -  Reputation: 11597

Like
0Likes
Like

Posted 31 December 2011 - 06:25 PM

The way that "passes" are meant to be used is for rendering multiple passes of the same mesh. So for instance if you had one pass that rendered depth, one that rendered normals, and one that rendered color. However it's all purely organizational, so you can set things up whatever way is convenient for your particular project. Typically people will usually have each Effect instance be a material for a particular mesh, and have one instance per mesh in the scene. To facilitate this you can clone effects. Cloned instances will share the same shaders so you won't needlessly load a shader multiple times, but will have a different set of effect parameters (constants, textures, etc.) for each instance. That way you can just set up the parameters once when you load the mesh, and not have to constantly set them whenever you render it.

#3 LudoDesign   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 January 2012 - 08:27 AM

Hi MJP !

Thank you for your answer. So, i understand that I can share parameters between effects through an effect pool and that passes are meant for a common object (like layers of paint on a wall, layers change but it is still the same wall).

I have additional questions:

- is it cheaper in terms of memory to render all your objects using a single "huge" effect file with different technique (one for each material) or separated effect file even they could have only one technique and one pass/technique ?

- is there a way to optimize the memory load that occure due to the change of technique or the change of effect file because I can read in many forum topics that Begin/End instructions of techniques are quiet memory consuming ?

many thanks if someone has a clue about these topics Posted Image

#4 Gavin Williams   Members   -  Reputation: 712

Like
0Likes
Like

Posted 02 January 2012 - 11:41 AM

I don't think memory is an issue when working with effects, they are very simple programs. You can have a lot of effects no worries, afaik. Your texture and model buffers will consume memory.

#5 LudoDesign   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 January 2012 - 01:52 PM

Thank you for your answer. Ok for the memory.

I think I was not very clear. I just think that it may be causing some FPS drop adding many Begin/End Effect process at every frame instead of a unique Effect file (or in my case several passes in a single technique and a single effect file). The same problem that can occur by adding many render-to-texture process (for rendering the water for instance) : a huge loss of FPS.

Anyway I will try split my effect file in several ones. It is just to be sure because it will be quiet time consuming.




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