Merge change 21847 into eclair
* changes: Tweak the water and its texture
This commit is contained in:
BIN
libs/rs/java/Fall/res/drawable-hdpi/sky.jpg
Normal file → Executable file
BIN
libs/rs/java/Fall/res/drawable-hdpi/sky.jpg
Normal file → Executable file
Binary file not shown.
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 89 KiB |
@@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#pragma version(1)
|
#pragma version(1)
|
||||||
#pragma stateVertex(PVLines)
|
#pragma stateVertex(PVSky)
|
||||||
#pragma stateFragment(PFBackground)
|
#pragma stateFragment(PFBackground)
|
||||||
#pragma stateFragmentStore(PFSBackground)
|
#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,
|
float averageZ(float x1, float x2, float y1, float y2, float* vertices,
|
||||||
int meshWidth, int meshHeight, float glWidth, float glHeight) {
|
int meshWidth, int meshHeight, float glWidth, float glHeight) {
|
||||||
|
|
||||||
@@ -481,16 +455,12 @@ int main(int index) {
|
|||||||
shininess(40.0f);
|
shininess(40.0f);
|
||||||
bindProgramFragmentStore(NAMED_PFSBackground);
|
bindProgramFragmentStore(NAMED_PFSBackground);
|
||||||
bindProgramFragment(NAMED_PFLighting);
|
bindProgramFragment(NAMED_PFLighting);
|
||||||
bindProgramVertex(NAMED_PVBackground);
|
bindProgramVertex(NAMED_PVLight);
|
||||||
drawTriangleMesh(NAMED_mesh);
|
drawTriangleMesh(NAMED_mesh);
|
||||||
|
|
||||||
bindProgramVertex(NAMED_PVLines);
|
bindProgramVertex(NAMED_PVSky);
|
||||||
drawLeaves(frameCount);
|
drawLeaves(frameCount);
|
||||||
|
|
||||||
if (!isRunning) {
|
|
||||||
drawNormals();
|
|
||||||
}
|
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
storeI32(RSID_STATE, RSID_FRAME_COUNT, frameCount);
|
storeI32(RSID_STATE, RSID_FRAME_COUNT, frameCount);
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import android.renderscript.Sampler;
|
|||||||
import android.renderscript.Element;
|
import android.renderscript.Element;
|
||||||
import android.renderscript.Light;
|
import android.renderscript.Light;
|
||||||
import static android.renderscript.Sampler.Value.LINEAR;
|
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.DepthFunc.*;
|
||||||
import static android.renderscript.ProgramStore.BlendDstFunc;
|
import static android.renderscript.ProgramStore.BlendDstFunc;
|
||||||
import static android.renderscript.ProgramStore.BlendSrcFunc;
|
import static android.renderscript.ProgramStore.BlendSrcFunc;
|
||||||
@@ -101,8 +101,8 @@ class FallRS {
|
|||||||
private ProgramFragment mPfSky;
|
private ProgramFragment mPfSky;
|
||||||
private ProgramStore mPfsBackground;
|
private ProgramStore mPfsBackground;
|
||||||
private ProgramStore mPfsLeaf;
|
private ProgramStore mPfsLeaf;
|
||||||
private ProgramVertex mPvBackground;
|
private ProgramVertex mPvLight;
|
||||||
private ProgramVertex mPvLines;
|
private ProgramVertex mPvSky;
|
||||||
private ProgramVertex.MatrixAllocation mPvOrthoAlloc;
|
private ProgramVertex.MatrixAllocation mPvOrthoAlloc;
|
||||||
private Light mLight;
|
private Light mLight;
|
||||||
|
|
||||||
@@ -120,6 +120,8 @@ class FallRS {
|
|||||||
private Allocation mGlState;
|
private Allocation mGlState;
|
||||||
private float mGlHeight;
|
private float mGlHeight;
|
||||||
|
|
||||||
|
private final int[] mIntData2 = new int[2];
|
||||||
|
|
||||||
public FallRS(int width, int height) {
|
public FallRS(int width, int height) {
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
@@ -138,7 +140,7 @@ class FallRS {
|
|||||||
mSampler.destroy();
|
mSampler.destroy();
|
||||||
mPfBackground.destroy();
|
mPfBackground.destroy();
|
||||||
mPfsBackground.destroy();
|
mPfsBackground.destroy();
|
||||||
mPvBackground.destroy();
|
mPvLight.destroy();
|
||||||
mPvOrthoAlloc.mAlloc.destroy();
|
mPvOrthoAlloc.mAlloc.destroy();
|
||||||
for (Allocation a : mTextures) {
|
for (Allocation a : mTextures) {
|
||||||
a.destroy();
|
a.destroy();
|
||||||
@@ -148,7 +150,7 @@ class FallRS {
|
|||||||
mLight.destroy();
|
mLight.destroy();
|
||||||
mRippleMap.destroy();
|
mRippleMap.destroy();
|
||||||
mRefractionMap.destroy();
|
mRefractionMap.destroy();
|
||||||
mPvLines.destroy();
|
mPvSky.destroy();
|
||||||
mPfLighting.destroy();
|
mPfLighting.destroy();
|
||||||
mLeaves.destroy();
|
mLeaves.destroy();
|
||||||
mPfsLeaf.destroy();
|
mPfsLeaf.destroy();
|
||||||
@@ -353,8 +355,8 @@ class FallRS {
|
|||||||
Sampler.Builder sampleBuilder = new Sampler.Builder(mRS);
|
Sampler.Builder sampleBuilder = new Sampler.Builder(mRS);
|
||||||
sampleBuilder.setMin(LINEAR);
|
sampleBuilder.setMin(LINEAR);
|
||||||
sampleBuilder.setMag(LINEAR);
|
sampleBuilder.setMag(LINEAR);
|
||||||
sampleBuilder.setWrapS(CLAMP);
|
sampleBuilder.setWrapS(WRAP);
|
||||||
sampleBuilder.setWrapT(CLAMP);
|
sampleBuilder.setWrapT(WRAP);
|
||||||
mSampler = sampleBuilder.create();
|
mSampler = sampleBuilder.create();
|
||||||
|
|
||||||
ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null);
|
ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null);
|
||||||
@@ -406,20 +408,20 @@ class FallRS {
|
|||||||
ProgramVertex.Builder builder = new ProgramVertex.Builder(mRS, null, null);
|
ProgramVertex.Builder builder = new ProgramVertex.Builder(mRS, null, null);
|
||||||
builder.setTextureMatrixEnable(true);
|
builder.setTextureMatrixEnable(true);
|
||||||
builder.addLight(mLight);
|
builder.addLight(mLight);
|
||||||
mPvBackground = builder.create();
|
mPvLight = builder.create();
|
||||||
mPvBackground.bindAllocation(mPvOrthoAlloc);
|
mPvLight.bindAllocation(mPvOrthoAlloc);
|
||||||
mPvBackground.setName("PVBackground");
|
mPvLight.setName("PVLight");
|
||||||
|
|
||||||
builder = new ProgramVertex.Builder(mRS, null, null);
|
builder = new ProgramVertex.Builder(mRS, null, null);
|
||||||
mPvLines = builder.create();
|
mPvSky = builder.create();
|
||||||
mPvLines.bindAllocation(mPvOrthoAlloc);
|
mPvSky.bindAllocation(mPvOrthoAlloc);
|
||||||
mPvLines.setName("PVLines");
|
mPvSky.setName("PVSky");
|
||||||
}
|
}
|
||||||
|
|
||||||
void addDrop(float x, float y) {
|
void addDrop(float x, float y) {
|
||||||
mState.subData1D(RSID_STATE_DROP_X, 2, new int[] {
|
mIntData2[0] = (int) ((x / mWidth) * mMeshWidth);
|
||||||
(int) ((x / mWidth) * mMeshWidth), (int) ((y / mHeight) * mMeshHeight)
|
mIntData2[1] = (int) ((y / mHeight) * mMeshHeight);
|
||||||
});
|
mState.subData1D(RSID_STATE_DROP_X, 2, mIntData2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void togglePause() {
|
void togglePause() {
|
||||||
|
|||||||
Reference in New Issue
Block a user