Announcement

Collapse
No announcement yet.

Custom shaders for mesh rendering?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom shaders for mesh rendering?

    Hello,

    Obligatory - UE4 newbie here - So pardon me if I do not know things.

    I am looking at writing custom shaders to load (static) meshes in the scene (Basically load index buffer and vertex data in). Similar to gltf files.

    As I am doing my research, I understand that there are Global Shaders (mostly 1 per scenes and used for things like post process etc) and Material Shaders (Which can have applied to various objects in the scenes) - So I guess I should be looking more in to writing Materials shaders. (vertex and pixel shaders here)

    So I read the following tutorials/links I could find :
    I have some questions :
    1. Should I be implementing it as a plugin or local module? I assume in UE4 plugins systems there is not much of a difference(?)
    2. To start off with I am looking to load a simple triangle or cube 3d model into the scene with my custom shaders - I found this blog post (https://rcaloca.blogspot.com/2018/01...o-ue4-v20.html) but I havnt manged to get far ahead. Does any one know of any resource /sample/tutorial doing the same? It is a pretty basic use case so I guess there should be some tutorials but I havnt any yet.
    3. I found this https://github.com/sp0lsh/UE4ShaderPluginDemo/ - But I am still looking through it to understand and extent it to load a simple model . Any pointers would be appreciated.

    Do I understand it correct (on a broader level) or I am missing something here?

    Thanks!

    #2
    Hey amitahire thanks for sharing your thoughts.

    As far as I understood you, there are two parts to your questions:
    1. Loading and handling custom mesh data.
    2. Developing, including and using custom shader code.

    Considerations on 1.:
    I would recommend taking a look at the loading code for GLTF. You can find it implemented as an engine plugin under Engine/Plugins/Editor/GLTFImporter. There you see how Epic has structured its abstraction layer for loading 3d model data so it can be used with Unreal Engine. This part of the documentation might also be relevent for you https://docs.unrealengine.com/en-US/...ine/index.html

    Considerations on 2.:
    We found that in most situations, putting our shaders in specific plugins has a lot of benefits, given that the plugin has an isolated set of features. Local modules come in handy, if you have strong dependencies to other parts of your local appliaction, yet want to have logical seperation, with the added benefit of faster turn-around/compile times (due to the fact that changes in the module only triggers a recompile of the module itself most of the time). We started a series of blog posts describing our setup.

    Hope this helps you navigate your problem.
    Company Website
    Marketplace Seller Page

    Comment


      #3
      Hey amitahire! I'm a bit new to UE4 rendering as well.

      I do think you have the approach a bit wrong - shaders are primarily used for operations on the GPU after you have already loaded your data. If you're loading a mesh from a file that should be done all on the CPU side. In that case, the GLTFImporter plugin mentioned by blurryroots definitely seems like a good place to start.

      If you're still interested in using global shaders for another purpose, I'd take a look at https://github.com/Temaran/UE4ShaderPluginDemo . I've personally found it very helpful, and this version of the repository has been updated to work with some of the changes added in UE 4.22+.

      Comment

      Working...
      X