Q on Shaders

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Q on Shaders

      Shaders are one of the main parts of the resources, and I was wondering how can I prevent the end user from seeing them.

      Ok, so let me explain a little bit more.

      The game I've been creating has a couple of HLSL shaders(also GLSL shaders) which I've been compiling at run-time from their respective HLSL/GLSL files. Now the problem with this is that anybody can actually see my shaders' code by just going into the folder of my game.

      What can I do to prevent this? I was thinking hard coding them after I've thoroughly tested them, by this I mean copying the tested code into a stream I will create at run-time and compile the shaders from memory instead. But it seems a little too much. Although completely possible, I was wondering if there was a better way?
      Intel i7 3930k
      8GB Mushkin LP @ 2133 mhz
      GTX 680
      Asus Rampage IV Extreme
      Corsair 650w
    • You can encrypt all resource files and decode them on load. Your encryption mechanism can be as simple as simply offsetting each byte by a number or can be as complex as using some advanced encryption encoding algorithms. The complex the encryption the more processing time it needs to decode your data.

      In my engine i have a simple Virtual File System(VFS) with a built-in data filter system. It is very loosely based on the GCC code. My VFS can process a specified folder then the system goes through each file. For each file, it process them based on what data filter key I give them. A data filter key can be anything from compression to encryption or even both. The system then spits out a single file with all my resources compressed and encrypted inside that one single file.

      Read chapter 8 : Loading and caching data of the GCC book for a better understanding of these type of systems.
    • That sounds neat, I already read that chapter but the information was not specific enough. It only gives a general idea of what are the things you need to do but doesn't say how.

      Also, if you encrypt your files how can your shader compiler process this files?

      Thanks in advance.
      Intel i7 3930k
      8GB Mushkin LP @ 2133 mhz
      GTX 680
      Asus Rampage IV Extreme
      Corsair 650w
    • Another thing to add is that some shading languages allow for compilation into assembly, I am reasonably sure that GLSL does not which is why I don't know the specifics, but I think HLSL may be able to, this could allow you to package your shaders maybe even in your executable or in one big unreadable file.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz