Developers Manual > Cocos2d-x > Advanced Features > Third Party SDK Integration > WP8 SDK Integration > How to update wp8 shader

How to Update WP8/WinRT Shaders

Since cocos2d-x uses ANGLE backend for rendering on WP8 and WinRT, we need to precompile all shaders before the App is started up.

At present a cocos2d shader compiler tool is provided to generate all cached shaders which are delivered with engine. Those include all the common shaders defined in the program cache implementation. If you are adding a new shader into them or modifying a existing shader. You have to update the precompiled shader data using the tool.

Below is a simple instruction for that:

  1. Open the solution file Cocos2dShaderCompiler.sln at $(cocos-root)/build/winrt/Cocos2dShaderCompiler.
  2. Build and run. (Note that it is only supported by Visual Studio 2013)
  3. Click the compile button.
  4. In the dialog box, select cocos\platform\wp8\shaders\precompiledshaders.h (or the WinRT version regarding what platform you are using).
  5. Now all the cached programs are precompiled.

For those who are trying to adding a new custom shader, the steps might be kind of inconvenience.
You need to use another tool provided by ANGLE

  1. Download the project WinRT shader compiler, build and run.
  2. Use winrtcompiler.exe to generate the precompiled data, check the README file for more detailed usages.
  3. Copy the generated data to the corresponding precompiledshaders.h file, also update its SHA1 key and the total program number.
  4. Now cocos2d-x will find the precompiled shader data by the key.

Actually this is just a simple work around. We are developing a new general tool which will handle all those stuff in a proper way. It may be coming in this late summer.

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.