-1
\$\begingroup\$

I obviously don't want the client to be able to view/modify my glsl code. Does this leave me with only one option, and that's to hardcode it in my cpp files? How do you deal with this issue?

\$\endgroup\$
2
  • 4
    \$\begingroup\$ Hardcoding the shader won't stop people from modifying them. \$\endgroup\$ Jan 4 '16 at 18:03
  • \$\begingroup\$ It will be much less intuitive than having the shader as a text file in the game folder though \$\endgroup\$
    – Pilpel
    Jan 4 '16 at 18:04
1
\$\begingroup\$

If someone really wants to edit or see your shader code, that person will find a way... With that out of the way:

There are several options to somewhat prevent curious eyes:

  1. You can save the files with names and extensions different from what usually is done with shaders (for example prog001.dat, shining.prog, etc). That will make some people think it is something better left untouched.
  2. You can save all your shaders in a custom container with some random magic numbers at the beginning so that all of them reside on a single file, you then implement a lookup and on-demand loading functionality.
  3. You can save everything on a zip or rar file, rename it to have a different extension and then open that on your code and do something similar as #2.

There may be other more creative ways to do this, the point is you just need to think outside the box and keep in mind that this is not meant to keep the code completely safe. Look in the files of any AAA game and you will probably find the shader code in plain text somewhere around there.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.