Jump to content

Recommended Posts

I have developed a python library to compile vs and ps file to ksh shader file, or convert it back.

PyPI: https://pypi.org/project/pyksh/

Github: https://github.com/lw-0x4eb1a/PyKsh/

It might by helpful for shader developing, especially on MacOS or Linux platforms (ShaderCompiler.exe not work)

 

Examples:

# parsing a ksh shader
from pyksh import Shader

s = Shader.from_file("shaders/anim.ksh")
# tell me vs file name and its source code
print(f"{s.vs_name}\n{s.vs_content}\n")
# tell me ps file name and its source code
print(f"{s.ps_name}\n{s.ps_content}\n")

---------------------

# compiling shader

from pyksh import Shader

s = Shader(
  vs_content = open("anim.vs").read(), # set vs shader source code
  ps_content = open("anim.ps").read(), # set ps shader source code
)

with open("anim.ksh", "wb") as f:
  f.write(s.dumps())

----------------------

compile via cli:

 python -m pyksh anim.vs anim.ps -o anim.ksh

  • Like 1
  • Health 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...