organizing shaders and effects question

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by  Joe Davis 4 years, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31093

    blamejane
    Member

    I’ll try to keep this simple: Let’s say I have 25 textures. Of these 25 textures 1 requires an environment map effect, 1 requires an alpha test, and 3 require bump map effects. The remaining 20 textures only need a default vertex and fragment shader. So, how do I structure my effect file with respect to the 20 default shader textures?

    Here is what I think effect.pfx file should have:

    1 environment effect
    1 alpha effect
    3 bump effects (sharing the same vert/frag shader)

    vertEnvironmentShader
    fragEnvironmentShader

    vertAlphaShader
    fragAlphaShader

    vertBumpShader
    fragBumpShader

    Am I correct on this so far?

    I’m not quite sure what to do about my default texture vert/fragment shaders at this point. I’m assuming that to define them in the pfx file, I would have to create an effect name for every texture that will be using them. For instance:

    defaultFloor (uses floor.pvr)
    defaultWall (uses wall.pvr)
    defaultShelf (…)
    defaultBox (…)

    What I’d rather do is load default vert and frag shaders from .vsh and .fsh files

    Is this doable? Basically I’d be adding the shaders needed for this app from pfx and .vsh/.fsh file types. If it’s not possible to do this, would it possible to define a defaultEffect which allows me to use any texture I need for the particular mesh being drawn?

    Thanks for the help.

    Valerie

    #36466

    Joe Davis
    Member

    In PFX, an EFFECT block is a material that can be applied to one or more objects in your scene. Because of this, it is best to create an EFFECT block for every material definition (i.e. texture and shader block combination).

    It may be possible to hack around and create a ‘default’ effect but you would have to manually bind textures instead of letting PFX do it. A better approach could be automating the EFFECT block creation for materials where only the bound texture changes.

    Thanks,
    Joe

    #36467

    blamejane
    Member

    Joe, thanks for your support. I like the idea of automating this process, and had not thought of that. Two questions if you don’t mind…

    1. Do you mean programatically create the Effect block during application load time, or via some sort of script?

    2. The is very interesting, can you tell me what creating the EFFECT block for each material/texture combination gains me? That is, is it for gpu/cpu/app efficiency?

    Sorry for the newbie questions.

    Valerie

    #36468

    Joe Davis
    Member

    1. Do you mean programatically create the Effect block during application load time, or via some sort of script?

    If you can, I’d suggest doing this offline. There shouldn’t be any reason to change the EFFECT blocks at run-time. It’s down to personal preference whether this should be done programatically or via a script.

    2. The is very interesting, can you tell me what creating the EFFECT block for each material/texture combination gains me? That is, is it for gpu/cpu/app efficiency?

    The benefit is simply that PFX was designed with material definitions in mind. If you attempt to repeatedly use a single EFFECT block with different textures, you will have to manually bind the textures instead of letting the PFX handling the code do this for you.

    No problem 🙂

    Joe

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.