Bladeren bron

Merge pull request #1692 from seanpaultaylor/next

iOS fixes for samples
Sean Taylor 11 jaren geleden
bovenliggende
commit
0c0dc45ddd

+ 1 - 1
gameplay/src/Node.cpp

@@ -1010,7 +1010,7 @@ AudioSource* Node::getAudioSource() const
 
 
 void Node::setAudioSource(AudioSource* audio)
 void Node::setAudioSource(AudioSource* audio)
 {
 {
-    if (_audioSource != audio)
+    if (_audioSource == audio)
         return;
         return;
 
 
     if (_audioSource)
     if (_audioSource)

+ 15 - 20
samples/browser/res/common/water/watersample.frag

@@ -1,23 +1,19 @@
 #ifdef OPENGL_ES
 #ifdef OPENGL_ES
-precision mediump float;
+precision highp float;
 #endif
 #endif
 
 
 //////////////////////////
 //////////////////////////
 // Uniforms
 // Uniforms
 uniform sampler2D u_refractionTexture;
 uniform sampler2D u_refractionTexture;
 uniform sampler2D u_reflectionTexture;
 uniform sampler2D u_reflectionTexture;
-
 uniform sampler2D u_normalMap;
 uniform sampler2D u_normalMap;
-
 uniform float u_time;
 uniform float u_time;
 
 
 //////////////////////////
 //////////////////////////
 // Varyings
 // Varyings
 varying vec4 v_vertexRefractionPosition;
 varying vec4 v_vertexRefractionPosition;
 varying vec4 v_vertexReflectionPosition;
 varying vec4 v_vertexReflectionPosition;
-
 varying vec2 v_texCoord;
 varying vec2 v_texCoord;
-
 varying vec3 v_eyePosition;
 varying vec3 v_eyePosition;
 
 
 //////////////////////////
 //////////////////////////
@@ -25,11 +21,9 @@ varying vec3 v_eyePosition;
 const float distortAmount = 0.05;
 const float distortAmount = 0.05;
 const float specularAmount = 2.5;
 const float specularAmount = 2.5;
 const float textureRepeat = 2.0;
 const float textureRepeat = 2.0;
-
 const vec4 tangent = vec4(1.0, 0.0, 0.0, 0.0);
 const vec4 tangent = vec4(1.0, 0.0, 0.0, 0.0);
 const vec4 viewNormal = vec4(0.0, 1.0, 0.0, 0.0);
 const vec4 viewNormal = vec4(0.0, 1.0, 0.0, 0.0);
 const vec4 bitangent = vec4(0.0, 0.0, 1.0, 0.0);
 const vec4 bitangent = vec4(0.0, 0.0, 1.0, 0.0);
-
 const vec4 waterColour = vec4(0.36, 0.32, 0.2,1.0);
 const vec4 waterColour = vec4(0.36, 0.32, 0.2,1.0);
 
 
 vec2 fromClipSpace(vec4 position)
 vec2 fromClipSpace(vec4 position)
@@ -39,39 +33,40 @@ vec2 fromClipSpace(vec4 position)
 
 
 void main()
 void main()
 {	
 {	
-    //get normal
+    // Get normal
     vec4 normal = texture2D(u_normalMap, v_texCoord * textureRepeat + u_time);
     vec4 normal = texture2D(u_normalMap, v_texCoord * textureRepeat + u_time);
     normal = normalize(normal * 2.0 - 1.0);
     normal = normalize(normal * 2.0 - 1.0);
     
     
-    //distortion offset
+    // Distortion offset
     vec4 dudv = normal * distortAmount;
     vec4 dudv = normal * distortAmount;
 
 
-    //refraction sample
+    // Refraction sample
     vec2 textureCoord = fromClipSpace(v_vertexRefractionPosition) + dudv.rg;
     vec2 textureCoord = fromClipSpace(v_vertexRefractionPosition) + dudv.rg;
     textureCoord = clamp(textureCoord, 0.001, 0.999);
     textureCoord = clamp(textureCoord, 0.001, 0.999);
     vec4 refractionColour = texture2D(u_refractionTexture, textureCoord) * waterColour;
     vec4 refractionColour = texture2D(u_refractionTexture, textureCoord) * waterColour;
 
 
-    //calc fog distance
-    //----version 1 (exponential)----//
+    // Calc fog distance
+    
+    // Version 1 (linear)
+    float z = (gl_FragCoord.z / gl_FragCoord.w) / 300.0; //const is max fog distance
+    const float fogDensity = 6.0;
+    float fogAmount = z * fogDensity;
+    fogAmount = clamp(fogAmount, 0.0, 1.0);
+    
+    // Version 2 (exponential)
     //float z = gl_FragCoord.z / gl_FragCoord.w;
     //float z = gl_FragCoord.z / gl_FragCoord.w;
     //const float fogDensity = 0.0005;
     //const float fogDensity = 0.0005;
     //float fogAmount = exp2(-fogDensity * fogDensity * z * z * 1.442695);
     //float fogAmount = exp2(-fogDensity * fogDensity * z * z * 1.442695);
     //fogAmount = clamp(fogAmount, 0.0, 0.7);
     //fogAmount = clamp(fogAmount, 0.0, 0.7);
 
 
-    //----version 2 (linear)----//
-    float z = (gl_FragCoord.z / gl_FragCoord.w) / 300.0; //const is max fog distance
-    const float fogDensity = 6.0;
-    float fogAmount = z * fogDensity;	
-    fogAmount = clamp(fogAmount, 0.0, 1.0);
-
     refractionColour = mix(refractionColour, waterColour, fogAmount);
     refractionColour = mix(refractionColour, waterColour, fogAmount);
 
 
-    //reflection sample
+    // Sample reflection
     textureCoord = fromClipSpace(v_vertexReflectionPosition) + dudv.rg;
     textureCoord = fromClipSpace(v_vertexReflectionPosition) + dudv.rg;
     textureCoord = clamp(textureCoord, 0.001, 0.999);	
     textureCoord = clamp(textureCoord, 0.001, 0.999);	
     vec4 reflectionColour = texture2D(u_reflectionTexture, textureCoord);
     vec4 reflectionColour = texture2D(u_reflectionTexture, textureCoord);
 
 
-    //put view in tangent space
+    // View in tangent space
     vec4 viewDir = normalize(vec4(v_eyePosition, 1.0));
     vec4 viewDir = normalize(vec4(v_eyePosition, 1.0));
     vec4 viewTanSpace = normalize(vec4(dot(viewDir, tangent), dot(viewDir, bitangent), dot(viewDir, viewNormal), 1.0));	
     vec4 viewTanSpace = normalize(vec4(dot(viewDir, tangent), dot(viewDir, bitangent), dot(viewDir, viewNormal), 1.0));	
     vec4 viewReflection = normalize(reflect(-1.0 * viewTanSpace, normal));
     vec4 viewReflection = normalize(reflect(-1.0 * viewTanSpace, normal));

+ 7 - 7
samples/browser/res/common/water/watersample.material

@@ -13,17 +13,17 @@ material ground
             u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX
             u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX
             
             
             u_ambientColor = SCENE_AMBIENT_COLOR
             u_ambientColor = SCENE_AMBIENT_COLOR
-	    u_directionalLightColor[0] = 1, 1, 1
+	        u_directionalLightColor[0] = 1, 1, 1
             
             
             sampler u_diffuseTexture
             sampler u_diffuseTexture
             {
             {
             	mipmap = true
             	mipmap = true
-	    	wrapS = REPEAT
-	    	wrapT = REPEAT
-	    	minFilter = LINEAR_MIPMAP_LINEAR
-		magFilter = LINEAR
-		
-		path = res/common/water/water_sample.png
+                wrapS = REPEAT
+                wrapT = REPEAT
+                minFilter = LINEAR_MIPMAP_LINEAR
+                magFilter = LINEAR
+
+                path = res/common/water/water_sample.png
             }
             }
             
             
             renderState
             renderState

+ 1 - 4
samples/browser/res/common/water/watersample.vert

@@ -8,19 +8,16 @@ attribute vec2 a_texCoord;
 uniform mat4 u_worldMatrix;
 uniform mat4 u_worldMatrix;
 uniform mat4 u_worldViewProjectionMatrix;
 uniform mat4 u_worldViewProjectionMatrix;
 uniform mat4 u_worldViewProjectionReflectionMatrix;
 uniform mat4 u_worldViewProjectionReflectionMatrix;
-
 uniform vec3 u_cameraPosition;
 uniform vec3 u_cameraPosition;
 
 
 /////////////////////////////
 /////////////////////////////
 // Varyings
 // Varyings
 varying vec4 v_vertexRefractionPosition;
 varying vec4 v_vertexRefractionPosition;
 varying vec4 v_vertexReflectionPosition;
 varying vec4 v_vertexReflectionPosition;
-
 varying vec2 v_texCoord;
 varying vec2 v_texCoord;
-
 varying vec3 v_eyePosition;
 varying vec3 v_eyePosition;
 
 
-/////////////////////////////
+
 void main()
 void main()
 {
 {
     v_vertexRefractionPosition = u_worldViewProjectionMatrix * a_position;
     v_vertexRefractionPosition = u_worldViewProjectionMatrix * a_position;

+ 0 - 1
samples/browser/src/Audio3DSample.cpp

@@ -12,7 +12,6 @@ static const unsigned int MOVE_LEFT = 4;
 static const unsigned int MOVE_RIGHT = 8;
 static const unsigned int MOVE_RIGHT = 8;
 static const unsigned int MOVE_UP = 16;
 static const unsigned int MOVE_UP = 16;
 static const unsigned int MOVE_DOWN = 32;
 static const unsigned int MOVE_DOWN = 32;
-
 static const float MOVE_SPEED = 15.0f;
 static const float MOVE_SPEED = 15.0f;
 static const float UP_DOWN_SPEED = 10.0f;
 static const float UP_DOWN_SPEED = 10.0f;
 
 

+ 4 - 3
samples/browser/src/TerrainSample.cpp

@@ -156,16 +156,17 @@ void TerrainSample::render(float elapsedTime)
 bool TerrainSample::drawScene(Node* node)
 bool TerrainSample::drawScene(Node* node)
 {
 {
     Camera* camera = _scene->getActiveCamera();
     Camera* camera = _scene->getActiveCamera();
-
     Drawable* drawable = node->getDrawable();
     Drawable* drawable = node->getDrawable();
     if (dynamic_cast<Model*>(drawable))
     if (dynamic_cast<Model*>(drawable))
     {
     {
         if (!node->getBoundingSphere().intersects(camera->getFrustum()))
         if (!node->getBoundingSphere().intersects(camera->getFrustum()))
             return true;
             return true;
     }
     }
-
     if (drawable)
     if (drawable)
-        drawable->draw(_wireframe);
+    {
+        bool wireframe = (node == _sky) ? false : _wireframe;
+        drawable->draw(wireframe);
+    }
 
 
 	return true;
 	return true;
 }
 }