Change definition of for loop statements in shader preprocessor to include both max and min.

This commit is contained in:
Kalle Bladin
2016-05-31 12:17:40 -04:00
parent d152ffc3a8
commit 096c19e49f
5 changed files with 25 additions and 21 deletions

View File

@@ -38,12 +38,13 @@ in vec2 fs_uv;
Fragment getFragment() {
Fragment frag;
#for i in 0..#{numLayersColor}
#for j in 1..#{numLayersColor}
{
int i = #{j} - 1;
vec2 samplePos =
colorTiles[#{i}].uvTransform.uvScale * fs_uv +
colorTiles[#{i}].uvTransform.uvOffset;
vec4 colorSample = texture(colorTiles[#{i}].textureSampler, samplePos);
colorTiles[i].uvTransform.uvScale * fs_uv +
colorTiles[i].uvTransform.uvOffset;
vec4 colorSample = texture(colorTiles[i].textureSampler, samplePos);
frag.color = blendOver(frag.color, colorSample);
}
#endfor

View File

@@ -61,18 +61,19 @@ void main()
float height = 0;
#for i in 0..#{numLayersHeight}
#for j in 1..#{numLayersHeight}
{
int i = #{j} - 1;
vec2 samplePos =
heightTiles[#{i}].uvTransform.uvScale * in_uv +
heightTiles[#{i}].uvTransform.uvOffset;
heightTiles[i].uvTransform.uvScale * in_uv +
heightTiles[i].uvTransform.uvOffset;
float sampledValue = texture(heightTiles[#{i}].textureSampler, samplePos).r;
float sampledValue = texture(heightTiles[i].textureSampler, samplePos).r;
// TODO : Some kind of blending here. Now it just writes over
height = (sampledValue *
heightTiles[#{i}].depthTransform.depthScale +
heightTiles[#{i}].depthTransform.depthOffset);
heightTiles[i].depthTransform.depthScale +
heightTiles[i].depthTransform.depthOffset);
// Skirts
int vertexIDx = gl_VertexID % (xSegments + 3);

View File

@@ -38,12 +38,13 @@ in vec2 fs_uv;
Fragment getFragment() {
Fragment frag;
#for i in 0..#{numLayersColor}
#for j in 1..#{numLayersColor}
{
int i = #{j} - 1;
vec2 samplePos =
colorTiles[#{i}].uvTransform.uvScale * fs_uv +
colorTiles[#{i}].uvTransform.uvOffset;
vec4 colorSample = texture(colorTiles[#{i}].textureSampler, samplePos);
colorTiles[i].uvTransform.uvScale * fs_uv +
colorTiles[i].uvTransform.uvOffset;
vec4 colorSample = texture(colorTiles[i].textureSampler, samplePos);
frag.color = blendOver(frag.color, colorSample);
}
#endfor

View File

@@ -65,18 +65,19 @@ void main()
float height = 0;
#for i in 0..#{numLayersHeight}
#for j in 1..#{numLayersHeight}
{
int i = #{j} - 1;
vec2 samplePos =
heightTiles[#{i}].uvTransform.uvScale * in_uv +
heightTiles[#{i}].uvTransform.uvOffset;
heightTiles[i].uvTransform.uvScale * in_uv +
heightTiles[i].uvTransform.uvOffset;
float sampledValue = texture(heightTiles[#{i}].textureSampler, samplePos).r;
float sampledValue = texture(heightTiles[i].textureSampler, samplePos).r;
// TODO : Some kind of blending here. Now it just writes over
height = (sampledValue *
heightTiles[#{i}].depthTransform.depthScale +
heightTiles[#{i}].depthTransform.depthOffset);
heightTiles[i].depthTransform.depthScale +
heightTiles[i].depthTransform.depthOffset);
// Skirts
int vertexIDx = gl_VertexID % (xSegments + 3);