Changed Terrain Shader -> Terrain now has custom edges
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
</terrainTiles>
|
||||
<ceilingTiles class="java.util.ArrayList">
|
||||
<tileData x="6.436699" width="18.873398"/>
|
||||
<tileData x="20.385015" width="9.023236"/>
|
||||
</ceilingTiles>
|
||||
<obstacles class="java.util.ArrayList">
|
||||
<obstacleData floating="false" moving="false" deadly="false" leftEdge="2.3533306" rightEdge="5.3533306" height="0.331" y="-0.43450004">
|
||||
@@ -247,7 +246,6 @@
|
||||
</terrainTiles>
|
||||
<ceilingTiles class="java.util.ArrayList">
|
||||
<tileData x="2.700005" width="11.40001"/>
|
||||
<tileData x="17.183376" width="16.56669"/>
|
||||
</ceilingTiles>
|
||||
<obstacles class="java.util.ArrayList">
|
||||
<obstacleData floating="false" moving="false" deadly="false" leftEdge="1.656666" rightEdge="1.8566661" height="0.815" y="-0.19250003">
|
||||
|
@@ -7,12 +7,10 @@
|
||||
<tileData x="8.559853" width="0.42468548"/>
|
||||
<tileData x="14.852292" width="3.8621922"/>
|
||||
<tileData x="19.439503" width="4.192238"/>
|
||||
<tileData x="24.228848" width="3.6224518"/>
|
||||
<tileData x="28.089983" width="4.099819"/>
|
||||
<tileData x="26.278606" width="7.721974"/>
|
||||
</terrainTiles>
|
||||
<ceilingTiles class="java.util.ArrayList">
|
||||
<tileData x="11.520037" width="29.040073"/>
|
||||
<tileData x="26.26674" width="0.45332718"/>
|
||||
</ceilingTiles>
|
||||
<obstacles class="java.util.ArrayList">
|
||||
<obstacleData floating="true" moving="true" deadly="true" leftEdge="0.65783304" rightEdge="0.988833" height="0.51" y="-0.34500003">
|
||||
@@ -167,7 +165,6 @@
|
||||
</terrainTiles>
|
||||
<ceilingTiles class="java.util.ArrayList">
|
||||
<tileData x="8.863336" width="23.726671"/>
|
||||
<tileData x="23.293339" width="5.1333294"/>
|
||||
</ceilingTiles>
|
||||
<obstacles class="java.util.ArrayList">
|
||||
<obstacleData floating="true" moving="true" deadly="false" leftEdge="-0.34966657" rightEdge="0.23633346" height="0.344" y="-0.91999984">
|
||||
@@ -435,5 +432,18 @@
|
||||
</stars>
|
||||
<energy x="18.570074" y="0.46666658"/>
|
||||
</level>
|
||||
<level packId="2" id="7" goalX="3.0" startSpeed="0.5" endSpeed="0.5" terrainEdge="-0.6" ceilingEdge="1.0">
|
||||
<terrainTiles class="java.util.ArrayList">
|
||||
<tileData x="0.0" width="6.0"/>
|
||||
</terrainTiles>
|
||||
<ceilingTiles class="java.util.ArrayList">
|
||||
<tileData x="0.0" width="6.0"/>
|
||||
</ceilingTiles>
|
||||
<obstacles class="java.util.ArrayList"/>
|
||||
<stars class="java.util.ArrayList">
|
||||
<positionData x="0.3066666" y="-0.37999997"/>
|
||||
</stars>
|
||||
<energy x="1.9466664" y="-0.3933333"/>
|
||||
</level>
|
||||
</levels>
|
||||
</levelPack>
|
46
app/src/main/assets/shader/terrainFragmentShader.glsl
Normal file
46
app/src/main/assets/shader/terrainFragmentShader.glsl
Normal file
@@ -0,0 +1,46 @@
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform float gridColumnCount;
|
||||
uniform float isEndlessTileList;
|
||||
|
||||
varying vec2 pass_TexCoords;
|
||||
|
||||
const float texAtlasWidth = 3.0;
|
||||
|
||||
float getAtlasIndex();
|
||||
vec2 getTexCoordsInAtlas(in vec2 texCoordsInGrid, in float atlasIndex);
|
||||
|
||||
void main() {
|
||||
|
||||
float atlasIndex = getAtlasIndex();
|
||||
vec2 texCoordsInGrid = pass_TexCoords;
|
||||
texCoordsInGrid.x *= gridColumnCount;
|
||||
texCoordsInGrid.x = mod(texCoordsInGrid.x, 1.0);
|
||||
vec2 texCoordsInAtlas = getTexCoordsInAtlas(texCoordsInGrid, atlasIndex);
|
||||
|
||||
gl_FragColor = texture2D(texture, texCoordsInAtlas);
|
||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||
}
|
||||
|
||||
float getAtlasIndex(){
|
||||
|
||||
if(isEndlessTileList == 1.0)
|
||||
return 1.0;
|
||||
|
||||
if(pass_TexCoords.x < 1.0 / gridColumnCount)
|
||||
return 0.0;
|
||||
if(pass_TexCoords.x > 1.0 - 1.0 / gridColumnCount)
|
||||
return 2.0;
|
||||
return 1.0;
|
||||
|
||||
}
|
||||
|
||||
vec2 getTexCoordsInAtlas(in vec2 texCoordsInGrid, in float atlasIndex){
|
||||
|
||||
vec2 texAtlasCoords = vec2(0.0, texCoordsInGrid.y);
|
||||
texAtlasCoords.x = texCoordsInGrid.x / texAtlasWidth;
|
||||
texAtlasCoords.x += mod(atlasIndex, texAtlasWidth) / texAtlasWidth;
|
||||
return texAtlasCoords;
|
||||
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
uniform mat4 mvpMatrix;
|
||||
uniform mat4 transformationMatrix;
|
||||
|
||||
attribute vec4 position;
|
||||
attribute vec2 texCoords;
|
||||
|
||||
varying vec2 pass_TexCoords;
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 transformatedPosition = transformationMatrix * position;
|
||||
gl_Position = mvpMatrix * transformatedPosition;
|
||||
|
||||
pass_TexCoords = (transformationMatrix * vec4(texCoords, 0.0, 0.0)).xy;
|
||||
pass_TexCoords *= vec2(3.0, 3.0);
|
||||
pass_TexCoords.y = clamp(pass_TexCoords.y, 0.0, 1.0) + 0.01;
|
||||
|
||||
}
|
Reference in New Issue
Block a user