Example game/Testbed for the libpp framework.

example.ppsl 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Input:
  2. shader {
  3. //You can write multiple shaders with multiple versions. The engine should pick itself the highest supported on your platform.
  4. //This will parse into #version 130
  5. version 130;
  6. //Name of the shader.
  7. name color_shader;
  8. //Attributes contains attributes and unforms that needs to be present in the shaders, if multiple shaders has the same names for uniforms they'll be combined.
  9. attributes {
  10. //Select vertex selects only vertex shaders.
  11. select vertex {
  12. in vec2 in_Position;
  13. in vec2 in_Color;
  14. out vec3 ex_Color;
  15. }
  16. //Select fragment selects only fragment shaders.
  17. select fragment {
  18. in vec3 ex_Color;
  19. out vec4 gl_FragColor;
  20. }
  21. //Select total selects ALL shader types.
  22. select total {
  23. uniform float time;
  24. }
  25. }
  26. vertex {
  27. //Always returns vec4
  28. //technique main is always added to the generated main.
  29. //Additional techniques can be turned on and off by setting them in-engine.
  30. technique main {
  31. ex_Color = in_Color;
  32. return vec4(in_Position, 0.0, 1.0);
  33. }
  34. }
  35. fragment {
  36. //Pre-attribute is added pre-attribute.
  37. preattrib glsl {
  38. precision highp float;
  39. }
  40. //Always return vec4
  41. //technique main is always added to the generated main.
  42. //Additional techniques can be turned on and off by setting them in-engine.
  43. technique main {
  44. return OtherFunction(ex_Color.xy);
  45. }
  46. //GLSL code.
  47. glsl {
  48. vec3 OtherFunction(vec2 input) {
  49. return vec3(input, 1.0);
  50. }
  51. }
  52. }
  53. }
  54. shader {
  55. //Version total is code that works on all GLSL versions.
  56. version total;
  57. name color_shader;
  58. }
  59. OUTPUT:
  60. vertex:
  61. #version 130
  62. in vec2 in_Position;
  63. in vec3 in_Color;
  64. out vec3 ex_Color;
  65. INSERT_MAIN
  66. vec4 color_shader_technique() {
  67. ex_Color = in_Color;
  68. return vec4(in_Position, 0.0, 1.0);
  69. }
  70. fragment:
  71. #version 130
  72. precision highp float;
  73. in vec3 ex_Color;
  74. out vec4 gl_FragColor;
  75. INSERT_MAIN
  76. vec4 color_shader_technique() {
  77. return OtherFunction(ex_Color.xy);
  78. }
  79. vec3 color_shader_OtherFunction(vec2 input) {
  80. return vec3(input, 1.0);
  81. }