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?
4\$\begingroup\$ Hardcoding the shader won't stop people from modifying them. \$\endgroup\$– Colonel Thirty TwoJan 4, 2016 at 18:03
\$\begingroup\$ It will be much less intuitive than having the shader as a text file in the game folder though \$\endgroup\$– McLovinJan 4, 2016 at 18:04
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:
- 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.
- 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.
- 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.