effects.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. // This file was created by Filewrap 1.1
  2. // Little endian mode
  3. // DO NOT EDIT
  4. #include "../PVRTMemoryFileSystem.h"
  5. // using 32 bit to guarantee alignment.
  6. #ifndef A32BIT
  7. #define A32BIT static const unsigned int
  8. #endif
  9. // ******** Start: effects.pfx ********
  10. // File data
  11. static const char _effects_pfx[] =
  12. "[HEADER]\r\n"
  13. "\tVERSION\t\t01.00.00.00\r\n"
  14. "\tDESCRIPTION texture example\r\n"
  15. "\tCOPYRIGHT\tImg Tec\r\n"
  16. "[/HEADER]\r\n"
  17. "\r\n"
  18. "// Define the textures that we'll be using\r\n"
  19. "[TEXTURES] \r\n"
  20. "\tFILE Balloon \t Balloon.pvr\t\tLINEAR-LINEAR-LINEAR\r\n"
  21. "\tFILE Balloon_pvr Balloon_pvr.pvr\tLINEAR-LINEAR-LINEAR\r\n"
  22. "\tFILE Noise \t \t Noise.pvr\t\t\tLINEAR-LINEAR-LINEAR\r\n"
  23. "\tFILE Skybox \t Skybox.pvr\t\t\tLINEAR-LINEAR-LINEAR CLAMP-CLAMP\r\n"
  24. "\tFILE SkyboxMidnight SkyboxMidnight.pvr\tLINEAR-LINEAR-LINEAR CLAMP-CLAMP\r\n"
  25. "[/TEXTURES]\r\n"
  26. "\r\n"
  27. "//Effect 0//////////////////////////////////////////////////////////////////////\r\n"
  28. "//\r\n"
  29. "// This effect is used for the skybox. The inverse of the vertex positions for \r\n"
  30. "// the skybox are used as texture coordinates for accessing the skybox texture.\r\n"
  31. "//\r\n"
  32. "\r\n"
  33. "[VERTEXSHADER]\r\n"
  34. "\tNAME \t\tskybox_vert\r\n"
  35. "\r\n"
  36. "\t[GLSL_CODE]\r\n"
  37. "\t\tattribute highp vec3\tmyVertex;\r\n"
  38. "\t\tuniform mediump mat4\tmyMVPMatrix;\r\n"
  39. "\t\tvarying highp vec3 EyeDir;\r\n"
  40. "\r\n"
  41. "\t\tvoid main(void)\r\n"
  42. "\t\t{ \r\n"
  43. "\t\t\tEyeDir = -myVertex;\r\n"
  44. "\t\t\tgl_Position = myMVPMatrix * vec4(myVertex,1.0);\r\n"
  45. "\t\t}\r\n"
  46. "\t[/GLSL_CODE]\r\n"
  47. "[/VERTEXSHADER]\r\n"
  48. "\r\n"
  49. "[FRAGMENTSHADER] \r\n"
  50. "\tNAME \t\tskybox_frag\r\n"
  51. "\t\r\n"
  52. "\t[GLSL_CODE]\r\n"
  53. "\t\tvarying highp vec3 EyeDir;\r\n"
  54. "\t\tuniform samplerCube myCubeMap;\r\n"
  55. "\t\t\r\n"
  56. "\t\tvoid main (void)\r\n"
  57. "\t\t{\r\n"
  58. "\t\t gl_FragColor = textureCube(myCubeMap, EyeDir);\r\n"
  59. "\t\t}\r\n"
  60. "\t[/GLSL_CODE]\r\n"
  61. "[/FRAGMENTSHADER]\r\n"
  62. "\r\n"
  63. "[EFFECT] \r\n"
  64. "\tNAME \tskybox_effect\r\n"
  65. "\t\t\r\n"
  66. "\t// GLOBALS UNIFORMS\r\n"
  67. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  68. "\tUNIFORM\tmyCubeMap\t\t\tTEXTURE0\r\n"
  69. "\r\n"
  70. "\t// ATTRIBUTES\r\n"
  71. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  72. "\r\n"
  73. "\tVERTEXSHADER \tskybox_vert\r\n"
  74. "\tFRAGMENTSHADER \tskybox_frag\r\n"
  75. "\tTEXTURE 0 Skybox\r\n"
  76. "[/EFFECT]\r\n"
  77. "\r\n"
  78. "//Effect 1 /////////////////////////////////////////////////////////////////////\r\n"
  79. "//\r\n"
  80. "// This effect displays a textured balloon with some simple lighting.\r\n"
  81. "//\r\n"
  82. "\r\n"
  83. "[VERTEXSHADER]\r\n"
  84. "\tNAME \t\tballoon_vert1\r\n"
  85. "\r\n"
  86. "\t[GLSL_CODE]\r\n"
  87. "\t\tattribute highp vec3\tmyVertex;\r\n"
  88. "\t\tattribute mediump vec3\tmyNormal;\r\n"
  89. "\t\tattribute mediump vec2\tmyUV;\r\n"
  90. "\t\tuniform mediump mat4\tmyMVPMatrix;\r\n"
  91. "\t\tuniform mediump mat3\tmyModelViewIT;\r\n"
  92. "\t\tuniform mediump vec3\tmyLightDirection;\r\n"
  93. "\t\tuniform mediump float\tfAnim;\r\n"
  94. "\t\tvarying mediump float\tfDot;\r\n"
  95. "\t\tvarying lowp vec2\tfTexCoord;\r\n"
  96. "\t\t\r\n"
  97. "\t\tvoid main(void)\r\n"
  98. "\t\t{\r\n"
  99. "\t\t\tgl_Position = myMVPMatrix * vec4(myVertex,1);\r\n"
  100. "\t\t\tfTexCoord = myUV;\r\n"
  101. "\t\t\tmediump vec3 fTransNormal = myModelViewIT * myNormal;\r\n"
  102. "\t\t\tfDot = 0.1 * dot(fTransNormal, myLightDirection) + 0.9;\r\n"
  103. "\t\t}\r\n"
  104. "\t[/GLSL_CODE]\r\n"
  105. "[/VERTEXSHADER]\r\n"
  106. "\r\n"
  107. "[FRAGMENTSHADER] \r\n"
  108. "\tNAME \t\tballoon_frag1\r\n"
  109. "\r\n"
  110. "\t[GLSL_CODE]\r\n"
  111. "\t\tuniform \t\tsampler2D \tsampler2d;\r\n"
  112. "\t\tvarying mediump float\t\tfDot;\r\n"
  113. "\t\tvarying lowp vec2\t\tfTexCoord;\r\n"
  114. "\t\t\r\n"
  115. "\t\tvoid main (void)\r\n"
  116. "\t\t{\r\n"
  117. "\t\t gl_FragColor = texture2D(sampler2d,fTexCoord) * fDot;\r\n"
  118. "\t\t}\r\n"
  119. "\t[/GLSL_CODE]\r\n"
  120. "[/FRAGMENTSHADER]\r\n"
  121. "\r\n"
  122. "[EFFECT] \r\n"
  123. "\tNAME \tballoon_effect1\r\n"
  124. "\t\t\r\n"
  125. "\t// GLOBALS UNIFORMS\r\n"
  126. "\tUNIFORM myModelViewIT \t\tWORLDVIEWIT\r\n"
  127. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  128. "\tUNIFORM\tmyLightDirection\tLIGHTDIRECTION\r\n"
  129. "\tUNIFORM\tsampler2d\t\t\tTEXTURE0\r\n"
  130. "\r\n"
  131. "\t// ATTRIBUTES\r\n"
  132. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  133. "\tATTRIBUTE\tmyNormal\tNORMAL\r\n"
  134. "\tATTRIBUTE\tmyUV\t\tUV\r\n"
  135. "\r\n"
  136. "\tVERTEXSHADER \tballoon_vert1\r\n"
  137. "\tFRAGMENTSHADER \tballoon_frag1\r\n"
  138. "\tTEXTURE 0 Balloon_pvr\r\n"
  139. "[/EFFECT]\r\n"
  140. "\r\n"
  141. "//Effect 2 /////////////////////////////////////////////////////////////////////\r\n"
  142. "//\r\n"
  143. "// This effect creates a burning effect that burns the balloon from the basket \r\n"
  144. "// up. It does this by calculating whether a pixel is below at least one of \r\n"
  145. "// three thresholds (which rise over time). If it is not then the balloon \r\n"
  146. "// is textured and lit in the same way as effect 1 otherwise the burn effect is \r\n"
  147. "// applied according to the threshold it is below.\r\n"
  148. "//\r\n"
  149. "\r\n"
  150. "[VERTEXSHADER]\r\n"
  151. "\tNAME \t\tballoon_vert2\r\n"
  152. "\r\n"
  153. "\t[GLSL_CODE]\r\n"
  154. "\t\tattribute vec3\tmyVertex;\r\n"
  155. "\t\tattribute vec3\tmyNormal;\r\n"
  156. "\t\tattribute vec2\tmyUV;\r\n"
  157. "\t\t\r\n"
  158. "\t\tuniform mat4\tmyMVPMatrix;\r\n"
  159. "\t\tuniform mat3\tmyModelViewIT;\r\n"
  160. "\t\t\r\n"
  161. "\t\tuniform mediump vec3\tmyLightDirection;\r\n"
  162. "\t\tuniform highp float fAnim;\r\n"
  163. "\t\t\r\n"
  164. "\t\tvarying float\tfDiffuse;\r\n"
  165. "\t\tvarying lowp vec2 fTexCoord;\r\n"
  166. "\t\tvarying lowp vec2 fTexCoord2;\r\n"
  167. "\t\t\r\n"
  168. "\t\tvarying highp vec3 fPosition;\r\n"
  169. "\t\tvarying highp float fBurn;\r\n"
  170. "\t\t\r\n"
  171. "\t\tvoid main(void)\r\n"
  172. "\t\t{\r\n"
  173. "\t\t\tgl_Position = myMVPMatrix * vec4(myVertex,1);\r\n"
  174. "\t\t\t\r\n"
  175. "\t\t\tfDiffuse = 0.1 * dot(myModelViewIT * myNormal, myLightDirection) + 0.9;\r\n"
  176. "\t\t\t\r\n"
  177. "\t\t\tfPosition = myVertex * 0.05;\r\n"
  178. "\t\t\t\r\n"
  179. "\t\t\thighp float fOffset = fract(0.999 * fAnim) * 2.1;\r\n"
  180. "\t\t\tfBurn = fOffset - 0.53 * (fPosition.y + 0.2);\t\r\n"
  181. "\t\t fBurn = clamp(fBurn, 0.0, 1.0);\r\n"
  182. "\t\t \r\n"
  183. "\t\t fTexCoord = myUV;\r\n"
  184. "\t\t fTexCoord2 = vec2(fPosition.x + fPosition.z * fPosition.z, fPosition.y + 0.5 * fPosition.z + 0.5 * fPosition.x * fPosition.x);\r\n"
  185. "\t\t}\r\n"
  186. "\t[/GLSL_CODE]\r\n"
  187. "[/VERTEXSHADER]\r\n"
  188. "\r\n"
  189. "[FRAGMENTSHADER] \r\n"
  190. "\tNAME \t\tballoon_frag2\r\n"
  191. "\r\n"
  192. "\t[GLSL_CODE]\r\n"
  193. "\t\tvarying highp float\tfDiffuse;\r\n"
  194. "\t\tvarying lowp vec2\tfTexCoord;\r\n"
  195. "\t\tvarying lowp vec2 fTexCoord2;\r\n"
  196. "\r\n"
  197. "\t\tuniform sampler2D sampler2d;\r\n"
  198. "\t\tuniform sampler2D Noise;\r\n"
  199. "\t\t\r\n"
  200. "\t\tvarying highp float fBurn;\r\n"
  201. "\t\t\r\n"
  202. "\t\thighp vec3 reflect (void)\r\n"
  203. "\t\t{\t\r\n"
  204. "\t\t\treturn texture2D(sampler2d,fTexCoord).rgb * fDiffuse;\r\n"
  205. "\t\t}\r\n"
  206. "\t\t\r\n"
  207. "\t\tvoid main (void)\r\n"
  208. "\t\t{\r\n"
  209. "\t\t highp vec4 noisevec;\r\n"
  210. "\t\t highp vec3 color;\r\n"
  211. "\t\t highp float intensity;\r\n"
  212. "\t\t\r\n"
  213. "\t\t noisevec = texture2D(Noise, fTexCoord2);\r\n"
  214. "\t\t \r\n"
  215. "\t\t intensity = 0.6 * (noisevec.x + noisevec.y + noisevec.z + noisevec.w);\r\n"
  216. "\t\t intensity = abs(intensity - 1.0);\r\n"
  217. "\t\t intensity = clamp(intensity, 0.0, 1.0);\r\n"
  218. "\t\t\r\n"
  219. "\t\t if (intensity < fBurn)\r\n"
  220. "\t\t\t\tcolor = vec3(0.0);\r\n"
  221. "\t\t else if(intensity < 1.5 * fBurn)\r\n"
  222. "\t\t\t\tcolor = vec3(0.1);\r\n"
  223. "\t\t else if(intensity < 1.7 * fBurn)\r\n"
  224. "\t\t\t\tcolor = vec3(1.0, 10.0 * (-intensity + 1.7 * fBurn) ,0.0);\r\n"
  225. "\t\t else\r\n"
  226. "\t\t\t\tcolor = reflect();\r\n"
  227. "\t\t\r\n"
  228. "\t\t gl_FragColor = vec4(color, 1);\r\n"
  229. "\t\t}\r\n"
  230. "\t[/GLSL_CODE]\r\n"
  231. "[/FRAGMENTSHADER]\r\n"
  232. "\t\r\n"
  233. "[EFFECT] \r\n"
  234. "\tNAME \tballoon_effect2\r\n"
  235. "\t\t\r\n"
  236. "\t// GLOBALS UNIFORMS\r\n"
  237. "\tUNIFORM myModelViewIT \t\tWORLDVIEWIT\r\n"
  238. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  239. "\tUNIFORM\tmyLightDirection\tLIGHTDIRECTION\r\n"
  240. "\tUNIFORM\tsampler2d\t\t\tTEXTURE0\r\n"
  241. "\tUNIFORM\tNoise\t\t\t\tTEXTURE1\r\n"
  242. "\r\n"
  243. "\t// ATTRIBUTES\r\n"
  244. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  245. "\tATTRIBUTE\tmyNormal\tNORMAL\r\n"
  246. "\tATTRIBUTE\tmyUV\t\tUV\r\n"
  247. "\r\n"
  248. "\tVERTEXSHADER \tballoon_vert2\r\n"
  249. "\tFRAGMENTSHADER \tballoon_frag2\r\n"
  250. "\tTEXTURE 0 Balloon_pvr\r\n"
  251. "\tTEXTURE 1 Noise\r\n"
  252. "[/EFFECT]\r\n"
  253. "\r\n"
  254. "//Effect 3 /////////////////////////////////////////////////////////////////////\r\n"
  255. "//\r\n"
  256. "// Effect 3 is very similar to effect 1 in that it displays a textured \r\n"
  257. "// balloon with diffuse lighting. However, it applies two textures to the \r\n"
  258. "// balloon. The second texture is the skybox cube map which is applied using a \r\n"
  259. "// reflection vector as texture coordinates. This makes it look like the balloon \r\n"
  260. "// is reflecting the skybox.\r\n"
  261. "//\r\n"
  262. "\r\n"
  263. "[VERTEXSHADER]\r\n"
  264. "\tNAME \t\tballoon_vert3\r\n"
  265. "\r\n"
  266. "\t[GLSL_CODE]\r\n"
  267. "\t\tattribute vec3\tmyVertex;\r\n"
  268. "\t\tattribute vec3\tmyNormal;\r\n"
  269. "\t\tattribute vec2\tmyUV;\r\n"
  270. "\t\t\r\n"
  271. "\t\tuniform mat4\tmyMVPMatrix;\r\n"
  272. "\t\tuniform mat3\tmyModelViewIT;\r\n"
  273. "\t\tuniform mat4\tmyModelView;\r\n"
  274. "\t\tuniform mat3 \tmyViewIT;\r\n"
  275. "\t\t\r\n"
  276. "\t\tuniform mediump vec3\tmyLightDirection;\r\n"
  277. "\t\tvarying highp\tfloat\tfDiffuse;\r\n"
  278. "\t\tvarying lowp\tvec2\tfTexCoord;\r\n"
  279. "\r\n"
  280. "\t\tuniform mediump float myFrame;\r\n"
  281. "\t\tuniform mediump float fAnim;\r\n"
  282. "\t\tvarying lowp vec3 fReflectVec;\r\n"
  283. "\t\t\r\n"
  284. "\t\tvoid main(void)\r\n"
  285. "\t\t{\r\n"
  286. "\t\t\tmediump vec4 myVertex4 = vec4(myVertex, 1);\r\n"
  287. "\t\t\t\r\n"
  288. "\t\t\tgl_Position = myMVPMatrix * myVertex4;\r\n"
  289. "\t\t\tmediump vec3 fTransNormal = myModelViewIT * myNormal;\r\n"
  290. "\t\t\t\r\n"
  291. "\t\t\tfDiffuse = (0.05 * dot(fTransNormal, myLightDirection) + 0.95) * fAnim * 0.5;\r\n"
  292. "\t\t\t\r\n"
  293. "\t\t\tmediump vec3 EyeDir = vec3(0.0,-1.0,0.0) - vec3(myModelView * myVertex4);\t\r\n"
  294. "\t\t\tfReflectVec = myViewIT * reflect(EyeDir, normalize(fTransNormal) );\r\n"
  295. "\t\t\t\r\n"
  296. "\t\t\tfTexCoord\t= myUV.st;\r\n"
  297. "\t\t}\r\n"
  298. "\t[/GLSL_CODE]\r\n"
  299. "[/VERTEXSHADER]\r\n"
  300. "\r\n"
  301. "[FRAGMENTSHADER] \r\n"
  302. "\tNAME \t\tballoon_frag3\r\n"
  303. "\r\n"
  304. "\t[GLSL_CODE]\r\n"
  305. "\t\tvarying highp \tfloat\tfDiffuse;\r\n"
  306. "\t\tvarying lowp \tvec2\tfTexCoord;\r\n"
  307. "\t\tvarying lowp \tvec3 \tfReflectVec;\r\n"
  308. "\t\t\t\r\n"
  309. "\t\tuniform sampler2D \tsampler2d;\r\n"
  310. "\t\tuniform samplerCube myCubeMap;\r\n"
  311. "\t\t\r\n"
  312. "\t\tvoid main (void)\r\n"
  313. "\t\t{ \r\n"
  314. "\t\t\tgl_FragColor = textureCube(myCubeMap, fReflectVec) + texture2D(sampler2d, fTexCoord);\r\n"
  315. "\t\t\tgl_FragColor *= fDiffuse;\r\n"
  316. "\t\t}\r\n"
  317. "\t[/GLSL_CODE]\r\n"
  318. "[/FRAGMENTSHADER]\r\n"
  319. "\r\n"
  320. "[EFFECT] \r\n"
  321. "\tNAME \tballoon_effect3\r\n"
  322. "\t\t\r\n"
  323. "\t// GLOBALS UNIFORMS\r\n"
  324. "\tUNIFORM myModelViewIT \t\tWORLDVIEWIT\r\n"
  325. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  326. "\tUNIFORM myModelView\t\t\tWORLDVIEW\r\n"
  327. "\tUNIFORM myViewIT\t\t\tVIEWIT\r\n"
  328. "\tUNIFORM\tmyLightDirection\tLIGHTDIRECTION\r\n"
  329. "\tUNIFORM\tsampler2d\t\t\tTEXTURE0\r\n"
  330. "\tUNIFORM\tmyCubeMap\t\t\tTEXTURE1\r\n"
  331. "\r\n"
  332. "\t// ATTRIBUTES\r\n"
  333. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  334. "\tATTRIBUTE\tmyNormal\tNORMAL\r\n"
  335. "\tATTRIBUTE\tmyUV\t\tUV\r\n"
  336. "\r\n"
  337. "\tVERTEXSHADER \tballoon_vert3\r\n"
  338. "\tFRAGMENTSHADER \tballoon_frag3\r\n"
  339. "\tTEXTURE 0 Balloon\r\n"
  340. "\tTEXTURE 1 Skybox\r\n"
  341. "[/EFFECT]\r\n"
  342. "\r\n"
  343. "//Effect 4 /////////////////////////////////////////////////////////////////////\r\n"
  344. "//\r\n"
  345. "// This effect alters the transparency of the balloon based on an external \r\n"
  346. "// variable calculated in the app. The basket isn't affected as much as the \r\n"
  347. "// balloon as pixels over the height of 0.1 are given a lower alpha value.\r\n"
  348. "//\r\n"
  349. "\r\n"
  350. "[VERTEXSHADER]\r\n"
  351. "\tNAME \t\tballoon_vert4\r\n"
  352. "\r\n"
  353. "\t[GLSL_CODE]\r\n"
  354. "\t\tattribute vec3\tmyVertex;\r\n"
  355. "\t\tattribute vec3\tmyNormal;\r\n"
  356. "\t\tattribute vec2\tmyUV;\r\n"
  357. "\t\t\r\n"
  358. "\t\tuniform mat4\tmyMVPMatrix;\r\n"
  359. "\t\tuniform mat3\tmyModelViewIT;\r\n"
  360. "\t\tuniform mediump vec3\tmyLightDirection;\r\n"
  361. "\t\tuniform mediump float fAnim;\r\n"
  362. "\t\t\r\n"
  363. "\t\tvarying float\tfDiffuse;\r\n"
  364. "\t\tvarying lowp vec2\tfTexCoord;\r\n"
  365. "\r\n"
  366. "\t\tvarying mediump float fHeight;\r\n"
  367. "\t\tvarying mediump float fAlteredAnim;\r\n"
  368. "\t\t\r\n"
  369. "\t\tvoid main(void)\r\n"
  370. "\t\t{\r\n"
  371. "\t\t\tgl_Position = myMVPMatrix * vec4(myVertex, 1);\r\n"
  372. "\t\t\t\r\n"
  373. "\t\t\tmediump vec3 fTransNormal = myModelViewIT * myNormal;\r\n"
  374. "\t\t\tfDiffuse = (0.05 * dot(fTransNormal, myLightDirection) + 0.95) * 0.5;\r\n"
  375. "\t\t\r\n"
  376. "\t\t\tfTexCoord = myUV;\r\n"
  377. "\r\n"
  378. "\t\t\tfHeight = myVertex.y;\r\n"
  379. "\t\t\t\r\n"
  380. "\t\t\tfAlteredAnim = (1.0 - fAnim) + fAnim;\r\n"
  381. "\t\t}\r\n"
  382. "\t[/GLSL_CODE]\r\n"
  383. "[/VERTEXSHADER]\r\n"
  384. "\r\n"
  385. "[FRAGMENTSHADER] \r\n"
  386. "\tNAME \t\tballoon_frag4\r\n"
  387. "\r\n"
  388. "\t[GLSL_CODE]\r\n"
  389. "\t\tvarying highp \tfloat\tfDiffuse;\r\n"
  390. "\t\tvarying lowp \tvec2\tfTexCoord;\r\n"
  391. "\t\tvarying mediump float \tfHeight;\r\n"
  392. "\t\tvarying mediump float \tfAlteredAnim;\r\n"
  393. "\t\t\r\n"
  394. "\t\tuniform sampler2D sampler2d;\r\n"
  395. "\r\n"
  396. "\t\tuniform bool bBackFace;\r\n"
  397. "\t\t\r\n"
  398. "\t\tvoid main (void)\r\n"
  399. "\t\t{\r\n"
  400. "\t\t\tgl_FragColor.rgb = texture2D(sampler2d, fTexCoord).rgb * fDiffuse;\r\n"
  401. "\t\t\r\n"
  402. "\t\t\tif(fHeight > -0.1)\r\n"
  403. "\t\t\t{\r\n"
  404. "\t\t\t\tif(bBackFace)\r\n"
  405. "\t\t\t\t\tgl_FragColor.a = fAlteredAnim * 0.3;\r\n"
  406. "\t\t\t\telse\r\n"
  407. "\t\t\t\t\tgl_FragColor.a = 0.0;\r\n"
  408. "\t\t\t}\r\n"
  409. "\t\t\telse \r\n"
  410. "\t\t\t{\r\n"
  411. "\t\t\t\tgl_FragColor.a = fAlteredAnim;\r\n"
  412. "\t\t\t}\r\n"
  413. "\t\t}\r\n"
  414. "\t[/GLSL_CODE]\r\n"
  415. "[/FRAGMENTSHADER]\r\n"
  416. "\r\n"
  417. "[EFFECT] \r\n"
  418. "\tNAME \tballoon_effect4\r\n"
  419. "\t\t\r\n"
  420. "\t// GLOBALS UNIFORMS\r\n"
  421. "\tUNIFORM myModelViewIT \t\tWORLDVIEWIT\r\n"
  422. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  423. "\tUNIFORM\tmyLightDirection\tLIGHTDIRECTION\r\n"
  424. "\tUNIFORM\tsampler2d\t\t\tTEXTURE0\r\n"
  425. "\r\n"
  426. "\t// ATTRIBUTES\r\n"
  427. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  428. "\tATTRIBUTE\tmyNormal\tNORMAL\r\n"
  429. "\tATTRIBUTE\tmyUV\t\tUV\r\n"
  430. "\r\n"
  431. "\tVERTEXSHADER balloon_vert4\r\n"
  432. "\tFRAGMENTSHADER balloon_frag4\r\n"
  433. "\tTEXTURE 0 Balloon\r\n"
  434. "[/EFFECT]\r\n"
  435. "\r\n"
  436. "//Effect 5 /////////////////////////////////////////////////////////////////////\r\n"
  437. "//\r\n"
  438. "// This effect gives a sort of liquid metal effect by only using the skybox \r\n"
  439. "// cubemap as the source for texturing and manipulating the vertex position in \r\n"
  440. "// the vertex shader.\r\n"
  441. "//\r\n"
  442. "\r\n"
  443. "[VERTEXSHADER]\r\n"
  444. "\tNAME \t\tballoon_vert5\r\n"
  445. "\r\n"
  446. "\r\n"
  447. "\t[GLSL_CODE]\r\n"
  448. "\t\tattribute vec3\tmyVertex;\r\n"
  449. "\t\tattribute vec3\tmyNormal;\r\n"
  450. "\t\t\r\n"
  451. "\t\tuniform mat4\tmyMVPMatrix;\r\n"
  452. "\t\tuniform mat3\tmyModelViewIT;\r\n"
  453. "\t\tuniform mat4\tmyModelView;\r\n"
  454. "\t\t\r\n"
  455. "\t\tuniform mediump mat3 myViewIT;\r\n"
  456. "\t\t\r\n"
  457. "\t\tvarying mediump vec3 Normal;\r\n"
  458. "\t\tvarying mediump vec3 EyeDir;\r\n"
  459. "\t\t\r\n"
  460. "\t\tvarying highp vec3 CubeUVs;\r\n"
  461. "\t\t\r\n"
  462. "\t\tuniform mediump float myFrame;\r\n"
  463. "\t\tuniform mediump float fAnim;\r\n"
  464. "\t\t\r\n"
  465. "\t\tvoid main(void)\r\n"
  466. "\t\t{\r\n"
  467. "\t\t\thighp vec3 tVertex = myVertex;\r\n"
  468. "\t\t\thighp float fValue = 3.0 * myFrame * radians(360.0/500.0) - 0.1 * myVertex.y;\r\n"
  469. "\t\t\t\r\n"
  470. "\t\t\tif(myVertex.y > -0.1)\r\n"
  471. "\t\t\t{\r\n"
  472. "\t\t\t\tmediump float fValue2 = fAnim * (1.0 + 0.3 * cos(fValue));\r\n"
  473. "\t\t\t\t\r\n"
  474. "\t\t\t\ttVertex.x *= fValue2;\r\n"
  475. "\t\t\t\ttVertex.z *= fValue2;\r\n"
  476. "\t\t\t\ttVertex.y *= fAnim * fAnim;\r\n"
  477. "\t\t\t}\r\n"
  478. "\t\t\t\r\n"
  479. "\t\t\tmediump vec4 tVertex4 = vec4(tVertex,1);\r\n"
  480. "\t\t\t\r\n"
  481. "\t\t\tEyeDir = vec3(0.0,-1.0,0.0) - vec3(myModelView * tVertex4);\r\n"
  482. "\t\t\t\r\n"
  483. "\t\t\tif(myVertex.y > -0.1)\r\n"
  484. "\t\t\t\tNormal = normalize(myModelViewIT * (myNormal+ sin(fValue))) ;\r\n"
  485. "\t\t\telse\r\n"
  486. "\t\t\t\tNormal = normalize(myModelViewIT * myNormal) ;\r\n"
  487. "\t\t\r\n"
  488. "\t\t\tmediump vec3 n;\r\n"
  489. "\t\t\tn = 0.7 * (dot(EyeDir , Normal) * Normal - EyeDir);\r\n"
  490. "\t\t\tCubeUVs = myViewIT * normalize(-1.0 * (EyeDir + n));\r\n"
  491. "\t\t\t\r\n"
  492. "\t\t\tgl_Position = myMVPMatrix * tVertex4;\r\n"
  493. "\t\t}\r\n"
  494. "\t[/GLSL_CODE]\r\n"
  495. "[/VERTEXSHADER]\r\n"
  496. "\r\n"
  497. "[FRAGMENTSHADER] \r\n"
  498. "\tNAME \t\tballoon_frag5\r\n"
  499. "\r\n"
  500. "\r\n"
  501. "\t[GLSL_CODE]\r\n"
  502. "\t\tuniform samplerCube myCubeMap;\r\n"
  503. "\t\tvarying highp vec3 CubeUVs;\r\n"
  504. "\t\t\r\n"
  505. "\t\tvoid main (void)\r\n"
  506. "\t\t{\r\n"
  507. "\t\t\tgl_FragColor = textureCube(myCubeMap, CubeUVs);\t\t\r\n"
  508. "\t\t}\r\n"
  509. "\t[/GLSL_CODE]\r\n"
  510. "[/FRAGMENTSHADER]\r\n"
  511. "\r\n"
  512. "[EFFECT] \r\n"
  513. "\tNAME \tballoon_effect5\r\n"
  514. "\t\t\r\n"
  515. "\t// GLOBALS UNIFORMS\r\n"
  516. "\tUNIFORM myModelViewIT \t\tWORLDVIEWIT\r\n"
  517. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  518. "\tUNIFORM myModelView\t\t\tWORLDVIEW\r\n"
  519. "\tUNIFORM myViewIT\t\t\tVIEWIT\r\n"
  520. "\tUNIFORM\tmyCubeMap\t\t\tTEXTURE0\r\n"
  521. "\r\n"
  522. "\t// ATTRIBUTES\r\n"
  523. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  524. "\tATTRIBUTE\tmyNormal\tNORMAL\r\n"
  525. "\r\n"
  526. "\tVERTEXSHADER balloon_vert5\r\n"
  527. "\tFRAGMENTSHADER balloon_frag5\r\n"
  528. "\tTEXTURE 0 Skybox\r\n"
  529. "[/EFFECT]\r\n"
  530. "\r\n"
  531. "//Effect 6 /////////////////////////////////////////////////////////////////////\r\n"
  532. "//\r\n"
  533. "// Effect 6 is a sort of bouncy cartoon shaded balloon. Once again the vertex \r\n"
  534. "// positions are manipulated to make the balloon bounce. The cartoon effect is \r\n"
  535. "// done by altering the lighting so it can only have 3 possible values. This \r\n"
  536. "// gives it the banded style of shading.\r\n"
  537. "//\r\n"
  538. "\r\n"
  539. "[VERTEXSHADER]\r\n"
  540. "\tNAME \t\tballoon_vert6\r\n"
  541. "\r\n"
  542. "\t[GLSL_CODE]\r\n"
  543. "\t\tattribute vec3\tmyVertex;\r\n"
  544. "\t\tattribute vec3\tmyNormal;\r\n"
  545. "\t\tattribute vec2\tmyUV;\r\n"
  546. "\t\t\r\n"
  547. "\t\tuniform mat4\tmyMVPMatrix;\r\n"
  548. "\t\tuniform mat3\tmyModelViewIT;\r\n"
  549. "\t\t\r\n"
  550. "\t\tuniform mediump vec3\tmyLightDirection;\r\n"
  551. "\t\tuniform mediump float fAnim;\r\n"
  552. "\t\tuniform mediump float myFrame;\r\n"
  553. "\t\t\r\n"
  554. "\t\tvarying float\tfDiffuse;\r\n"
  555. "\t\tvarying lowp vec2 fTexCoord;\r\n"
  556. "\t\t\r\n"
  557. "\t\tvoid main(void)\r\n"
  558. "\t\t{\r\n"
  559. "\t\t\tmediump float anim2 = sin(3.0*myFrame * radians(360.0/500.0))*0.5 + 0.5;\r\n"
  560. "\t\t\tanim2 *= 0.5;\r\n"
  561. "\t\t\r\n"
  562. "\t\t\tmediump vec3 center = vec3(0.0,30.0,0.0);\r\n"
  563. "\t\t\tmediump vec3 tVertex =((30.0*normalize(myVertex-center)*anim2 + myVertex)*(1.0-anim2)) * fAnim ;\r\n"
  564. "\t\t\ttVertex\t\t+=\t 30.0*normalize(myVertex) * (1.0-fAnim);\r\n"
  565. "\t\t\r\n"
  566. "\t\t\tmediump vec3 fTransNormal = normalize( myModelViewIT * myNormal );\r\n"
  567. "\t\t\t\r\n"
  568. "\t\t\tgl_Position = myMVPMatrix * vec4(tVertex,1.0);\r\n"
  569. "\t\t\t\r\n"
  570. "\t\t\tfDiffuse = dot(fTransNormal, myLightDirection);\r\n"
  571. "\t\t\tfTexCoord= myUV;\r\n"
  572. "\t\t}\r\n"
  573. "\t[/GLSL_CODE]\r\n"
  574. "[/VERTEXSHADER]\r\n"
  575. "\r\n"
  576. "[FRAGMENTSHADER] \r\n"
  577. "\tNAME \t\tballoon_frag6\r\n"
  578. "\r\n"
  579. "\t[GLSL_CODE]\r\n"
  580. "\t\tvarying highp float\tfDiffuse;\r\n"
  581. "\t\tvarying lowp vec2\tfTexCoord;\r\n"
  582. "\t\t\r\n"
  583. "\t\tuniform sampler2D sampler2d;\r\n"
  584. "\t\t\r\n"
  585. "\t\t\r\n"
  586. "\t\tvoid main (void)\r\n"
  587. "\t\t{\r\n"
  588. "\t\t\tlowp vec4 texColor = texture2D(sampler2d,fTexCoord);\r\n"
  589. "\t\t\t\r\n"
  590. "\t\t\tmediump float intensity;\r\n"
  591. "\t\t\t\r\n"
  592. "\t\t\tif(fDiffuse > 0.67)\r\n"
  593. "\t\t\t\tintensity = 1.0;\r\n"
  594. "\t\t\telse if(fDiffuse > 0.33)\r\n"
  595. "\t\t\t\tintensity = 0.67;\r\n"
  596. "\t\t\telse\r\n"
  597. "\t\t\t\tintensity = 0.33;\r\n"
  598. "\t\t\t\t\r\n"
  599. "\t\t gl_FragColor = texColor * intensity;;\r\n"
  600. "\t\t}\r\n"
  601. "\t[/GLSL_CODE]\r\n"
  602. "[/FRAGMENTSHADER]\r\n"
  603. "\r\n"
  604. "[EFFECT] \r\n"
  605. "\tNAME \tballoon_effect6\r\n"
  606. "\t\t\r\n"
  607. "\t// GLOBALS UNIFORMS\r\n"
  608. "\tUNIFORM myModelViewIT \t\tWORLDVIEWIT\r\n"
  609. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  610. "\tUNIFORM\tmyLightDirection\tLIGHTDIRECTION\r\n"
  611. "\tUNIFORM\tsampler2d\t\t\tTEXTURE0\r\n"
  612. "\r\n"
  613. "\t// ATTRIBUTES\r\n"
  614. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  615. "\tATTRIBUTE\tmyNormal\tNORMAL\r\n"
  616. "\tATTRIBUTE\tmyUV\t\tUV\r\n"
  617. "\r\n"
  618. "\tVERTEXSHADER balloon_vert6\r\n"
  619. "\tFRAGMENTSHADER balloon_frag6\r\n"
  620. "\tTEXTURE 0 Balloon\r\n"
  621. "[/EFFECT]\r\n"
  622. "\r\n"
  623. "//Effect 7 /////////////////////////////////////////////////////////////////////\r\n"
  624. "//\r\n"
  625. "// This effect gives impression that the balloon is slightly transparent and \r\n"
  626. "// being affected by wind. This is done by using a noise texture to alter the \r\n"
  627. "// alpha and texture coordinates in the fragment shader. \r\n"
  628. "//\r\n"
  629. "\r\n"
  630. "[VERTEXSHADER]\r\n"
  631. "\tNAME \t\tballoon_vert7\r\n"
  632. "\r\n"
  633. "\t[GLSL_CODE]\r\n"
  634. "\t\tattribute vec3\tmyVertex;\r\n"
  635. "\t\tattribute vec3\tmyNormal;\r\n"
  636. "\t\tattribute vec2\tmyUV;\r\n"
  637. "\t\t\r\n"
  638. "\t\tuniform mat4\tmyMVPMatrix;\r\n"
  639. "\t\tuniform mat3\tmyModelViewIT;\r\n"
  640. "\t\t\r\n"
  641. "\t\tuniform mediump vec3\tmyLightDirection;\r\n"
  642. "\t\tuniform mediump float\tfAnim;\r\n"
  643. "\t\tuniform mediump float myFrame;\r\n"
  644. "\t\t\r\n"
  645. "\t\tvarying float\tfDiffuse;\r\n"
  646. "\t\tvarying lowp vec2 fTexCoord;\r\n"
  647. "\r\n"
  648. "\t\tvarying highp float fAlpha;\r\n"
  649. "\t\tvarying mediump float frame;\r\n"
  650. "\t\t\r\n"
  651. "\t\tvoid main(void)\r\n"
  652. "\t\t{\r\n"
  653. "\t\t\r\n"
  654. "\t\t\tgl_Position = myMVPMatrix * vec4(myVertex,1);\r\n"
  655. "\t\t\tmediump vec3 fTransNormal = myModelViewIT * myNormal;\r\n"
  656. "\t\t\t\r\n"
  657. "\t\t\tfDiffuse = 0.1 * dot(fTransNormal, myLightDirection) + 0.9;\r\n"
  658. "\t\t\tfTexCoord\t= 0.7 * myUV;\r\n"
  659. "\t\t\tfAlpha = fAnim * dot(normalize(fTransNormal), vec3(0.0,0.0,0.5)) * 2.0;\r\n"
  660. "\t\t\tframe = myFrame * 0.02;\r\n"
  661. "\t\t}\r\n"
  662. "\t[/GLSL_CODE]\r\n"
  663. "[/VERTEXSHADER]\r\n"
  664. "\r\n"
  665. "[FRAGMENTSHADER] \r\n"
  666. "\tNAME \t\tballoon_frag7\r\n"
  667. "\r\n"
  668. "\t[GLSL_CODE]\r\n"
  669. "\t\tvarying highp float\tfDiffuse;\r\n"
  670. "\t\tvarying lowp vec2\tfTexCoord;\r\n"
  671. "\t\tvarying highp float\tfAlpha;\r\n"
  672. "\t\tvarying mediump float frame;\r\n"
  673. "\t\t\r\n"
  674. "\t\tuniform sampler2D sampler2d;\r\n"
  675. "\t\tuniform sampler2D Noise;\r\n"
  676. "\t\t\r\n"
  677. "\t\tvoid main (void)\r\n"
  678. "\t\t{ \r\n"
  679. "\t\t mediump vec2 noisevec = texture2D(Noise, fTexCoord + frame).xy;\r\n"
  680. "\t\t mediump vec2 coord2D = fTexCoord + 0.3 * noisevec;\r\n"
  681. "\t\t\r\n"
  682. "\t\t gl_FragColor.rgb = texture2D(sampler2d, coord2D).rgb * fDiffuse;\r\n"
  683. "\t\t gl_FragColor.a = fAlpha * noisevec.x;\r\n"
  684. "\t\t}\r\n"
  685. "\t[/GLSL_CODE]\r\n"
  686. "[/FRAGMENTSHADER]\r\n"
  687. "\r\n"
  688. "\r\n"
  689. "[EFFECT] \r\n"
  690. "\tNAME \tballoon_effect7\r\n"
  691. "\t\t\r\n"
  692. "\t// GLOBALS UNIFORMS\r\n"
  693. "\tUNIFORM myModelViewIT \t\tWORLDVIEWIT\r\n"
  694. "\tUNIFORM myMVPMatrix \t\tWORLDVIEWPROJECTION\r\n"
  695. "\tUNIFORM\tmyLightDirection\tLIGHTDIRECTION\r\n"
  696. "\tUNIFORM\tsampler2d\t\t\tTEXTURE0\r\n"
  697. "\tUNIFORM\tNoise\t\t\t\tTEXTURE1\r\n"
  698. "\r\n"
  699. "\t// ATTRIBUTES\r\n"
  700. "\tATTRIBUTE \tmyVertex\tPOSITION\r\n"
  701. "\tATTRIBUTE\tmyNormal\tNORMAL\r\n"
  702. "\tATTRIBUTE\tmyUV\t\tUV\r\n"
  703. "\r\n"
  704. "\tVERTEXSHADER \tballoon_vert7\r\n"
  705. "\tFRAGMENTSHADER \tballoon_frag7\r\n"
  706. "\tTEXTURE 0 Balloon_pvr\r\n"
  707. "\tTEXTURE 1 Noise\r\n"
  708. "[/EFFECT]\r\n";
  709. // Register effects.pfx in memory file system at application startup time
  710. static CPVRTMemoryFileSystem RegisterFile_effects_pfx("effects.pfx", _effects_pfx, 17065);
  711. // ******** End: effects.pfx ********