Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a1f350c authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 21847 into eclair

* changes:
  Tweak the water and its texture
parents 7b6771a9 8a947bd6
Loading
Loading
Loading
Loading
−6.06 KiB (88.6 KiB)
Loading image diff...
+3 −33
Original line number Diff line number Diff line
@@ -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 generateRipples() {
    }
}

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 @@ int main(int index) {
    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);

+18 −16
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import android.renderscript.Sampler;
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 @@ class FallRS {
    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 @@ class FallRS {
    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 @@ class FallRS {
        mSampler.destroy();
        mPfBackground.destroy();
        mPfsBackground.destroy();
        mPvBackground.destroy();
        mPvLight.destroy();
        mPvOrthoAlloc.mAlloc.destroy();
        for (Allocation a : mTextures) {
            a.destroy();
@@ -148,7 +150,7 @@ class FallRS {
        mLight.destroy();
        mRippleMap.destroy();
        mRefractionMap.destroy();
        mPvLines.destroy();
        mPvSky.destroy();
        mPfLighting.destroy();
        mLeaves.destroy();
        mPfsLeaf.destroy();
@@ -353,8 +355,8 @@ class FallRS {
        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 @@ class FallRS {
        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() {