Tweak the water and its texture
diff --git a/libs/rs/java/Fall/res/drawable-hdpi/sky.jpg b/libs/rs/java/Fall/res/drawable-hdpi/sky.jpg
old mode 100644
new mode 100755
index e628688..2508f0c
--- a/libs/rs/java/Fall/res/drawable-hdpi/sky.jpg
+++ b/libs/rs/java/Fall/res/drawable-hdpi/sky.jpg
Binary files differ
diff --git a/libs/rs/java/Fall/res/raw/fall.c b/libs/rs/java/Fall/res/raw/fall.c
index 3af3338..edfc926 100644
--- a/libs/rs/java/Fall/res/raw/fall.c
+++ b/libs/rs/java/Fall/res/raw/fall.c
@@ -13,7 +13,7 @@
// limitations under the License.
#pragma version(1)
-#pragma stateVertex(PVLines)
+#pragma stateVertex(PVSky)
#pragma stateFragment(PFBackground)
#pragma stateFragmentStore(PFSBackground)
@@ -276,32 +276,6 @@
}
}
-void drawNormals() {
- int width = loadI32(RSID_STATE, RSID_MESH_WIDTH);
- int height = loadI32(RSID_STATE, RSID_MESH_HEIGHT);
-
- float *vertices = loadTriangleMeshVerticesF(NAMED_mesh);
-
- bindProgramVertex(NAMED_PVLines);
- color(1.0f, 0.0f, 0.0f, 1.0f);
-
- int y = 0;
- for ( ; y < height; y++) {
- int yOffset = y * width;
- int x = 0;
- for ( ; x < width; x++) {
- int offset = (yOffset + x) * 8;
- float vx = vertices[offset + 5];
- float vy = vertices[offset + 6];
- float vz = vertices[offset + 7];
- float nx = vertices[offset + 0];
- float ny = vertices[offset + 1];
- float nz = vertices[offset + 2];
- drawLine(vx, vy, vz, vx + nx / 10.0f, vy + ny / 10.0f, vz + nz / 10.0f);
- }
- }
-}
-
float averageZ(float x1, float x2, float y1, float y2, float* vertices,
int meshWidth, int meshHeight, float glWidth, float glHeight) {
@@ -481,16 +455,12 @@
shininess(40.0f);
bindProgramFragmentStore(NAMED_PFSBackground);
bindProgramFragment(NAMED_PFLighting);
- bindProgramVertex(NAMED_PVBackground);
+ bindProgramVertex(NAMED_PVLight);
drawTriangleMesh(NAMED_mesh);
- bindProgramVertex(NAMED_PVLines);
+ bindProgramVertex(NAMED_PVSky);
drawLeaves(frameCount);
- if (!isRunning) {
- drawNormals();
- }
-
frameCount++;
storeI32(RSID_STATE, RSID_FRAME_COUNT, frameCount);
diff --git a/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java b/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java
index 3e2bdbf..b4f96f3 100644
--- a/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java
+++ b/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java
@@ -27,7 +27,7 @@
import android.renderscript.Element;
import android.renderscript.Light;
import static android.renderscript.Sampler.Value.LINEAR;
-import static android.renderscript.Sampler.Value.CLAMP;
+import static android.renderscript.Sampler.Value.WRAP;
import static android.renderscript.ProgramStore.DepthFunc.*;
import static android.renderscript.ProgramStore.BlendDstFunc;
import static android.renderscript.ProgramStore.BlendSrcFunc;
@@ -101,8 +101,8 @@
private ProgramFragment mPfSky;
private ProgramStore mPfsBackground;
private ProgramStore mPfsLeaf;
- private ProgramVertex mPvBackground;
- private ProgramVertex mPvLines;
+ private ProgramVertex mPvLight;
+ private ProgramVertex mPvSky;
private ProgramVertex.MatrixAllocation mPvOrthoAlloc;
private Light mLight;
@@ -120,6 +120,8 @@
private Allocation mGlState;
private float mGlHeight;
+ private final int[] mIntData2 = new int[2];
+
public FallRS(int width, int height) {
mWidth = width;
mHeight = height;
@@ -138,7 +140,7 @@
mSampler.destroy();
mPfBackground.destroy();
mPfsBackground.destroy();
- mPvBackground.destroy();
+ mPvLight.destroy();
mPvOrthoAlloc.mAlloc.destroy();
for (Allocation a : mTextures) {
a.destroy();
@@ -148,7 +150,7 @@
mLight.destroy();
mRippleMap.destroy();
mRefractionMap.destroy();
- mPvLines.destroy();
+ mPvSky.destroy();
mPfLighting.destroy();
mLeaves.destroy();
mPfsLeaf.destroy();
@@ -353,8 +355,8 @@
Sampler.Builder sampleBuilder = new Sampler.Builder(mRS);
sampleBuilder.setMin(LINEAR);
sampleBuilder.setMag(LINEAR);
- sampleBuilder.setWrapS(CLAMP);
- sampleBuilder.setWrapT(CLAMP);
+ sampleBuilder.setWrapS(WRAP);
+ sampleBuilder.setWrapT(WRAP);
mSampler = sampleBuilder.create();
ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null);
@@ -406,20 +408,20 @@
ProgramVertex.Builder builder = new ProgramVertex.Builder(mRS, null, null);
builder.setTextureMatrixEnable(true);
builder.addLight(mLight);
- mPvBackground = builder.create();
- mPvBackground.bindAllocation(mPvOrthoAlloc);
- mPvBackground.setName("PVBackground");
+ mPvLight = builder.create();
+ mPvLight.bindAllocation(mPvOrthoAlloc);
+ mPvLight.setName("PVLight");
builder = new ProgramVertex.Builder(mRS, null, null);
- mPvLines = builder.create();
- mPvLines.bindAllocation(mPvOrthoAlloc);
- mPvLines.setName("PVLines");
+ mPvSky = builder.create();
+ mPvSky.bindAllocation(mPvOrthoAlloc);
+ mPvSky.setName("PVSky");
}
void addDrop(float x, float y) {
- mState.subData1D(RSID_STATE_DROP_X, 2, new int[] {
- (int) ((x / mWidth) * mMeshWidth), (int) ((y / mHeight) * mMeshHeight)
- });
+ mIntData2[0] = (int) ((x / mWidth) * mMeshWidth);
+ mIntData2[1] = (int) ((y / mHeight) * mMeshHeight);
+ mState.subData1D(RSID_STATE_DROP_X, 2, mIntData2);
}
void togglePause() {