123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- [HEADER]
- VERSION 01.00.00.00
- DESCRIPTION texture example
- COPYRIGHT Img Tec
- [/HEADER]
- // Define the textures that we'll be using
- [TEXTURES]
- FILE Balloon Balloon.pvr LINEAR-LINEAR-LINEAR
- FILE Balloon_pvr Balloon_pvr.pvr LINEAR-LINEAR-LINEAR
- FILE Noise Noise.pvr LINEAR-LINEAR-LINEAR
- FILE Skybox Skybox.pvr LINEAR-LINEAR-LINEAR CLAMP-CLAMP
- FILE SkyboxMidnight SkyboxMidnight.pvr LINEAR-LINEAR-LINEAR CLAMP-CLAMP
- [/TEXTURES]
- //Effect 0//////////////////////////////////////////////////////////////////////
- //
- // This effect is used for the skybox. The inverse of the vertex positions for
- // the skybox are used as texture coordinates for accessing the skybox texture.
- //
- [VERTEXSHADER]
- NAME skybox_vert
- [GLSL_CODE]
- attribute highp vec3 myVertex;
- uniform mediump mat4 myMVPMatrix;
- varying highp vec3 EyeDir;
- void main(void)
- {
- EyeDir = -myVertex;
- gl_Position = myMVPMatrix * vec4(myVertex,1.0);
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME skybox_frag
-
- [GLSL_CODE]
- varying highp vec3 EyeDir;
- uniform samplerCube myCubeMap;
-
- void main (void)
- {
- gl_FragColor = textureCube(myCubeMap, EyeDir);
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
- [EFFECT]
- NAME skybox_effect
-
- // GLOBALS UNIFORMS
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myCubeMap TEXTURE0
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- VERTEXSHADER skybox_vert
- FRAGMENTSHADER skybox_frag
- TEXTURE 0 Skybox
- [/EFFECT]
- //Effect 1 /////////////////////////////////////////////////////////////////////
- //
- // This effect displays a textured balloon with some simple lighting.
- //
- [VERTEXSHADER]
- NAME balloon_vert1
- [GLSL_CODE]
- attribute highp vec3 myVertex;
- attribute mediump vec3 myNormal;
- attribute mediump vec2 myUV;
- uniform mediump mat4 myMVPMatrix;
- uniform mediump mat3 myModelViewIT;
- uniform mediump vec3 myLightDirection;
- uniform mediump float fAnim;
- varying mediump float fDot;
- varying lowp vec2 fTexCoord;
-
- void main(void)
- {
- gl_Position = myMVPMatrix * vec4(myVertex,1);
- fTexCoord = myUV;
- mediump vec3 fTransNormal = myModelViewIT * myNormal;
- fDot = 0.1 * dot(fTransNormal, myLightDirection) + 0.9;
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME balloon_frag1
- [GLSL_CODE]
- uniform sampler2D sampler2d;
- varying mediump float fDot;
- varying lowp vec2 fTexCoord;
-
- void main (void)
- {
- gl_FragColor = texture2D(sampler2d,fTexCoord) * fDot;
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
- [EFFECT]
- NAME balloon_effect1
-
- // GLOBALS UNIFORMS
- UNIFORM myModelViewIT WORLDVIEWIT
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myLightDirection LIGHTDIRECTION
- UNIFORM sampler2d TEXTURE0
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- ATTRIBUTE myNormal NORMAL
- ATTRIBUTE myUV UV
- VERTEXSHADER balloon_vert1
- FRAGMENTSHADER balloon_frag1
- TEXTURE 0 Balloon_pvr
- [/EFFECT]
- //Effect 2 /////////////////////////////////////////////////////////////////////
- //
- // This effect creates a burning effect that burns the balloon from the basket
- // up. It does this by calculating whether a pixel is below at least one of
- // three thresholds (which rise over time). If it is not then the balloon
- // is textured and lit in the same way as effect 1 otherwise the burn effect is
- // applied according to the threshold it is below.
- //
- [VERTEXSHADER]
- NAME balloon_vert2
- [GLSL_CODE]
- attribute vec3 myVertex;
- attribute vec3 myNormal;
- attribute vec2 myUV;
-
- uniform mat4 myMVPMatrix;
- uniform mat3 myModelViewIT;
-
- uniform mediump vec3 myLightDirection;
- uniform highp float fAnim;
-
- varying float fDiffuse;
- varying lowp vec2 fTexCoord;
- varying lowp vec2 fTexCoord2;
-
- varying highp vec3 fPosition;
- varying highp float fBurn;
-
- void main(void)
- {
- gl_Position = myMVPMatrix * vec4(myVertex,1);
-
- fDiffuse = 0.1 * dot(myModelViewIT * myNormal, myLightDirection) + 0.9;
-
- fPosition = myVertex * 0.05;
-
- highp float fOffset = fract(0.999 * fAnim) * 2.1;
- fBurn = fOffset - 0.53 * (fPosition.y + 0.2);
- fBurn = clamp(fBurn, 0.0, 1.0);
-
- fTexCoord = myUV;
- fTexCoord2 = vec2(fPosition.x + fPosition.z * fPosition.z, fPosition.y + 0.5 * fPosition.z + 0.5 * fPosition.x * fPosition.x);
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME balloon_frag2
- [GLSL_CODE]
- varying highp float fDiffuse;
- varying lowp vec2 fTexCoord;
- varying lowp vec2 fTexCoord2;
- uniform sampler2D sampler2d;
- uniform sampler2D Noise;
-
- varying highp float fBurn;
-
- highp vec3 reflect (void)
- {
- return texture2D(sampler2d,fTexCoord).rgb * fDiffuse;
- }
-
- void main (void)
- {
- highp vec4 noisevec;
- highp vec3 color;
- highp float intensity;
-
- noisevec = texture2D(Noise, fTexCoord2);
-
- intensity = 0.6 * (noisevec.x + noisevec.y + noisevec.z + noisevec.w);
- intensity = abs(intensity - 1.0);
- intensity = clamp(intensity, 0.0, 1.0);
-
- if (intensity < fBurn)
- color = vec3(0.0);
- else if(intensity < 1.5 * fBurn)
- color = vec3(0.1);
- else if(intensity < 1.7 * fBurn)
- color = vec3(1.0, 10.0 * (-intensity + 1.7 * fBurn) ,0.0);
- else
- color = reflect();
-
- gl_FragColor = vec4(color, 1);
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
-
- [EFFECT]
- NAME balloon_effect2
-
- // GLOBALS UNIFORMS
- UNIFORM myModelViewIT WORLDVIEWIT
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myLightDirection LIGHTDIRECTION
- UNIFORM sampler2d TEXTURE0
- UNIFORM Noise TEXTURE1
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- ATTRIBUTE myNormal NORMAL
- ATTRIBUTE myUV UV
- VERTEXSHADER balloon_vert2
- FRAGMENTSHADER balloon_frag2
- TEXTURE 0 Balloon_pvr
- TEXTURE 1 Noise
- [/EFFECT]
- //Effect 3 /////////////////////////////////////////////////////////////////////
- //
- // Effect 3 is very similar to effect 1 in that it displays a textured
- // balloon with diffuse lighting. However, it applies two textures to the
- // balloon. The second texture is the skybox cube map which is applied using a
- // reflection vector as texture coordinates. This makes it look like the balloon
- // is reflecting the skybox.
- //
- [VERTEXSHADER]
- NAME balloon_vert3
- [GLSL_CODE]
- attribute vec3 myVertex;
- attribute vec3 myNormal;
- attribute vec2 myUV;
-
- uniform mat4 myMVPMatrix;
- uniform mat3 myModelViewIT;
- uniform mat4 myModelView;
- uniform mat3 myViewIT;
-
- uniform mediump vec3 myLightDirection;
- varying highp float fDiffuse;
- varying lowp vec2 fTexCoord;
- uniform mediump float myFrame;
- uniform mediump float fAnim;
- varying lowp vec3 fReflectVec;
-
- void main(void)
- {
- mediump vec4 myVertex4 = vec4(myVertex, 1);
-
- gl_Position = myMVPMatrix * myVertex4;
- mediump vec3 fTransNormal = myModelViewIT * myNormal;
-
- fDiffuse = (0.05 * dot(fTransNormal, myLightDirection) + 0.95) * fAnim * 0.5;
-
- mediump vec3 EyeDir = vec3(0.0,-1.0,0.0) - vec3(myModelView * myVertex4);
- fReflectVec = myViewIT * reflect(EyeDir, normalize(fTransNormal) );
-
- fTexCoord = myUV.st;
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME balloon_frag3
- [GLSL_CODE]
- varying highp float fDiffuse;
- varying lowp vec2 fTexCoord;
- varying lowp vec3 fReflectVec;
-
- uniform sampler2D sampler2d;
- uniform samplerCube myCubeMap;
-
- void main (void)
- {
- gl_FragColor = textureCube(myCubeMap, fReflectVec) + texture2D(sampler2d, fTexCoord);
- gl_FragColor *= fDiffuse;
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
- [EFFECT]
- NAME balloon_effect3
-
- // GLOBALS UNIFORMS
- UNIFORM myModelViewIT WORLDVIEWIT
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myModelView WORLDVIEW
- UNIFORM myViewIT VIEWIT
- UNIFORM myLightDirection LIGHTDIRECTION
- UNIFORM sampler2d TEXTURE0
- UNIFORM myCubeMap TEXTURE1
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- ATTRIBUTE myNormal NORMAL
- ATTRIBUTE myUV UV
- VERTEXSHADER balloon_vert3
- FRAGMENTSHADER balloon_frag3
- TEXTURE 0 Balloon
- TEXTURE 1 Skybox
- [/EFFECT]
- //Effect 4 /////////////////////////////////////////////////////////////////////
- //
- // This effect alters the transparency of the balloon based on an external
- // variable calculated in the app. The basket isn't affected as much as the
- // balloon as pixels over the height of 0.1 are given a lower alpha value.
- //
- [VERTEXSHADER]
- NAME balloon_vert4
- [GLSL_CODE]
- attribute vec3 myVertex;
- attribute vec3 myNormal;
- attribute vec2 myUV;
-
- uniform mat4 myMVPMatrix;
- uniform mat3 myModelViewIT;
- uniform mediump vec3 myLightDirection;
- uniform mediump float fAnim;
-
- varying float fDiffuse;
- varying lowp vec2 fTexCoord;
- varying mediump float fHeight;
- varying mediump float fAlteredAnim;
-
- void main(void)
- {
- gl_Position = myMVPMatrix * vec4(myVertex, 1);
-
- mediump vec3 fTransNormal = myModelViewIT * myNormal;
- fDiffuse = (0.05 * dot(fTransNormal, myLightDirection) + 0.95) * 0.5;
-
- fTexCoord = myUV;
- fHeight = myVertex.y;
-
- fAlteredAnim = (1.0 - fAnim) + fAnim;
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME balloon_frag4
- [GLSL_CODE]
- varying highp float fDiffuse;
- varying lowp vec2 fTexCoord;
- varying mediump float fHeight;
- varying mediump float fAlteredAnim;
-
- uniform sampler2D sampler2d;
- uniform bool bBackFace;
-
- void main (void)
- {
- gl_FragColor.rgb = texture2D(sampler2d, fTexCoord).rgb * fDiffuse;
-
- if(fHeight > -0.1)
- {
- if(bBackFace)
- gl_FragColor.a = fAlteredAnim * 0.3;
- else
- gl_FragColor.a = 0.0;
- }
- else
- {
- gl_FragColor.a = fAlteredAnim;
- }
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
- [EFFECT]
- NAME balloon_effect4
-
- // GLOBALS UNIFORMS
- UNIFORM myModelViewIT WORLDVIEWIT
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myLightDirection LIGHTDIRECTION
- UNIFORM sampler2d TEXTURE0
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- ATTRIBUTE myNormal NORMAL
- ATTRIBUTE myUV UV
- VERTEXSHADER balloon_vert4
- FRAGMENTSHADER balloon_frag4
- TEXTURE 0 Balloon
- [/EFFECT]
- //Effect 5 /////////////////////////////////////////////////////////////////////
- //
- // This effect gives a sort of liquid metal effect by only using the skybox
- // cubemap as the source for texturing and manipulating the vertex position in
- // the vertex shader.
- //
- [VERTEXSHADER]
- NAME balloon_vert5
- [GLSL_CODE]
- attribute vec3 myVertex;
- attribute vec3 myNormal;
-
- uniform mat4 myMVPMatrix;
- uniform mat3 myModelViewIT;
- uniform mat4 myModelView;
-
- uniform mediump mat3 myViewIT;
-
- varying mediump vec3 Normal;
- varying mediump vec3 EyeDir;
-
- varying highp vec3 CubeUVs;
-
- uniform mediump float myFrame;
- uniform mediump float fAnim;
-
- void main(void)
- {
- highp vec3 tVertex = myVertex;
- highp float fValue = 3.0 * myFrame * radians(360.0/500.0) - 0.1 * myVertex.y;
-
- if(myVertex.y > -0.1)
- {
- mediump float fValue2 = fAnim * (1.0 + 0.3 * cos(fValue));
-
- tVertex.x *= fValue2;
- tVertex.z *= fValue2;
- tVertex.y *= fAnim * fAnim;
- }
-
- mediump vec4 tVertex4 = vec4(tVertex,1);
-
- EyeDir = vec3(0.0,-1.0,0.0) - vec3(myModelView * tVertex4);
-
- if(myVertex.y > -0.1)
- Normal = normalize(myModelViewIT * (myNormal+ sin(fValue))) ;
- else
- Normal = normalize(myModelViewIT * myNormal) ;
-
- mediump vec3 n;
- n = 0.7 * (dot(EyeDir , Normal) * Normal - EyeDir);
- CubeUVs = myViewIT * normalize(-1.0 * (EyeDir + n));
-
- gl_Position = myMVPMatrix * tVertex4;
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME balloon_frag5
- [GLSL_CODE]
- uniform samplerCube myCubeMap;
- varying highp vec3 CubeUVs;
-
- void main (void)
- {
- gl_FragColor = textureCube(myCubeMap, CubeUVs);
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
- [EFFECT]
- NAME balloon_effect5
-
- // GLOBALS UNIFORMS
- UNIFORM myModelViewIT WORLDVIEWIT
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myModelView WORLDVIEW
- UNIFORM myViewIT VIEWIT
- UNIFORM myCubeMap TEXTURE0
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- ATTRIBUTE myNormal NORMAL
- VERTEXSHADER balloon_vert5
- FRAGMENTSHADER balloon_frag5
- TEXTURE 0 Skybox
- [/EFFECT]
- //Effect 6 /////////////////////////////////////////////////////////////////////
- //
- // Effect 6 is a sort of bouncy cartoon shaded balloon. Once again the vertex
- // positions are manipulated to make the balloon bounce. The cartoon effect is
- // done by altering the lighting so it can only have 3 possible values. This
- // gives it the banded style of shading.
- //
- [VERTEXSHADER]
- NAME balloon_vert6
- [GLSL_CODE]
- attribute vec3 myVertex;
- attribute vec3 myNormal;
- attribute vec2 myUV;
-
- uniform mat4 myMVPMatrix;
- uniform mat3 myModelViewIT;
-
- uniform mediump vec3 myLightDirection;
- uniform mediump float fAnim;
- uniform mediump float myFrame;
-
- varying float fDiffuse;
- varying lowp vec2 fTexCoord;
-
- void main(void)
- {
- mediump float anim2 = sin(3.0*myFrame * radians(360.0/500.0))*0.5 + 0.5;
- anim2 *= 0.5;
-
- mediump vec3 center = vec3(0.0,30.0,0.0);
- mediump vec3 tVertex =((30.0*normalize(myVertex-center)*anim2 + myVertex)*(1.0-anim2)) * fAnim ;
- tVertex += 30.0*normalize(myVertex) * (1.0-fAnim);
-
- mediump vec3 fTransNormal = normalize( myModelViewIT * myNormal );
-
- gl_Position = myMVPMatrix * vec4(tVertex,1.0);
-
- fDiffuse = dot(fTransNormal, myLightDirection);
- fTexCoord= myUV;
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME balloon_frag6
- [GLSL_CODE]
- varying highp float fDiffuse;
- varying lowp vec2 fTexCoord;
-
- uniform sampler2D sampler2d;
-
-
- void main (void)
- {
- lowp vec4 texColor = texture2D(sampler2d,fTexCoord);
-
- mediump float intensity;
-
- if(fDiffuse > 0.67)
- intensity = 1.0;
- else if(fDiffuse > 0.33)
- intensity = 0.67;
- else
- intensity = 0.33;
-
- gl_FragColor = texColor * intensity;;
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
- [EFFECT]
- NAME balloon_effect6
-
- // GLOBALS UNIFORMS
- UNIFORM myModelViewIT WORLDVIEWIT
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myLightDirection LIGHTDIRECTION
- UNIFORM sampler2d TEXTURE0
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- ATTRIBUTE myNormal NORMAL
- ATTRIBUTE myUV UV
- VERTEXSHADER balloon_vert6
- FRAGMENTSHADER balloon_frag6
- TEXTURE 0 Balloon
- [/EFFECT]
- //Effect 7 /////////////////////////////////////////////////////////////////////
- //
- // This effect gives impression that the balloon is slightly transparent and
- // being affected by wind. This is done by using a noise texture to alter the
- // alpha and texture coordinates in the fragment shader.
- //
- [VERTEXSHADER]
- NAME balloon_vert7
- [GLSL_CODE]
- attribute vec3 myVertex;
- attribute vec3 myNormal;
- attribute vec2 myUV;
-
- uniform mat4 myMVPMatrix;
- uniform mat3 myModelViewIT;
-
- uniform mediump vec3 myLightDirection;
- uniform mediump float fAnim;
- uniform mediump float myFrame;
-
- varying float fDiffuse;
- varying lowp vec2 fTexCoord;
- varying highp float fAlpha;
- varying mediump float frame;
-
- void main(void)
- {
-
- gl_Position = myMVPMatrix * vec4(myVertex,1);
- mediump vec3 fTransNormal = myModelViewIT * myNormal;
-
- fDiffuse = 0.1 * dot(fTransNormal, myLightDirection) + 0.9;
- fTexCoord = 0.7 * myUV;
- fAlpha = fAnim * dot(normalize(fTransNormal), vec3(0.0,0.0,0.5)) * 2.0;
- frame = myFrame * 0.02;
- }
- [/GLSL_CODE]
- [/VERTEXSHADER]
- [FRAGMENTSHADER]
- NAME balloon_frag7
- [GLSL_CODE]
- varying highp float fDiffuse;
- varying lowp vec2 fTexCoord;
- varying highp float fAlpha;
- varying mediump float frame;
-
- uniform sampler2D sampler2d;
- uniform sampler2D Noise;
-
- void main (void)
- {
- mediump vec2 noisevec = texture2D(Noise, fTexCoord + frame).xy;
- mediump vec2 coord2D = fTexCoord + 0.3 * noisevec;
-
- gl_FragColor.rgb = texture2D(sampler2d, coord2D).rgb * fDiffuse;
- gl_FragColor.a = fAlpha * noisevec.x;
- }
- [/GLSL_CODE]
- [/FRAGMENTSHADER]
- [EFFECT]
- NAME balloon_effect7
-
- // GLOBALS UNIFORMS
- UNIFORM myModelViewIT WORLDVIEWIT
- UNIFORM myMVPMatrix WORLDVIEWPROJECTION
- UNIFORM myLightDirection LIGHTDIRECTION
- UNIFORM sampler2d TEXTURE0
- UNIFORM Noise TEXTURE1
- // ATTRIBUTES
- ATTRIBUTE myVertex POSITION
- ATTRIBUTE myNormal NORMAL
- ATTRIBUTE myUV UV
- VERTEXSHADER balloon_vert7
- FRAGMENTSHADER balloon_frag7
- TEXTURE 0 Balloon_pvr
- TEXTURE 1 Noise
- [/EFFECT]
|