Upgrade Guide: Effect from v3.4.x to v3.5.0

Macro tags and functional macros

The effect syntax for Macro Tags and Functional Macros have been upgraded to avoid the occupation of standard glsl define, old effects in project will be upgrade automatically, but if you are using external effects without meta or writing a new one, you have to pay attention.

  • New syntax for Macro Tag: #pragma define-meta
  • New syntax for Funtional Macro: #pragma define

You can refer to Effect Syntax - macro-tags for detailed information.

Model level shadow bias

In v3.5, we supported individual shadow bias configuration for models, this allows detailed control of shadow effect on simple or complex surfaces. If you have any customized effect, you may need to upgrade them for shadow bias configuration to take effect.

Note: If shadow map of lights are disabled, or if CC_TRANSFER_SHADOW(pos) is not invoked in your vertex shader, then you won’t need to upgrade it.

Upgrade instructions

There are four elements to add to your effect file, they are listed below:

  1. Output varying define in the vertex shader

    1. #if CC_RECEIVE_SHADOW
    2. out mediump vec2 v_shadowBias;
    3. #endif
  2. Calculation of shadow bias in the vertex shader

    1. #if CC_RECEIVE_SHADOW
    2. v_shadowBias = CCGetShadowBias();
    3. #endif
  3. Input varying define in the fragment shader

    1. #if CC_RECEIVE_SHADOW
    2. in mediump vec2 v_shadowBias;
    3. #endif
  4. Shadow bias assignment in the fragment shader

    1. #if CC_RECEIVE_SHADOW
    2. s.shadowBias = v_shadowBias;
    3. #endif

Example (code snippets)

  1. // Vertex shader
  2. CCProgram xxx-vs %{
  3. // Header file area
  4. #include <cc-xxx>
  5. ...
  6. #include <cc-xxxx>
  7. // Vs output area
  8. out vec3 v_xxx;
  9. ...
  10. #if CC_RECEIVE_SHADOW
  11. out mediump vec2 v_shadowBias;
  12. #endif
  13. ...
  14. out vec3 v_xxxx;
  15. // Vs execution area
  16. void main () {
  17. xxx;
  18. ...
  19. #if CC_RECEIVE_SHADOW
  20. v_shadowBias = CCGetShadowBias();
  21. #endif
  22. ...
  23. xxxx;
  24. }
  25. }%
  26. // Pixel shader
  27. CCProgram xxx-fs %{
  28. // Header file area
  29. #include <cc-xxx>
  30. ...
  31. #include <cc-xxxx>
  32. // Vs output area
  33. in vec3 v_xxx;
  34. ...
  35. #if CC_RECEIVE_SHADOW
  36. in mediump vec2 v_shadowBias;
  37. #endif
  38. ...
  39. in vec3 v_xxxx;
  40. // Ps execution area
  41. void surf (out StandardSurface s) {
  42. xxx;
  43. ...
  44. #if CC_RECEIVE_SHADOW
  45. s.shadowBias = v_shadowBias;
  46. #endif
  47. ...
  48. xxxx;
  49. }
  50. }%