Jump to content
  • Advertisement
Sign in to follow this  
miminawewe

OpenGL Shading language query

This topic is 4051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I would like to use OpenGL shading language, I have read the reference document and other tutorials. It seems to me that the shader source code needs to be written and saved in a file as text, then it will be loaded by the game for use. Here are my questions: 1. Is it possible to hide this text and how do the big studios do it(i.e. which tools)? 2. If the only way is to write the shader as text and load it, does the load time of the game become slow? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
No, you can pass your shader (to the createshader function) as a precompiled resource as well. And maybe optimize the assembler code by hand to improve performance...

But i don't know how the game studios do it.

Share this post


Link to post
Share on other sites
Quote:
Original post by miminawewe
1. Is it possible to hide this text and how do the big studios do it(i.e. which tools)?

The question is why do you want to hide it? IMHO you really don't care if people play about with your shaders (and they're not exactly super secret either - they're basically worthless without the associated state setup and exe code.

Incidentally, Doom3 (and probably other iD games) just distribute the shaders as plain text. Thats one of the reasons why people have been able to hack in extra features like parallax mapping.

Share this post


Link to post
Share on other sites
I just wanted to know so that if I distribute my shaders in my games as text it won't seems strange, and may be allow someone to do some sort of bad hacking. If distributing as text is perfectly normal then that's OK. Is there still a way for GLSL code to be distributed as a precompiled resource? I've done research and didn't come across anything like that.
Thanks.

Share this post


Link to post
Share on other sites
It depends on what you mean by precompiled resource.
Do you mean compile the text to make a binary that you just sent to GL? That's not possible. We've been discussing this.

If you mean put the shader text it in the resource of your exe, then sure, you can do that. Use whatever WinAPI is available to get the shader text then send it to GL.

The shader text just needs to be an a array of char.

Share this post


Link to post
Share on other sites
You can't precompile your shader which is why they have to be fed to the create shader functions as text. That's because they create shader call is actually compiling your shader "program" into the instructions used for your card. ATi and nVidia use different instruction sets/implementations even cards of different generations from the same company use differing instruction sets.

If you pre-compiled your shader programs (they really are programs, shader is just a term used to differentiate them for the common usage case) then you'd only be able to support the currently existing platforms and future compatibility would be lost.

Now back to how we distribute our shaders. We zip them up. Ok so we call them something other than zips and we have optional encryption but that's about it. It's a trivial file format to hack and even then we only do it to appease publishers checklists. As someone already pointed out it's quite common to distribute them in plain text. So don't worry about it :)

Andy

Share this post


Link to post
Share on other sites
Thanks!
I think I can distribute as plain text or use resources (I've read a bit on that from the Win32 Developers Reference). In cases where I feel I don't want people to see the shader code I can encrypt it and save the encrypted file then the game will decrypt the file during loading (I've checked out encyption/decryption in Win32 Developers Reference).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!