diff options
author | Alex Sakhartchouk <alexst@google.com> | 2012-03-08 14:25:56 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-03-08 14:25:56 -0800 |
commit | c53254ec92260a01605b96bd147c03c267641682 (patch) | |
tree | 14c630160e8d2e20caf268499e92bd55228b62e1 /tests | |
parent | ae8945ab23f50271d5d70210f52e3196a7db0f80 (diff) | |
parent | b23b58ad343ccbf8835c7067698a60fc6bc1a870 (diff) | |
download | frameworks_base-c53254ec92260a01605b96bd147c03c267641682.zip frameworks_base-c53254ec92260a01605b96bd147c03c267641682.tar.gz frameworks_base-c53254ec92260a01605b96bd147c03c267641682.tar.bz2 |
Merge "Enable AA in scenegraph. Minor shader work in sample."
Diffstat (limited to 'tests')
6 files changed, 44 insertions, 2 deletions
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/diffuse_lights.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/diffuse_lights.glsl new file mode 100644 index 0000000..ef93e1c --- /dev/null +++ b/tests/RenderScriptTests/SceneGraph/res/raw/diffuse_lights.glsl @@ -0,0 +1,22 @@ +varying vec3 varWorldPos; +varying vec3 varWorldNormal; +varying vec2 varTex0; + +void main() { + + vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz); + vec3 worldNorm = normalize(varWorldNormal); + + vec3 light0Vec = normalize(UNI_lightPos_0.xyz - varWorldPos.xyz); + float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0); + + vec3 light1Vec = normalize(UNI_lightPos_1.xyz - varWorldPos.xyz); + float light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0); + + vec2 t0 = varTex0.xy; + lowp vec4 col = UNI_diffuse; + col.xyz = col.xyz * (light0_Diffuse * UNI_lightColor_0.xyz + + light1_Diffuse * UNI_lightColor_1.xyz); + gl_FragColor = col; +} + diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/shader2v.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/shader2v.glsl index 1ea234f..7910a54 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/shader2v.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/shader2v.glsl @@ -1,3 +1,8 @@ +/* + rs_matrix4x4 model; + rs_matrix4x4 viewProj; +*/ + varying vec3 varWorldPos; varying vec3 varWorldNormal; varying vec2 varTex0; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppView.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppView.java index 053e545..2112181 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppView.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppView.java @@ -41,6 +41,7 @@ public class SimpleAppView extends RSSurfaceView { if (mRS == null) { RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); sc.setDepth(16, 24); + sc.setSamples(1, 2, 1); mRS = createRenderScriptGL(sc); mRS.setSurface(holder, w, h); mRender = new SimpleAppRS(); diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java index f159e85..3aa80f4 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java @@ -65,6 +65,7 @@ public class TestAppRS { // Shaders private FragmentShader mPaintF; private FragmentShader mLightsF; + private FragmentShader mLightsDiffF; private FragmentShader mAluminumF; private FragmentShader mPlasticF; private FragmentShader mDiffuseF; @@ -173,6 +174,11 @@ public class TestAppRS { fb.setShader(mRes, R.raw.plastic_lights); mLightsF = fb.create(); + fb = new FragmentShader.Builder(mRS); + fb.setObjectConst(lightParams.getAllocation().getType()); + fb.setShader(mRes, R.raw.diffuse_lights); + mLightsDiffF = fb.create(); + FullscreenBlur.initShaders(mRes, mRS); } @@ -203,6 +209,7 @@ public class TestAppRS { private void addShadersToScene() { mActiveScene.appendShader(mPaintF); mActiveScene.appendShader(mLightsF); + mActiveScene.appendShader(mLightsDiffF); mActiveScene.appendShader(mAluminumF); mActiveScene.appendShader(mPlasticF); mActiveScene.appendShader(mDiffuseF); @@ -219,8 +226,12 @@ public class TestAppRS { RenderState paint = new RenderState(mGenericV, mPaintF, null, null); RenderState aluminum = new RenderState(mGenericV, mAluminumF, null, null); RenderState lights = new RenderState(mGenericV, mLightsF, null, null); + RenderState diff_lights = new RenderState(mGenericV, mLightsDiffF, null, null); + RenderState diff_lights_no_cull = new RenderState(mGenericV, mLightsDiffF, null, + ProgramRaster.CULL_NONE(mRS)); RenderState glassTransp = new RenderState(mGenericV, mPaintF, ProgramStore.BLEND_ALPHA_DEPTH_TEST(mRS), null); + RenderState texState = new RenderState(mGenericV, mTextureF, null, null); initRenderPasses(); @@ -239,10 +250,12 @@ public class TestAppRS { mActiveScene.assignRenderStateToMaterial(glassTransp, "^GlassLight"); mActiveScene.assignRenderStateToMaterial(lights, "^LightBlinn"); + mActiveScene.assignRenderStateToMaterial(diff_lights, "^LightLambert"); + mActiveScene.assignRenderStateToMaterial(diff_lights_no_cull, "^LightLambertNoCull"); + mActiveScene.assignRenderStateToMaterial(texState, "^TextureOnly"); Renderable plane = (Renderable)mActiveScene.getRenderableByName("pPlaneShape1"); if (plane != null) { - RenderState texState = new RenderState(mGenericV, mTextureF, null, null); plane.setRenderState(texState); plane.setVisible(!mUseBlur); } diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java index 687f35b..33ca1b8 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java @@ -59,6 +59,7 @@ public class TestAppView extends RSSurfaceView { if (mRS == null) { RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); sc.setDepth(16, 24); + sc.setSamples(1, 2, 1); mRS = createRenderScriptGL(sc); mRS.setSurface(holder, w, h); mRender = new TestAppRS(); diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java index e272cc5..d0f9797 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java @@ -43,7 +43,7 @@ public class TouchHandler { public void init(Scene scene) { // Some initial values for camera position mRotateXValue = -20; - mRotateYValue = 45; + mRotateYValue = 0; mDistValue = new Float3(0, 0, 45); mPosValue = new Float3(0, 4, 0); |