More android shader compilation fixes

This commit is contained in:
Olivier Prat 2018-11-08 10:47:24 +01:00
parent 7e93d91bfa
commit c79c403a52
4 changed files with 25 additions and 22 deletions

View file

@ -253,6 +253,14 @@ vec3 getTapLocationClampedSSAO(int sampleNumber, float spinAngle, float outerRad
LAYOUT(binding=RENDER_UTILS_TEXTURE_SSAO_DEPTH) uniform sampler2D depthPyramidTex; LAYOUT(binding=RENDER_UTILS_TEXTURE_SSAO_DEPTH) uniform sampler2D depthPyramidTex;
LAYOUT(binding=RENDER_UTILS_TEXTURE_SSAO_NORMAL) uniform sampler2D normalTex; LAYOUT(binding=RENDER_UTILS_TEXTURE_SSAO_NORMAL) uniform sampler2D normalTex;
vec2 getFramebufferUVFromSideUV(ivec4 side, vec2 uv) {
return isStereo() ? vec2((uv.x + float(getStereoSide(side))) * 0.5, uv.y) : uv;
}
vec2 getSideUVFromFramebufferUV(ivec4 side, vec2 uv) {
return isStereo() ? vec2(uv.x * 2.0 - float(getStereoSide(side)), uv.y) : uv;
}
ivec2 getDepthTextureSize(int level) { ivec2 getDepthTextureSize(int level) {
return textureSize(depthPyramidTex, level); return textureSize(depthPyramidTex, level);
} }
@ -286,7 +294,7 @@ float getZEyeAtUV(vec2 texCoord, float level) {
<@endfunc@> <@endfunc@>
float getZEyeAtUV(ivec4 side, vec2 texCoord, float level) { float getZEyeAtUV(ivec4 side, vec2 texCoord, float level) {
texCoord.x = mix(texCoord.x, (texCoord.x + getStereoSide(side)) * 0.5, isStereo()); texCoord = getFramebufferUVFromSideUV(side, texCoord);
return getZEyeAtUV(texCoord, level); return getZEyeAtUV(texCoord, level);
} }
@ -304,7 +312,7 @@ vec3 getNormalEyeAtUV(vec2 texCoord, float level) {
} }
vec3 getNormalEyeAtUV(ivec4 side, vec2 texCoord, float level) { vec3 getNormalEyeAtUV(ivec4 side, vec2 texCoord, float level) {
texCoord.x = mix(texCoord.x, (texCoord.x + getStereoSide(side)) * 0.5, isStereo()); texCoord = getFramebufferUVFromSideUV(side, texCoord);
return getNormalEyeAtUV(texCoord, level); return getNormalEyeAtUV(texCoord, level);
} }
@ -322,7 +330,7 @@ vec2 fetchTap(ivec4 side, vec2 tapUV, float tapRadius) {
int mipLevel = evalMipFromRadius(tapRadius * float(doFetchMips())); int mipLevel = evalMipFromRadius(tapRadius * float(doFetchMips()));
vec2 fetchUV = clamp(tapUV, vec2(0), vec2(1)); vec2 fetchUV = clamp(tapUV, vec2(0), vec2(1));
fetchUV = isStereo() ? vec2((fetchUV.x + getStereoSide(side)) * 0.5, fetchUV.y) : fetchUV; fetchUV = getFramebufferUVFromSideUV(side, fetchUV);
vec2 P; vec2 P;
P.x = float(mipLevel); P.x = float(mipLevel);
@ -357,19 +365,17 @@ const ivec2 UV_TOP = ivec2(0,1);
const ivec2 UV_BOTTOM = ivec2(0,-1); const ivec2 UV_BOTTOM = ivec2(0,-1);
vec3 buildNormal(ivec4 side, vec2 fragUVPos, vec3 fragPosition, vec2 deltaDepthUV) { vec3 buildNormal(ivec4 side, vec2 fragUVPos, vec3 fragPosition, vec2 deltaDepthUV) {
vec2 sideUVPos = fragUVPos; vec2 fullUVPos = getFramebufferUVFromSideUV(side, fragUVPos);
sideUVPos.x = mix(sideUVPos.x, (sideUVPos.x + getStereoSide(side)) * 0.5, isStereo());
vec3 fragPositionDxPos; vec3 fragPositionDxPos;
vec3 fragPositionDxNeg; vec3 fragPositionDxNeg;
vec3 fragPositionDyPos; vec3 fragPositionDyPos;
vec3 fragPositionDyNeg; vec3 fragPositionDyNeg;
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_RIGHT, deltaDepthUV, fragPositionDxPos)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_RIGHT, deltaDepthUV, fragPositionDxPos)$>
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_LEFT, deltaDepthUV, fragPositionDxNeg)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_LEFT, deltaDepthUV, fragPositionDxNeg)$>
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_TOP, deltaDepthUV, fragPositionDyPos)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_TOP, deltaDepthUV, fragPositionDyPos)$>
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_BOTTOM, deltaDepthUV, fragPositionDyNeg)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_BOTTOM, deltaDepthUV, fragPositionDyNeg)$>
vec3 fragDeltaDx = getMinDelta(fragPosition, fragPositionDxPos, fragPositionDxNeg); vec3 fragDeltaDx = getMinDelta(fragPosition, fragPositionDxPos, fragPositionDxNeg);
vec3 fragDeltaDy = getMinDelta(fragPosition, fragPositionDyPos, fragPositionDyNeg); vec3 fragDeltaDy = getMinDelta(fragPosition, fragPositionDyPos, fragPositionDyNeg);
@ -379,19 +385,17 @@ vec3 buildNormal(ivec4 side, vec2 fragUVPos, vec3 fragPosition, vec2 deltaDepthU
void buildTangentBinormal(ivec4 side, vec2 fragUVPos, vec3 fragPosition, vec3 fragNormal, vec2 deltaDepthUV, void buildTangentBinormal(ivec4 side, vec2 fragUVPos, vec3 fragPosition, vec3 fragNormal, vec2 deltaDepthUV,
out vec3 fragTangent, out vec3 fragBinormal) { out vec3 fragTangent, out vec3 fragBinormal) {
vec2 sideUVPos = fragUVPos; vec2 fullUVPos = getFramebufferUVFromSideUV(side, fragUVPos);
sideUVPos.x = mix(sideUVPos.x, (sideUVPos.x + getStereoSide(side)) * 0.5, isStereo());
vec3 fragPositionDxPos; vec3 fragPositionDxPos;
vec3 fragPositionDxNeg; vec3 fragPositionDxNeg;
vec3 fragPositionDyPos; vec3 fragPositionDyPos;
vec3 fragPositionDyNeg; vec3 fragPositionDyNeg;
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_RIGHT, deltaDepthUV, fragPositionDxPos)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_RIGHT, deltaDepthUV, fragPositionDxPos)$>
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_LEFT, deltaDepthUV, fragPositionDxNeg)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_LEFT, deltaDepthUV, fragPositionDxNeg)$>
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_TOP, deltaDepthUV, fragPositionDyPos)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_TOP, deltaDepthUV, fragPositionDyPos)$>
<$buildPositionOffset(side, fragUVPos, sideUVPos, UV_BOTTOM, deltaDepthUV, fragPositionDyNeg)$> <$buildPositionOffset(side, fragUVPos, fullUVPos, UV_BOTTOM, deltaDepthUV, fragPositionDyNeg)$>
vec3 fragDeltaDx = getMinDelta(fragPosition, fragPositionDxPos, fragPositionDxNeg); vec3 fragDeltaDx = getMinDelta(fragPosition, fragPositionDxPos, fragPositionDxNeg);
vec3 fragDeltaDy = getMinDelta(fragPosition, fragPositionDyPos, fragPositionDyNeg); vec3 fragDeltaDy = getMinDelta(fragPosition, fragPositionDyPos, fragPositionDyNeg);

