diff options
| author | Jason Sams <rjsams@android.com> | 2009-12-10 17:32:28 -0800 |
|---|---|---|
| committer | Jason Sams <rjsams@android.com> | 2010-02-11 18:09:56 -0800 |
| commit | 6a500a1d5e15bd5a563995f31d0796552cc13640 (patch) | |
| tree | 5166241fb3673a24b980e8995200a67b8168672d /res | |
| parent | a7f85762cded62465c5144679ba8bf5b9986d0c0 (diff) | |
| download | android_packages_wallpapers_Basic-6a500a1d5e15bd5a563995f31d0796552cc13640.tar.gz android_packages_wallpapers_Basic-6a500a1d5e15bd5a563995f31d0796552cc13640.tar.bz2 android_packages_wallpapers_Basic-6a500a1d5e15bd5a563995f31d0796552cc13640.zip | |
DO NOT MERGE. Port Froyo livewallpaper support to eclair for droid..
Update grass to use fragment shaders.
Create struct for blade data.
Use indicies to reduce grass cpu usage. Fix aliasing of tips of grass.
Update to new RS texture API.
Update to new RS element API.
Update to use RS generic attrib support.
Change to user attrib types.
Disable per touch logging.
Simplify the fall water script. Remove some dead code from the java layer that was left over from the old integer mesh.
Move Fall waveform calculation to vertex shader.
Add uses-feature to the manifest.
Enable red-pulses-only mode in Nexus wallpaper.
Also load textures with CLAMP for Droid compatiblity.
Bug: 2395147
Change-Id: Id310674e1c3160a545d632b286506e55e9cbc8ad
Fix shader problems in Nexus, er, Neural Network LW.
Change-Id: I852bdf4700d61f18a006ebcf619e9d4f3b51e4cd
Fix Galaxy in landscape mode.
Author: Romain Guy <romainguy@android.com>
Committer: Jason Sams <rjsams@android.com>
On branch droid
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: src/com/android/wallpaper/galaxy/GalaxyRS.java
Diffstat (limited to 'res')
| -rw-r--r-- | res/raw/fall.rs | 134 | ||||
| -rw-r--r-- | res/raw/galaxy.rs | 54 | ||||
| -rw-r--r-- | res/raw/grass.rs | 149 | ||||
| -rw-r--r-- | res/raw/nexus.rs | 21 | ||||
| -rw-r--r-- | res/values/integers.xml | 3 |
5 files changed, 112 insertions, 249 deletions
diff --git a/res/raw/fall.rs b/res/raw/fall.rs index e5cd67b..e183178 100644 --- a/res/raw/fall.rs +++ b/res/raw/fall.rs @@ -26,21 +26,10 @@ float skyOffsetY; float g_DT; int g_LastTime; -struct vert_s { - float x; - float y; - float z; - float s; - float t; -}; - struct drop_s { float ampS; float ampE; float spread; - float spread2; - float invSpread; - float invSpread2; float x; float y; }; @@ -63,9 +52,7 @@ struct Leaves_s { }; struct Leaves_s gLeavesStore[LEAVES_COUNT]; - struct Leaves_s* gLeaves[LEAVES_COUNT]; - struct Leaves_s* gNextLeaves[LEAVES_COUNT]; void init() { @@ -75,9 +62,6 @@ void init() { gDrops[ct].ampS = 0; gDrops[ct].ampE = 0; gDrops[ct].spread = 1; - gDrops[ct].spread2 = gDrops[ct].spread * gDrops[ct].spread; - gDrops[ct].invSpread = 1 / gDrops[ct].spread; - gDrops[ct].invSpread2 = gDrops[ct].invSpread * gDrops[ct].invSpread; } } @@ -107,10 +91,7 @@ void initLeaves() { void updateDrop(int ct) { gDrops[ct].spread += 30.f * g_DT; - gDrops[ct].spread2 = gDrops[ct].spread * gDrops[ct].spread; - gDrops[ct].invSpread = 1 / gDrops[ct].spread; - gDrops[ct].invSpread2 = gDrops[ct].invSpread * gDrops[ct].invSpread; - gDrops[ct].ampE = gDrops[ct].ampS * gDrops[ct].invSpread; + gDrops[ct].ampE = gDrops[ct].ampS / gDrops[ct].spread; } void drop(int x, int y, float s) { @@ -131,65 +112,20 @@ void drop(int x, int y, float s) { } void generateRipples() { - int rippleMapSize = State->rippleMapSize; - int width = State->meshWidth; - int height = State->meshHeight; - int index = State->rippleIndex; - float ratio = (float)State->meshWidth / State->glWidth; - float xShift = State->xOffset * ratio * 2; - - float *vertices = loadSimpleMeshVerticesF(NAMED_WaterMesh, 0); - struct vert_s *vert = (struct vert_s *)vertices; - - float fw = 1.0f / width; - float fh = 1.0f / height; - int x, y, ct; - struct vert_s *v = vert; - for (y=0; y < height; y++) { - for (x=0; x < width; x++) { - struct drop_s * d = &gDrops[0]; - float z = 0; - - for (ct = 0; ct < gMaxDrops; ct++) { - if (d->ampE > 0.01f) { - float dx = (d->x - xShift) - x; - float dy = d->y - y; - float dist2 = dx*dx + dy*dy; - if (dist2 < d->spread2) { - float dist = sqrtf(dist2); - float a = d->ampE * (dist * d->invSpread); - z += sinf(d->spread - dist) * a; - } - } - d++; - } - v->z = z; - v ++; - } - } + int ct; for (ct = 0; ct < gMaxDrops; ct++) { - updateDrop(ct); + struct drop_s * d = &gDrops[ct]; + vecF32_4_t *v = &Constants->Drop01; + v += ct; + v->x = d->x; + v->y = d->y; + v->z = d->ampE * 0.12f; + v->w = d->spread; } + Constants->Offset.x = State->xOffset; - v = vert; - for (y = 0; y < height; y += 1) { - for (x = 0; x < width; x += 1) { - struct vec3_s n1, n2, n3; - vec3Sub(&n1, (struct vec3_s *)&(v+1)->x, (struct vec3_s *)&v->x); - vec3Sub(&n2, (struct vec3_s *)&(v+width)->x, (struct vec3_s *)&v->x); - vec3Cross(&n3, &n1, &n2); - - // Average of previous normal and N1 x N2 - vec3Sub(&n1, (struct vec3_s *)&(v+width+1)->x, (struct vec3_s *)&v->x); - vec3Cross(&n2, &n1, &n2); - vec3Add(&n3, &n3, &n2); - //vec3Norm(&n3); // Not necessary for our constrained mesh. - - v->s = (float)x * fw + n3.x;// * 0.2; - v->t = (float)y * fh + n3.y;// * 0.2; - v->z = 0; - v += 1; - } + for (ct = 0; ct < gMaxDrops; ct++) { + updateDrop(ct); } } @@ -357,46 +293,8 @@ void drawLeaves() { void drawRiverbed() { bindTexture(NAMED_PFBackground, 0, NAMED_TRiverbed); - - float matrix[16]; - matrixLoadScale(matrix, 0.5f * 960.0f / 1024.0f, -1.0f * 800.0f / 1024.0f, 1.0f); - matrixTranslate(matrix, State->xOffset, 0.0f, 0.0f); - vpLoadTextureMatrix(matrix); - - drawSimpleMesh(NAMED_WaterMesh); - - matrixLoadIdentity(matrix); - vpLoadTextureMatrix(matrix); -} - -/* -void drawSky() { - color(1.0f, 1.0f, 1.0f, 0.5f); - - bindProgramFragment(NAMED_PFSky); - bindProgramFragmentStore(NAMED_PFSLeaf); - bindTexture(NAMED_PFSky, 0, NAMED_TSky); - - float x = skyOffsetX + State->skySpeedX; - float y = skyOffsetY + State->skySpeedY; - - if (x > 1.0f) x = 0.0f; - if (x < -1.0f) x = 0.0f; - if (y > 1.0f) y = 0.0f; - - skyOffsetX = x; - skyOffsetY = y; - - float matrix[16]; - matrixLoadTranslate(matrix, x + State->xOffset, y, 0.0f); - vpLoadTextureMatrix(matrix); - drawSimpleMesh(NAMED_WaterMesh); - - matrixLoadIdentity(matrix); - vpLoadTextureMatrix(matrix); } -*/ int main(int index) { // Compute dt in seconds. @@ -425,17 +323,17 @@ int main(int index) { genLeafDrop(gLeaves[i], randf(0.3f) + 0.1f); } - generateRipples(); - updateSimpleMesh(NAMED_WaterMesh); - if (State->rotate) { float matrix[16]; matrixLoadRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f); vpLoadModelMatrix(matrix); } + bindProgramVertex(NAMED_PVWater); + generateRipples(); drawRiverbed(); - // drawSky(); + + bindProgramVertex(NAMED_PVSky); drawLeaves(); return 30; diff --git a/res/raw/galaxy.rs b/res/raw/galaxy.rs index 7c97de0..f37dc6d 100644 --- a/res/raw/galaxy.rs +++ b/res/raw/galaxy.rs @@ -13,7 +13,7 @@ // limitations under the License. #pragma version(1) -#pragma stateVertex(PVBackground) +#pragma stateVertex(PVBkOrtho) #pragma stateRaster(parent) #pragma stateFragment(PFBackground) #pragma stateStore(PFSBackground) @@ -51,25 +51,30 @@ float randomGauss() { return x1 * w; } +float gSpeed[12000]; + /** * Generates the properties for a given star. */ -void createParticle(struct Stars_s *star, struct Particles_s *part, float scale) { +void createParticle(struct Particles_s *part, int idx, float scale) { float d = fabsf(randomGauss()) * State->galaxyRadius * 0.5f + randf(64.0f); float id = d / State->galaxyRadius; float z = randomGauss() * 0.4f * (1.0f - id); float p = -d * ELLIPSE_TWIST; + int r,g,b,a; if (d < State->galaxyRadius * 0.33f) { - part->r = (int) (220 + id * 35); - part->g = 220; - part->b = 220; + r = (int) (220 + id * 35); + g = 220; + b = 220; } else { - part->r= 180; - part->g = 180; - part->b = (int) clampf(140.f + id * 115.f, 140.f, 255.f); + r = 180; + g = 180; + b = (int) clampf(140.f + id * 115.f, 140.f, 255.f); } - part->a = (int) (140 + (1.0f - id) * 115); + // Stash point size * 10 in Alpha + a = (int) (randf2(1.2f, 2.1f) * 60); + part->color = r | g<<8 | b<<16 | a<<24; if (d > State->galaxyRadius * 0.15f) { z *= 0.6f * (1.0f - id); @@ -80,14 +85,11 @@ void createParticle(struct Stars_s *star, struct Particles_s *part, float scale) // Map to the projection coordinates (viewport.x = -1.0 -> 1.0) d = mapf(-4.0f, State->galaxyRadius + 4.0f, 0.0f, scale, d); - star->angle = randf(TWO_PI); - star->distance = d; - star->speed = randf2(0.0015f, 0.0025f) * (0.5f + (scale / d)) * 0.8f; - star->s = cosf(p); - star->t = sinf(p); + part->position.x = randf(TWO_PI); + part->position.y = d; + gSpeed[idx] = randf2(0.0015f, 0.0025f) * (0.5f + (scale / d)) * 0.8f; - part->z = z / 5.0f; - part->pointSize = randf2(1.2f, 2.1f) * 6; + part->position.z = z / 5.0f; } /** @@ -98,15 +100,13 @@ void initParticles() { angle = 0.0f; } - struct Stars_s *star = Stars; struct Particles_s *part = Particles; int particlesCount = State->particlesCount; float scale = State->galaxyRadius / (State->width * 0.5f); int i; for (i = 0; i < particlesCount; i ++) { - createParticle(star, part, scale); - star++; + createParticle(part, i, scale); part++; } } @@ -121,7 +121,7 @@ void drawSpace(float xOffset, int width, int height) { } void drawLights(float xOffset, int width, int height) { - bindProgramVertex(NAMED_PVStars); + bindProgramVertex(NAMED_PVBkProj); bindProgramFragment(NAMED_PFBackground); bindTexture(NAMED_PFBackground, 0, NAMED_TLight1); @@ -158,26 +158,16 @@ void drawParticles(float xOffset, float offset, int width, int height) { vpLoadModelMatrix(matrix); // quadratic attenuation - pointAttenuation(0.1f + 0.3f * fabsf(offset), 0.0f, 0.06f + 0.1f * fabsf(offset)); + //pointAttenuation(0.1f + 0.3f * fabsf(offset), 0.0f, 0.06f + 0.1f * fabsf(offset)); int radius = State->galaxyRadius; int particlesCount = State->particlesCount; - struct Stars_s *star = Stars; struct Particles_s *vtx = Particles; int i = 0; for ( ; i < particlesCount; i++) { - float a = star->angle + star->speed; - float x = star->distance * sinf(a); - float y = star->distance * cosf(a) * ELLIPSE_RATIO; - - vtx->x = star->t * x + star->s * y + xOffset; - vtx->y = star->s * x - star->t * y; - - star->angle = a; - - star++; + vtx->position.x = vtx->position.x + gSpeed[i]; vtx++; } diff --git a/res/raw/grass.rs b/res/raw/grass.rs index f963791..563af1c 100644 --- a/res/raw/grass.rs +++ b/res/raw/grass.rs @@ -17,25 +17,8 @@ #pragma stateFragment(PFBackground) #pragma stateStore(PFSBackground) -#define RSID_STATE 0 -#define RSID_BLADES 1 #define RSID_BLADES_BUFFER 2 -#define BLADE_STRUCT_FIELDS_COUNT 13 -#define BLADE_STRUCT_ANGLE 0 -#define BLADE_STRUCT_SIZE 1 -#define BLADE_STRUCT_XPOS 2 -#define BLADE_STRUCT_YPOS 3 -#define BLADE_STRUCT_OFFSET 4 -#define BLADE_STRUCT_SCALE 5 -#define BLADE_STRUCT_LENGTHX 6 -#define BLADE_STRUCT_LENGTHY 7 -#define BLADE_STRUCT_HARDNESS 8 -#define BLADE_STRUCT_H 9 -#define BLADE_STRUCT_S 10 -#define BLADE_STRUCT_B 11 -#define BLADE_STRUCT_TURBULENCEX 12 - #define TESSELATION 0.5f #define HALF_TESSELATION 0.25f @@ -48,6 +31,21 @@ #define REAL_TIME 1 +void updateBlades() +{ + int bladesCount = State->bladesCount; + struct Blades_s *bladeStruct = Blades; + + int i; + for (i = 0; i < bladesCount; i ++) { + float xpos = randf2(-State->width, State->width); + bladeStruct->xPos = xpos; + bladeStruct->turbulencex = xpos * 0.006f; + bladeStruct->yPos = State->height; + bladeStruct++; + } +} + float time(int isPreview) { if (REAL_TIME && !isPreview) { return (hour() * 3600.0f + minute() * 60.0f + second()) / SECONDS_IN_DAY; @@ -88,91 +86,62 @@ void drawSunset(int width, int height) { drawRect(0.0f, 0.0f, width, height, 0.0f); } -int drawBlade(float *bladeStruct, float *bladeBuffer, int *bladeColor, +int drawBlade(struct Blades_s *bladeStruct, float *bladeBuffer, int *bladeColor, float brightness, float xOffset, float now) { - float offset = bladeStruct[BLADE_STRUCT_OFFSET]; - float scale = bladeStruct[BLADE_STRUCT_SCALE]; - float angle = bladeStruct[BLADE_STRUCT_ANGLE]; - float hardness = bladeStruct[BLADE_STRUCT_HARDNESS]; - float turbulenceX = bladeStruct[BLADE_STRUCT_TURBULENCEX]; - - float xpos = bladeStruct[BLADE_STRUCT_XPOS] + xOffset; - float ypos = bladeStruct[BLADE_STRUCT_YPOS]; + float scale = bladeStruct->scale; + float angle = bladeStruct->angle; + float xpos = bladeStruct->xPos + xOffset; + int size = bladeStruct->size; - float lengthX = bladeStruct[BLADE_STRUCT_LENGTHX]; - float lengthY = bladeStruct[BLADE_STRUCT_LENGTHY]; + int color = hsbToAbgr(bladeStruct->h, bladeStruct->s, + lerpf(0, bladeStruct->b, brightness), 1.0f); - int size = bladeStruct[BLADE_STRUCT_SIZE]; - - float h = bladeStruct[BLADE_STRUCT_H]; - float s = bladeStruct[BLADE_STRUCT_S]; - float b = bladeStruct[BLADE_STRUCT_B]; - - int color = hsbToAbgr(h, s, lerpf(0, b, brightness), 1.0f); - - float newAngle = (turbulencef2(turbulenceX, now, 4.0f) - 0.5f) * 0.5f; - angle = clampf(angle + (newAngle + offset - angle) * 0.15f, -MAX_BEND, MAX_BEND); + float newAngle = (turbulencef2(bladeStruct->turbulencex, now, 4.0f) - 0.5f) * 0.5f; + angle = clampf(angle + (newAngle + bladeStruct->offset - angle) * 0.15f, -MAX_BEND, MAX_BEND); float currentAngle = HALF_PI; float bottomX = xpos; - float bottomY = ypos; + float bottomY = bladeStruct->yPos; - float d = angle * hardness; + float d = angle * bladeStruct->hardness; - int triangles = size * 2; + + float si = size * scale; + float bottomLeft = bottomX - si; + float bottomRight = bottomX + si; + float bottom = bottomY + HALF_TESSELATION; + + bladeColor[0] = color; // V1.ABGR + bladeBuffer[1] = bottomLeft; // V1.X + bladeBuffer[2] = bottom; // V1.Y + bladeColor[5] = color; // V2.ABGR + bladeBuffer[6] = bottomRight; // V2.X + bladeBuffer[7] = bottom; // V2.Y + bladeBuffer += 10; + bladeColor += 10; for ( ; size > 0; size -= 1) { - float topX = bottomX - cosf_fast(currentAngle) * lengthX; - float topY = bottomY - sinf_fast(currentAngle) * lengthY; + float topX = bottomX - cosf_fast(currentAngle) * bladeStruct->lengthX; + float topY = bottomY - sinf_fast(currentAngle) * bladeStruct->lengthY; - float si = size * scale; + si = (float)size * scale; float spi = si - scale; - float bottomLeft = bottomX - si; - float bottomRight = bottomX + si; float topLeft = topX - spi; float topRight = topX + spi; - float bottom = bottomY + HALF_TESSELATION; - // First triangle bladeColor[0] = color; // V1.ABGR + bladeBuffer[1] = topLeft; // V2.X + bladeBuffer[2] = topY; // V2.Y - bladeBuffer[1] = bottomLeft; // V1.X - bladeBuffer[2] = bottom; // V1.Y - - bladeColor[5] = color; // V1.ABGR - - bladeBuffer[6] = topLeft; // V2.X - bladeBuffer[7] = topY; // V2.Y - - bladeColor[10] = color; // V3.ABGR - - bladeBuffer[11] = topRight; // V3.X - bladeBuffer[12] = topY; // V3.Y - - // Second triangle - bladeBuffer += 15; - bladeColor += 15; - - bladeColor[0] = color; // V1.ABGR - - bladeBuffer[1] = bottomLeft; // V1.X - bladeBuffer[2] = bottom; // V1.Y - - bladeColor[5] = color; // V2.ABGR - - bladeBuffer[6] = topRight; // V2.X - bladeBuffer[7] = topY; // V2.Y - - bladeColor[10] = color; // V3.ABGR - - bladeBuffer[11] = bottomRight; // V3.X - bladeBuffer[12] = bottom; // V3.Y + bladeColor[5] = color; // V3.ABGR + bladeBuffer[6] = topRight; // V3.X + bladeBuffer[7] = topY; // V3.Y - bladeBuffer += 15; - bladeColor += 15; + bladeBuffer += 10; + bladeColor += 10; bottomX = topX; bottomY = topY; @@ -180,21 +149,20 @@ int drawBlade(float *bladeStruct, float *bladeBuffer, int *bladeColor, currentAngle += d; } - bladeStruct[BLADE_STRUCT_ANGLE] = angle; + bladeStruct->angle = angle; - // 3 vertices per triangle, 5 properties per vertex (RGBA, X, Y, S, T) - return triangles * 15; + // 2 vertices per triangle, 5 properties per vertex (RGBA, X, Y, S, T) + return bladeStruct->size * 10 + 10; } void drawBlades(float brightness, float xOffset) { // For anti-aliasing - bindTexture(NAMED_PFBackground, 0, NAMED_TAa); + bindTexture(NAMED_PFGrass, 0, NAMED_TAa); int bladesCount = State->bladesCount; - int trianglesCount = State->trianglesCount; int i = 0; - float *bladeStruct = loadArrayF(RSID_BLADES, 0); + struct Blades_s *bladeStruct = Blades; float *bladeBuffer = loadArrayF(RSID_BLADES_BUFFER, 0); int *bladeColor = loadArrayI32(RSID_BLADES_BUFFER, 0); @@ -204,11 +172,11 @@ void drawBlades(float brightness, float xOffset) { int offset = drawBlade(bladeStruct, bladeBuffer, bladeColor, brightness, xOffset, now); bladeBuffer += offset; bladeColor += offset; - bladeStruct += BLADE_STRUCT_FIELDS_COUNT; + bladeStruct ++; } uploadToBufferObject(NAMED_BladesBuffer); - drawSimpleMeshRange(NAMED_BladesMesh, 0, trianglesCount * 3); + drawSimpleMeshRange(NAMED_BladesMesh, 0, State->indexCount); } int main(int launchID) { @@ -262,7 +230,8 @@ int main(int launchID) { newB = 0.0f; } + bindProgramFragment(NAMED_PFGrass); drawBlades(newB, x); - return 30; + return 50; } diff --git a/res/raw/nexus.rs b/res/raw/nexus.rs index 698529c..3b43411 100644 --- a/res/raw/nexus.rs +++ b/res/raw/nexus.rs @@ -14,7 +14,6 @@ #pragma version(1) #pragma stateVertex(PVOrtho) -#pragma stateFragment(PFTexture) #pragma stateStore(PSSolid) #define MAX_PULSES 20 @@ -48,18 +47,21 @@ int gNow; void setColor(int c) { - if (c == 0) { + if (State->mode == 1) { + // sholes red + color(0.9f, 0.1f, 0.1f, 0.8f); + } else if (c == 0) { // red - color(1.0f, 0.0f, 0.0f, 1.0f); + color(1.0f, 0.0f, 0.0f, 0.8f); } else if (c == 1) { // green - color(0.0f, 0.6f, 0.0f, 1.0f); + color(0.0f, 0.8f, 0.0f, 0.8f); } else if (c == 2) { // blue - color(0.0f, 0.4f, 0.8f, 1.0f); + color(0.0f, 0.4f, 0.9f, 0.8f); } else if (c == 3) { // yellow - color(1.0f, 0.8f, 0.0f, 1.0f); + color(1.0f, 0.8f, 0.0f, 0.8f); } } @@ -115,7 +117,8 @@ void initPulses() { } void drawBackground(int width, int height) { - bindTexture(NAMED_PFTexture, 0, NAMED_TBackground); + bindProgramFragment(NAMED_PFTexture565); + bindTexture(NAMED_PFTexture565, 0, NAMED_TBackground); color(1.0f, 1.0f, 1.0f, 1.0f); if (State->rotate) { drawRect(0.0f, 0.0f, height*2, width, 0.0f); @@ -267,8 +270,8 @@ int main(int index) { gNow = uptimeMillis(); if (Command->command != 0) { - debugF("x", Command->x); - debugF("y", Command->y); + //debugF("x", Command->x); + //debugF("y", Command->y); Command->command = 0; addTap(Command->x, Command->y); } diff --git a/res/values/integers.xml b/res/values/integers.xml new file mode 100644 index 0000000..db671b2 --- /dev/null +++ b/res/values/integers.xml @@ -0,0 +1,3 @@ +<resources> + <integer name="nexus_mode">0</integer> +</resources> |
