mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Fixing shader implicit type conversions
This commit is contained in:
parent
650f112f16
commit
fade3a8de0
20 changed files with 45 additions and 44 deletions
|
@ -11,7 +11,7 @@ layout(location=0) in vec2 varTexCoord0;
|
|||
layout(location=0) out vec4 outFragColor;
|
||||
|
||||
void main(void) {
|
||||
ivec2 texCoord = ivec2(floor(varTexCoord0 * textureData.textureSize));
|
||||
ivec2 texCoord = ivec2(floor(varTexCoord0 * vec2(textureData.textureSize)));
|
||||
texCoord.x /= 2;
|
||||
int row = int(floor(gl_FragCoord.y));
|
||||
if (row % 2 > 0) {
|
||||
|
|
|
@ -45,7 +45,7 @@ void main(void) {
|
|||
int frontCondition = 1 -int(gl_FrontFacing) * 2;
|
||||
vec3 color = varColor.rgb;
|
||||
packDeferredFragmentTranslucent(
|
||||
interpolatedNormal * frontCondition,
|
||||
interpolatedNormal * float(frontCondition),
|
||||
texel.a * varColor.a,
|
||||
polyline.color * texel.rgb + fadeEmissive,
|
||||
vec3(0.01, 0.01, 0.01),
|
||||
|
|
|
@ -17,7 +17,7 @@ float paintStripe(float value, float offset, float scale, float edge) {
|
|||
float width = fwidth(value);
|
||||
float normalizedWidth = width * scale;
|
||||
|
||||
float x0 = (value + offset) * scale - normalizedWidth / 2;
|
||||
float x0 = (value + offset) * scale - normalizedWidth / 2.0;
|
||||
float x1 = x0 + normalizedWidth;
|
||||
|
||||
float balance = 1.0 - edge;
|
||||
|
|
|
@ -30,7 +30,7 @@ void main(void) {
|
|||
for (int x=0 ; x<parameters._sampleCount ; x++) {
|
||||
vec4 color = texture(colorMap, uv);
|
||||
float luminance = (color.r+color.g+color.b) / 3.0;
|
||||
float mask = clamp((luminance-parameters._threshold)*0.25, 0, 1);
|
||||
float mask = clamp((luminance-parameters._threshold)*0.25, 0.0, 1.0);
|
||||
|
||||
color *= mask;
|
||||
maskedColor += color;
|
||||
|
@ -39,6 +39,6 @@ void main(void) {
|
|||
|
||||
startUv.y += parameters._deltaUV.y;
|
||||
}
|
||||
maskedColor /= parameters._sampleCount * parameters._sampleCount;
|
||||
maskedColor /= float(parameters._sampleCount * parameters._sampleCount);
|
||||
outFragColor = vec4(maskedColor.rgb, 1.0);
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ void main(void) {
|
|||
discard;
|
||||
<@endif@>
|
||||
} else {
|
||||
vec2 halfTexel = getInvWidthHeight() / 2;
|
||||
vec2 halfTexel = getInvWidthHeight() / 2.0;
|
||||
vec2 texCoord0 = varTexCoord0+halfTexel;
|
||||
float weight = 0.0;
|
||||
vec2 deltaUv = params._size / params._blurKernelSize;
|
||||
vec2 deltaUv = params._size / float(params._blurKernelSize);
|
||||
vec2 lineStartUv = texCoord0 - params._size / 2.0;
|
||||
vec2 uv;
|
||||
int x;
|
||||
|
@ -87,7 +87,7 @@ void main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (intensity > 0) {
|
||||
if (intensity > 0.0) {
|
||||
// sumOutlineDepth /= intensity;
|
||||
} else {
|
||||
sumOutlineDepth = FAR_Z;
|
||||
|
|
|
@ -67,10 +67,10 @@ ShadowSampleOffsets evalShadowFilterOffsets(vec4 position) {
|
|||
ivec2 offset = coords & ivec2(1,1);
|
||||
offset.y = (offset.x+offset.y) & 1;
|
||||
|
||||
offsets.points[0] = shadowScale * vec3(offset + PCFkernel[0], 0.0);
|
||||
offsets.points[1] = shadowScale * vec3(offset + PCFkernel[1], 0.0);
|
||||
offsets.points[2] = shadowScale * vec3(offset + PCFkernel[2], 0.0);
|
||||
offsets.points[3] = shadowScale * vec3(offset + PCFkernel[3], 0.0);
|
||||
offsets.points[0] = shadowScale * vec3(vec2(offset) + PCFkernel[0], 0.0);
|
||||
offsets.points[1] = shadowScale * vec3(vec2(offset) + PCFkernel[1], 0.0);
|
||||
offsets.points[2] = shadowScale * vec3(vec2(offset) + PCFkernel[2], 0.0);
|
||||
offsets.points[3] = shadowScale * vec3(vec2(offset) + PCFkernel[3], 0.0);
|
||||
|
||||
return offsets;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDe
|
|||
vec3 cascadeMix;
|
||||
bvec4 isPixelOnCascade;
|
||||
int cascadeIndex;
|
||||
float oneMinusNdotL = 1.0 - clamp(dot(worldLightDir, worldNormal), 0, 1);
|
||||
float oneMinusNdotL = 1.0 - clamp(dot(worldLightDir, worldNormal), 0.0, 1.0);
|
||||
|
||||
for (cascadeIndex=0 ; cascadeIndex<getShadowCascadeCount() ; cascadeIndex++) {
|
||||
cascadeShadowCoords[cascadeIndex] = evalShadowTexcoord(cascadeIndex, worldPosition);
|
||||
|
|
|
@ -79,7 +79,7 @@ void main(void) {
|
|||
<$transformModelToEyeDir(cam, obj, originSpaceTan, tanEye)$>
|
||||
|
||||
lateralDir = normalize(cross(vec3(0.0, 0.0, 1.0), normalize(tanEye)));
|
||||
posEye.xyz += (0.005 * abs(posEye.z) * (regionID + 1)) * (-1.0 + 2.0 * float(segmentVertexID)) * lateralDir;
|
||||
posEye.xyz += (0.005 * abs(posEye.z) * float(regionID + 1)) * (-1.0 + 2.0 * float(segmentVertexID)) * lateralDir;
|
||||
varEyePos = posEye.xyz;
|
||||
|
||||
<$transformEyeToClipPos(cam, posEye, gl_Position)$>
|
||||
|
|
|
@ -68,7 +68,7 @@ void main() {
|
|||
outFragColor.w = 1.0;
|
||||
|
||||
}*/
|
||||
if (gl_FragCoord.x > 800) {
|
||||
if (gl_FragCoord.x > 800.0) {
|
||||
/* // filter width limit for dependent "two-tap" texture samples
|
||||
float FXAA_SPAN_MAX = 8.0;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ void main(void) {
|
|||
|
||||
ivec3 cluster = clusterGrid_getCluster(clusterIndex);
|
||||
int numLights = cluster.x + cluster.y;
|
||||
float numLightsScale = clamp(numLights * 0.05, 0.01, 1.0);
|
||||
float numLightsScale = clamp(float(numLights) * 0.05, 0.01, 1.0);
|
||||
|
||||
int clusterOffset = cluster.z;
|
||||
|
||||
|
@ -90,6 +90,6 @@ void main(void) {
|
|||
numLightTouching++;
|
||||
}
|
||||
|
||||
_fragColor = vec4(colorRamp(1.0 - (numLightTouching / 12.0f)), (numLightTouching > 0 ? 0.5 + 0.5 * numLightsScale : 0.0));
|
||||
_fragColor = vec4(colorRamp(1.0 - (float(numLightTouching) / 12.0f)), (numLightTouching > 0 ? 0.5 + 0.5 * numLightsScale : 0.0));
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ void main(void) {
|
|||
ivec3 cluster = clusterGrid_getCluster(gpu_InstanceID());
|
||||
int numLights = cluster.x + cluster.y;
|
||||
|
||||
float numLightsScale = clamp(numLights * 0.1, 0.0, 1.0);
|
||||
float numLightsScale = clamp(float(numLights) * 0.1, 0.0, 1.0);
|
||||
|
||||
ivec3 clusterPos = frustumGrid_indexToCluster(gpu_InstanceID());
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void main(void) {
|
|||
|
||||
ivec3 cluster = clusterGrid_getCluster(frustumGrid_clusterToIndex(clusterPos));
|
||||
int numLights = cluster.x + cluster.y;
|
||||
float numLightsScale = clamp(numLights * 0.05, 0.01, 1.0);
|
||||
float numLightsScale = clamp(float(numLights) * 0.05, 0.01, 1.0);
|
||||
|
||||
|
||||
ivec3 dims = frustumGrid.dims.xyz;
|
||||
|
|
|
@ -91,7 +91,7 @@ void main(void) {
|
|||
normal,
|
||||
1.0,
|
||||
diffuse+fadeEmissive,
|
||||
max(0, 1.0 - shininess / 128.0),
|
||||
max(0.0, 1.0 - shininess / 128.0),
|
||||
DEFAULT_METALLIC,
|
||||
specular,
|
||||
specular);
|
||||
|
@ -100,7 +100,7 @@ void main(void) {
|
|||
normal,
|
||||
1.0,
|
||||
diffuse,
|
||||
max(0, 1.0 - shininess / 128.0),
|
||||
max(0.0, 1.0 - shininess / 128.0),
|
||||
length(specular),
|
||||
DEFAULT_EMISSIVE+fadeEmissive,
|
||||
DEFAULT_OCCLUSION,
|
||||
|
|
|
@ -137,14 +137,14 @@ float getBlurCoef(int c) {
|
|||
float getAngleDitheringWorldPos(in vec3 pixelWorldPos) {
|
||||
vec3 worldPosFract = fract(pixelWorldPos * 1.0);
|
||||
|
||||
ivec3 pixelPos = ivec3(worldPosFract * 256);
|
||||
ivec3 pixelPos = ivec3(worldPosFract * 256.0);
|
||||
|
||||
return isDitheringEnabled() * ((3 * pixelPos.x ^ pixelPos.y + pixelPos.x * pixelPos.y) + (3 * pixelPos.y ^ pixelPos.z + pixelPos.x * pixelPos.z)) * 10 + getFrameDithering();
|
||||
return isDitheringEnabled() * float(((3 * pixelPos.x ^ pixelPos.y + pixelPos.x * pixelPos.y) + (3 * pixelPos.y ^ pixelPos.z + pixelPos.x * pixelPos.z)) * 10) + getFrameDithering();
|
||||
}
|
||||
|
||||
float getAngleDithering(in ivec2 pixelPos) {
|
||||
// Hash function used in the AlchemyAO paper
|
||||
return isDitheringEnabled() * (3 * pixelPos.x ^ pixelPos.y + pixelPos.x * pixelPos.y) * 10 + getFrameDithering();
|
||||
return isDitheringEnabled() * float((3 * pixelPos.x ^ pixelPos.y + pixelPos.x * pixelPos.y) * 10) + getFrameDithering();
|
||||
}
|
||||
|
||||
float evalDiskRadius(float Zeye, vec2 imageSize) {
|
||||
|
@ -162,7 +162,7 @@ const float TWO_PI = 6.28;
|
|||
|
||||
vec3 getUnitTapLocation(int sampleNumber, float spinAngle){
|
||||
// Radius relative to ssR
|
||||
float alpha = float(sampleNumber + 0.5) * getInvNumSamples();
|
||||
float alpha = (float(sampleNumber) + 0.5) * getInvNumSamples();
|
||||
float angle = alpha * (getNumSpiralTurns() * TWO_PI) + spinAngle;
|
||||
return vec3(cos(angle), sin(angle), alpha);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ vec3 getTapLocationClamped(int sampleNumber, float spinAngle, float outerRadius,
|
|||
if (redoTap) {
|
||||
tap.xy = tapPos - pixelPos;
|
||||
tap.z = length(tap.xy);
|
||||
tap.z = 0;
|
||||
tap.z = 0.0;
|
||||
}
|
||||
|
||||
return tap;
|
||||
|
@ -253,7 +253,7 @@ vec3 fetchTapUnfiltered(ivec4 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
|
|||
|
||||
vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
|
||||
|
||||
vec2 fetchUV = vec2(tapUV.x + side.w * 0.5 * (side.x - tapUV.x), tapUV.y);
|
||||
vec2 fetchUV = vec2(tapUV.x + float(side.w) * 0.5 * (float(side.x) - tapUV.x), tapUV.y);
|
||||
|
||||
vec3 P;
|
||||
P.xy = tapUV;
|
||||
|
@ -263,7 +263,7 @@ vec3 fetchTapUnfiltered(ivec4 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
|
|||
}
|
||||
|
||||
vec3 fetchTap(ivec4 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
|
||||
int mipLevel = evalMipFromRadius(tap.z * doFetchMips());
|
||||
int mipLevel = evalMipFromRadius(tap.z * float(doFetchMips()));
|
||||
|
||||
ivec2 ssP = ivec2(tap.xy) + ssC;
|
||||
ivec2 ssPFull = ivec2(ssP.x + side.y, ssP.y);
|
||||
|
@ -276,7 +276,7 @@ vec3 fetchTap(ivec4 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
|
|||
ivec2 mipP = clamp(ssPFull >> mipLevel, ivec2(0), mipSize - ivec2(1));
|
||||
|
||||
vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
|
||||
vec2 fetchUV = vec2(tapUV.x + side.w * 0.5 * (side.x - tapUV.x), tapUV.y);
|
||||
vec2 fetchUV = vec2(tapUV.x + float(side.w) * 0.5 * (float(side.x) - tapUV.x), tapUV.y);
|
||||
// vec2 tapUV = (vec2(mipP) + vec2(0.5)) / vec2(mipSize);
|
||||
|
||||
vec3 P;
|
||||
|
|
|
@ -84,15 +84,15 @@ void main(void) {
|
|||
float keepTapRadius = 1.0;
|
||||
int keepedMip = -1;
|
||||
bool keep = false;
|
||||
|
||||
for (int i = 0; i < getNumSamples(); ++i) {
|
||||
int sampleCount = int(getNumSamples());
|
||||
for (int i = 0; i < sampleCount; ++i) {
|
||||
vec3 tap = getTapLocationClamped(i, randomPatternRotationAngle, ssDiskRadius, cursorPixelPos, imageSize);
|
||||
|
||||
// The occluding point in camera space
|
||||
vec2 fragToTap = vec2(ssC) + tap.xy - fragCoord.xy;
|
||||
if (dot(fragToTap,fragToTap) < keepTapRadius) {
|
||||
keep = true;
|
||||
keepedMip = evalMipFromRadius(tap.z * doFetchMips());
|
||||
keepedMip = evalMipFromRadius(tap.z * float(doFetchMips()));
|
||||
}
|
||||
|
||||
vec3 tapUVZ = fetchTap(side, ssC, tap, imageSize);
|
||||
|
|
|
@ -52,8 +52,9 @@ void main(void) {
|
|||
|
||||
// Accumulate the Obscurance for each samples
|
||||
float sum = 0.0;
|
||||
for (int i = 0; i < getNumSamples(); ++i) {
|
||||
vec3 tap = getTapLocationClamped(i, randomPatternRotationAngle, ssDiskRadius, ssC, imageSize);
|
||||
int sampleCount = int(getNumSamples());
|
||||
for (int i = 0; i < sampleCount; ++i) {
|
||||
vec3 tap = getTapLocationClamped(i, randomPatternRotationAngle, ssDiskRadius, vec2(ssC), imageSize);
|
||||
|
||||
vec3 tapUVZ = fetchTap(side, ssC, tap, imageSize);
|
||||
|
||||
|
@ -68,10 +69,10 @@ void main(void) {
|
|||
// Bilateral box-filter over a quad for free, respecting depth edges
|
||||
// (the difference that this makes is subtle)
|
||||
if (abs(dFdx(Cp.z)) < 0.02) {
|
||||
A -= dFdx(A) * ((ssC.x & 1) - 0.5);
|
||||
A -= dFdx(A) * (float(ssC.x & 1) - 0.5);
|
||||
}
|
||||
if (abs(dFdy(Cp.z)) < 0.02) {
|
||||
A -= dFdy(A) * ((ssC.y & 1) - 0.5);
|
||||
A -= dFdy(A) * (float(ssC.y & 1) - 0.5);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ vec3 drawScatteringTableUV(vec2 cursor, vec2 texcoord) {
|
|||
|
||||
vec3 distance = vec3(0.0);
|
||||
for (int c = 0; c < 3; c++) {
|
||||
vec2 BRDFuv = vec2(clamp(bentNdotL[c] * 0.5 + 0.5, 0.0, 1.0), clamp(2 * curvature, 0.0, 1.0));
|
||||
vec2 BRDFuv = vec2(clamp(bentNdotL[c] * 0.5 + 0.5, 0.0, 1.0), clamp(2.0 * curvature, 0.0, 1.0));
|
||||
vec2 delta = BRDFuv - texcoord;
|
||||
distance[c] = 1.0 - dot(delta, delta);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ vec2 taa_fetchVelocityMap(vec2 uv) {
|
|||
}
|
||||
|
||||
float taa_fetchDepth(vec2 uv) {
|
||||
return -texture(depthMap, vec2(uv), 0).x;
|
||||
return -texture(depthMap, vec2(uv), 0.0).x;
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,7 +230,7 @@ vec2 taa_fromEyeUVToFragUV(vec2 eyeUV, int stereoSide) {
|
|||
vec2 fragUV = eyeUV;
|
||||
if (isStereo()) {
|
||||
fragUV.x *= 0.5;
|
||||
fragUV.x += stereoSide*0.5;
|
||||
fragUV.x += float(stereoSide)*0.5;
|
||||
}
|
||||
return fragUV;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void main(void) {
|
|||
vec2 cursorVelocityDir = cursorVelocity / cursorVelocityLength;
|
||||
vec2 cursorVelocityNor = vec2(cursorVelocityDir.y, -cursorVelocityDir.x);
|
||||
|
||||
if ((dot(cursorVelocityDir, cursorToFragVec) < 0) && abs(dot(cursorVelocityNor, cursorToFragVec)) < 1.0) {
|
||||
if ((dot(cursorVelocityDir, cursorToFragVec) < 0.0) && abs(dot(cursorVelocityNor, cursorToFragVec)) < 1.0) {
|
||||
|
||||
vec3 speedColor = taa_getVelocityColorRelative(cursorToFragLength);
|
||||
|
||||
|
@ -69,7 +69,7 @@ void main(void) {
|
|||
float tenPercentHeight = 0.1 * imageSize.y;
|
||||
float centerWidth = imageSize.x * 0.5;
|
||||
|
||||
//vec2 nextOrbPos = vec2(centerWidth, imageSize.y - 3 * tenPercentHeight);
|
||||
//vec2 nextOrbPos = vec2(centerWidth, imageSize.y - 3.0 * tenPercentHeight);
|
||||
vec2 nextOrbPos = cursorPos;
|
||||
vec2 nextOrbPosToPix = pixPos - nextOrbPos;
|
||||
float nextOrbPosToPixLength = length(nextOrbPosToPix);
|
||||
|
@ -146,7 +146,7 @@ void main(void) {
|
|||
prevColor = texture(historyMap, prevTexCoord).xyz;
|
||||
}
|
||||
|
||||
outFragColor.xyz = mix(prevColor, vec3(1,0,1), clamp(distance(prevColor, nextColor) - 0.01, 0, 1));
|
||||
outFragColor.xyz = mix(prevColor, vec3(1,0,1), clamp(distance(prevColor, nextColor) - 0.01, 0.0, 1.0));
|
||||
|
||||
if (pixVelocityLength > params.debugShowVelocityThreshold) {
|
||||
vec3 speedColor = taa_getVelocityColorAboveThreshold(pixVelocityLength);
|
||||
|
|
|
@ -44,7 +44,7 @@ void main(void) {
|
|||
// vec3 ambient = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(lightAmbient), fragNormal).xyz;
|
||||
// _fragColor = vec4( 0.5 * (fragNormal + vec3(1.0)), 1.0);
|
||||
|
||||
vec3 color = (sphereUV.x > 0 ? ambientMap : ambientSH);
|
||||
vec3 color = (sphereUV.x > 0.0 ? ambientMap : ambientSH);
|
||||
|
||||
color = color * 1.0 - base.w + base.xyz * base.w;
|
||||
const float INV_GAMMA_22 = 1.0 / 2.2;
|
||||
|
|
|
@ -61,5 +61,5 @@ void main(void) {
|
|||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
|
||||
|
||||
varColor = vec4(colorWheel(fract(float(inCellLocation.w) / 5.0)), 0.8 + 0.2 * cellIsEmpty);
|
||||
varColor = vec4(colorWheel(fract(float(inCellLocation.w) / 5.0)), 0.8 + 0.2 * float(cellIsEmpty));
|
||||
}
|
Loading…
Reference in a new issue