From 9cc290038ca3ee06ed34d172bbd139ea13bafd1b Mon Sep 17 00:00:00 2001 From: Alex Sakhartchouk Date: Tue, 21 Feb 2012 17:33:27 -0800 Subject: [PATCH] Properly pipe texture names through. Change-Id: I3e44c2757acee90539869c32771626cd0f770a25 --- tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl | 10 +++++----- tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl | 10 +++++----- .../RenderScriptTests/SceneGraph/res/raw/diffuse.glsl | 4 ++-- tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl | 4 ++-- tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl | 4 ++-- .../RenderScriptTests/SceneGraph/res/raw/plastic.glsl | 2 +- .../SceneGraph/res/raw/select_color.glsl | 2 +- .../RenderScriptTests/SceneGraph/res/raw/texture.glsl | 2 +- .../src/com/android/scenegraph/FragmentShader.java | 6 ++++-- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl index fa468cc3620cd..c34adc9e334db 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl @@ -3,13 +3,13 @@ varying vec2 varTex0; void main() { vec2 blurCoord = varTex0; blurCoord.x = varTex0.x + UNI_blurOffset0; - vec3 col = texture2D(UNI_Tex0, blurCoord).rgb; + vec3 col = texture2D(UNI_color, blurCoord).rgb; blurCoord.x = varTex0.x + UNI_blurOffset1; - col += texture2D(UNI_Tex0, blurCoord).rgb; + col += texture2D(UNI_color, blurCoord).rgb; blurCoord.x = varTex0.x + UNI_blurOffset2; - col += texture2D(UNI_Tex0, blurCoord).rgb; + col += texture2D(UNI_color, blurCoord).rgb; blurCoord.x = varTex0.x + UNI_blurOffset3; - col += texture2D(UNI_Tex0, blurCoord).rgb; + col += texture2D(UNI_color, blurCoord).rgb; - gl_FragColor = vec4(col * 0.25, 0.0); //texture2D(UNI_Tex0, varTex0); + gl_FragColor = vec4(col * 0.25, 0.0); } diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl index a644a3e6b8fb9..ade05a27920d1 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl @@ -3,15 +3,15 @@ varying vec2 varTex0; void main() { vec2 blurCoord = varTex0; blurCoord.y = varTex0.y + UNI_blurOffset0; - vec3 col = texture2D(UNI_Tex0, blurCoord).rgb; + vec3 col = texture2D(UNI_color, blurCoord).rgb; blurCoord.y = varTex0.y + UNI_blurOffset1; - col += texture2D(UNI_Tex0, blurCoord).rgb; + col += texture2D(UNI_color, blurCoord).rgb; blurCoord.y = varTex0.y + UNI_blurOffset2; - col += texture2D(UNI_Tex0, blurCoord).rgb; + col += texture2D(UNI_color, blurCoord).rgb; blurCoord.y = varTex0.y + UNI_blurOffset3; - col += texture2D(UNI_Tex0, blurCoord).rgb; + col += texture2D(UNI_color, blurCoord).rgb; col = col * 0.25; - gl_FragColor = vec4(col, 0.0); //texture2D(UNI_Tex0, varTex0); + gl_FragColor = vec4(col, 0.0); } diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/diffuse.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/diffuse.glsl index 5d8938bc5a4ea..2eb102872afdc 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/diffuse.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/diffuse.glsl @@ -12,8 +12,8 @@ void main() { float light0_Diffuse = dot(worldNorm, light0Vec); vec2 t0 = varTex0.xy; - lowp vec4 col = texture2D(UNI_Tex0, t0).rgba; + lowp vec4 col = texture2D(UNI_diffuse, t0).rgba; col.xyz = col.xyz * light0_Diffuse * 1.2; - gl_FragColor = col; //vec4(0.0, 1.0, 0.0, 0.0); + gl_FragColor = col; } diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl index 51f06124d7590..b90a7b27354cc 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl @@ -14,8 +14,8 @@ void main() { float light0_Specular = pow(light0Spec, 15.0) * 0.5; vec2 t0 = varTex0.xy; - lowp vec4 col = texture2D(UNI_Tex0, t0).rgba; - col.xyz = col.xyz * (textureCube(UNI_Tex1, worldNorm).rgb * 0.5 + vec3(light0_Diffuse)); + lowp vec4 col = texture2D(UNI_diffuse, t0).rgba; + col.xyz = col.xyz * (textureCube(UNI_reflection, worldNorm).rgb * 0.5 + vec3(light0_Diffuse)); col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0); gl_FragColor = col; diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl index 893d553990034..f3b89ede53698 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl @@ -14,12 +14,12 @@ void main() { float light0_Specular = pow(light0Spec, 150.0) * 0.5; vec2 t0 = varTex0.xy; - lowp vec4 col = texture2D(UNI_Tex0, t0).rgba; + lowp vec4 col = texture2D(UNI_diffuse, t0).rgba; col.xyz = col.xyz * light0_Diffuse * 1.1; col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0); float fresnel = mix(pow(1.0 - light0_Diffuse, 15.0), 1.0, 0.1); - col.xyz = mix(col.xyz, textureCube(UNI_Tex1, -light0R).rgb * 2.4, fresnel); + col.xyz = mix(col.xyz, textureCube(UNI_reflection, -light0R).rgb * 2.4, fresnel); col.w = 0.8; gl_FragColor = col; } diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/plastic.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/plastic.glsl index ceb53bd232d23..56f7151f22afd 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/plastic.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/plastic.glsl @@ -14,7 +14,7 @@ void main() { float light0_Specular = pow(light0Spec, 10.0) * 0.5; vec2 t0 = varTex0.xy; - lowp vec4 col = texture2D(UNI_Tex0, t0).rgba; + lowp vec4 col = texture2D(UNI_diffuse, t0).rgba; col.xyz = col.xyz * light0_Diffuse * 1.2; col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0); gl_FragColor = col; diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/select_color.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/select_color.glsl index 42b231aa86573..1a927cab62363 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/select_color.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/select_color.glsl @@ -1,7 +1,7 @@ varying vec2 varTex0; void main() { - vec3 col = texture2D(UNI_Tex0, varTex0).rgb; + vec3 col = texture2D(UNI_color, varTex0).rgb; vec3 desat = vec3(0.299, 0.587, 0.114); float lum = dot(desat, col); diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/texture.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/texture.glsl index dd709cf01f9dd..662ecd852af27 100644 --- a/tests/RenderScriptTests/SceneGraph/res/raw/texture.glsl +++ b/tests/RenderScriptTests/SceneGraph/res/raw/texture.glsl @@ -1,7 +1,7 @@ varying vec2 varTex0; void main() { - lowp vec4 col = texture2D(UNI_Tex0, varTex0).rgba; + lowp vec4 col = texture2D(UNI_color, varTex0).rgba; gl_FragColor = col; } diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java index c8e25feb8db73..8a468db9a1cf8 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java @@ -83,10 +83,12 @@ public class FragmentShader extends Shader { mBuilder.addConstant(mShader.mPerObjConstants); } for (int i = 0; i < mShader.mTextureTypes.size(); i ++) { - mBuilder.addTexture(mShader.mTextureTypes.get(i)); + mBuilder.addTexture(mShader.mTextureTypes.get(i), + mShader.mTextureNames.get(i)); } for (int i = 0; i < mShader.mShaderTextureTypes.size(); i ++) { - mBuilder.addTexture(mShader.mShaderTextureTypes.get(i)); + mBuilder.addTexture(mShader.mShaderTextureTypes.get(i), + mShader.mShaderTextureNames.get(i)); } mShader.mProgram = mBuilder.create();