View file

@ -43,7 +43,7 @@ int getBlurRadius() {
} }
vec4 fetchOcclusionPacked(ivec4 side, vec2 texCoord) { vec4 fetchOcclusionPacked(ivec4 side, vec2 texCoord) {
texCoord.x = mix(texCoord.x, (texCoord.x + getStereoSide(side) * getBlurOcclusionUVLimit().x) * 0.5, isStereo()); texCoord.x = isStereo() ? (texCoord.x + float(getStereoSide(side)) * getBlurOcclusionUVLimit().x) * 0.5 : texCoord.x;
return textureLod(occlusionMap, texCoord, 0.0); return textureLod(occlusionMap, texCoord, 0.0);
} }
@ -96,7 +96,7 @@ vec4 getBlurredOcclusion(ivec2 destPixelCoord, vec2 occlusionTexCoord, vec2 dept
int r; int r;
// From now on, occlusionTexCoord is the UV pos in the side // From now on, occlusionTexCoord is the UV pos in the side
float sideTexCoord = occlusionTexCoord.x * 2.0 - getStereoSide(side) * getBlurOcclusionUVLimit().x; float sideTexCoord = occlusionTexCoord.x * 2.0 - float(getStereoSide(side)) * getBlurOcclusionUVLimit().x;
occlusionTexCoord.x = mix(occlusionTexCoord.x, sideTexCoord, isStereo()); occlusionTexCoord.x = mix(occlusionTexCoord.x, sideTexCoord, isStereo());
occlusionTexCoord -= getBlurOcclusionAxis() * blurRadius; occlusionTexCoord -= getBlurOcclusionAxis() * blurRadius;

View file

@ -32,7 +32,7 @@ void main(void) {
vec2 deltaDepthUV = vec2(1.0) / vec2(getDepthTextureSideSize(0)); vec2 deltaDepthUV = vec2(1.0) / vec2(getDepthTextureSideSize(0));
// From now on, fragUVPos is the UV pos in the side // From now on, fragUVPos is the UV pos in the side
fragUVPos.x = mix(fragUVPos.x, fragUVPos.x * 2.0 - getStereoSide(side), isStereo()); fragUVPos = getSideUVFromFramebufferUV(side, fragUVPos);
// The position and normal of the pixel fragment in Eye space // The position and normal of the pixel fragment in Eye space
vec3 fragPositionES = buildPosition(side, fragUVPos); vec3 fragPositionES = buildPosition(side, fragUVPos);

View file

@ -45,8 +45,7 @@ void main(void) {
} }
ivec4 side = getStereoSideInfoFromWidth(fragPixelPos.x, sideOcclusionSize.x); ivec4 side = getStereoSideInfoFromWidth(fragPixelPos.x, sideOcclusionSize.x);
// From now on, fragUVPos is the UV pos in the side // From now on, fragUVPos is the UV pos in the side
fragUVPos.x = mix(fragUVPos.x, fragUVPos.x * 2.0 - getStereoSide(side), isStereo()); fragUVPos = getSideUVFromFramebufferUV(side, fragUVPos);
fragUVPos = snapToTexel(fragUVPos, sideDepthSize); fragUVPos = snapToTexel(fragUVPos, sideDepthSize);
// The position and normal of the pixel fragment in Eye space // The position and normal of the pixel fragment in Eye space