Custom shaders?


#1

May be a silly question to ask, but if i want to write my own object shaders does it depend on dx11 or opengl backend ?? I mean do i have to write an hlsl or a glsl shader ?


#2

Custom shader are written in glsl and then it is trans-compiled to platform’s own shading language for example for:
Mac/IOS -> MSL,
Windows-> Hlsl/Glsl (DX/OpenGl, depend on api you choose),
Linux -> Glsl/SPIR-V (OpenGl/Vulkan, depend on api you choose)
So, you just have to write shader in glsl and let armory/kha handle platform’s backend.

I did do here:
Shader in pure iron: Physically Based Rendering(PBR) In Iron. (Repo link)
Custom shader in armory: Physically Based Rendering(PBR) In Iron (Repo link)


#3

Ok, that was my understanding of how armory was working but i was not sure. Thanks for clarifying.


#4

I come back to you, do we have access to geometry shader too ?


#5

Yep, we can do whatever kha can do, you can access and use geometry shader too but i haven’t used geometry shader.


#6

I guess i have to investigate what kha can do :slight_smile:


#7

Geometry shaders currently only work when targeting GLSL, HLSL support is unfinished. It will never work on Metal though because that simply doesn’t support geometry shaders (which tells you a lot about the general state of geometry shaders which are frowned upon by many developers because of their performance problems (see for example http://www.joshbarczak.com/blog/?p=667)).


#8

Ok, great! thanks for clarify this …