From 96b28a3b9d4f95a817f614701fe084c3c0cea251 Mon Sep 17 00:00:00 2001 From: fallahn Date: Thu, 27 Jul 2023 15:20:03 +0100 Subject: [PATCH] optimise shaders slightly --- crogine/src/graphics/shaders/Billboard.hpp | 8 ++-- .../src/graphics/shaders/ShaderIncludes.inl | 12 +++--- samples/golf/buildnumber.h | 4 +- samples/golf/src/GolfGame.cpp | 4 +- samples/golf/src/golf/BillboardShader.inl | 17 +++++---- samples/golf/src/golf/CelShader.inl | 14 +++---- samples/golf/src/golf/CloudShader.inl | 4 +- samples/golf/src/golf/ProfileState.cpp | 6 +-- samples/golf/src/golf/ShaderIncludes.inl | 12 +++--- samples/golf/src/golf/TerrainShader.inl | 9 +---- samples/golf/src/golf/TreeShader.inl | 38 +++++++++---------- samples/golf/src/golf/WaterShader.inl | 18 ++++----- samples/scratchpad/src/MyApp.cpp | 4 +- 13 files changed, 74 insertions(+), 76 deletions(-) diff --git a/crogine/src/graphics/shaders/Billboard.hpp b/crogine/src/graphics/shaders/Billboard.hpp index c7dd5c00a..7e25fb514 100644 --- a/crogine/src/graphics/shaders/Billboard.hpp +++ b/crogine/src/graphics/shaders/Billboard.hpp @@ -102,7 +102,7 @@ namespace cro::Shaders::Billboard gl_Position = viewProj * vec4(position, 1.0); gl_Position /= gl_Position.w; - gl_Position.xy += a_position.xy * (a_texCoord1 / u_screenSize); + gl_Position.xy = (a_position.xy * (a_texCoord1 / u_screenSize)) + gl_Position.xy; #if defined (VERTEX_LIT) v_normalVector = vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]); @@ -115,8 +115,8 @@ namespace cro::Shaders::Billboard #else vec3 camUp = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]) * -u_clipPlane.y; #endif - position = position + camRight * a_position.x - + camUp * a_position.y; + position = position + (camRight * a_position.x) + + (camUp * a_position.y); gl_Position = viewProj * vec4(position, 1.0); @@ -300,7 +300,7 @@ namespace cro::Shaders::Billboard { for(int y = 0; y < filterSize; ++y) { - float pcfDepth = TEXTURE(u_shadowMap, vec3(projectionCoords.xy + kernel[y * filterSize + x] * texelSize, cascadeIndex)).r; + float pcfDepth = TEXTURE(u_shadowMap, vec3((kernel[y * filterSize + x] * texelSize) + projectionCoords.xy, cascadeIndex)).r; shadow += (projectionCoords.z - 0.001) > pcfDepth ? 0.4 : 0.0; } } diff --git a/crogine/src/graphics/shaders/ShaderIncludes.inl b/crogine/src/graphics/shaders/ShaderIncludes.inl index 3ce63312d..a57181f21 100644 --- a/crogine/src/graphics/shaders/ShaderIncludes.inl +++ b/crogine/src/graphics/shaders/ShaderIncludes.inl @@ -83,9 +83,11 @@ R"( static const std::string SkinMatrix = R"( mat4 skinMatrix = a_boneWeights.x * u_boneMatrices[int(a_boneIndices.x)]; - skinMatrix += a_boneWeights.y * u_boneMatrices[int(a_boneIndices.y)]; - skinMatrix += a_boneWeights.z * u_boneMatrices[int(a_boneIndices.z)]; - skinMatrix += a_boneWeights.w * u_boneMatrices[int(a_boneIndices.w)]; + + skinMatrix = a_boneWeights.y * u_boneMatrices[int(a_boneIndices.y)] + skinMatrix; + skinMatrix = a_boneWeights.z * u_boneMatrices[int(a_boneIndices.z)] + skinMatrix; + skinMatrix = a_boneWeights.w * u_boneMatrices[int(a_boneIndices.w)] + skinMatrix; + )"; @@ -194,7 +196,7 @@ R"( { for(int y = 0; y < filterSize; ++y) { - float pcfDepth = TEXTURE(u_shadowMap, vec3(projectionCoords.xy + kernel[y * filterSize + x] * texelSize, cascadeIndex)).r; + float pcfDepth = TEXTURE(u_shadowMap, vec3((kernel[y * filterSize + x] * texelSize) + projectionCoords.xy, cascadeIndex)).r; shadow += (projectionCoords.z - bias) > pcfDepth ? 0.4 : 0.0; } } @@ -216,7 +218,7 @@ R"( { for(int y = 0; y < filterSize; ++y) { - float pcfDepth = TEXTURE(u_shadowMap, vec3(projectionCoords.xy + kernel[y * filterSize + x] * texelSize, cascadeIndex)).r; + float pcfDepth = TEXTURE(u_shadowMap, vec3((kernel[y * filterSize + x] * texelSize) + projectionCoords.xy, cascadeIndex)).r; shadow += (projectionCoords.z - 0.001) > pcfDepth ? 0.4 : 0.0; } } diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index ad666a5ee..9a52d4c3f 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 970 -#define BUILDNUMBER_STR "970" +#define BUILDNUMBER 973 +#define BUILDNUMBER_STR "973" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/GolfGame.cpp b/samples/golf/src/GolfGame.cpp index e19cf0ef5..c93c90cb7 100644 --- a/samples/golf/src/GolfGame.cpp +++ b/samples/golf/src/GolfGame.cpp @@ -722,9 +722,9 @@ bool GolfGame::initialise() #ifdef CRO_DEBUG_ //m_stateStack.pushState(StateID::DrivingRange); //can't go straight to this because menu needs to parse avatar data //m_stateStack.pushState(StateID::Bush); - m_stateStack.pushState(StateID::Clubhouse); + //m_stateStack.pushState(StateID::Clubhouse); //m_stateStack.pushState(StateID::SplashScreen); - //m_stateStack.pushState(StateID::Menu); + m_stateStack.pushState(StateID::Menu); //m_stateStack.pushState(StateID::SQLite); #else m_stateStack.pushState(StateID::SplashScreen); diff --git a/samples/golf/src/golf/BillboardShader.inl b/samples/golf/src/golf/BillboardShader.inl index 975f1d9c3..61679b059 100644 --- a/samples/golf/src/golf/BillboardShader.inl +++ b/samples/golf/src/golf/BillboardShader.inl @@ -97,9 +97,9 @@ static const std::string BillboardVertexShader = R"( #endif vec3 camRight = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]); vec3 camUp = vec3(0.0, 1.0, 0.0); - position = position + camRight * relPos.x - + camUp * relPos.y - + cross(camRight, camUp) * relPos.z; + position = position + (camRight * relPos.x) + + (camUp * relPos.y) + + (cross(camRight, camUp) * relPos.z); //---generic wind added to tall billboards---// @@ -118,21 +118,21 @@ static const std::string BillboardVertexShader = R"( vec2 uv = a_normal.xz; - uv.x += u_windData.w * xFreq; + uv.x = (u_windData.w * xFreq) + uv.x; float windX = TEXTURE(u_noiseTexture, uv).r; windX *= 2.0; windX -= 1.0; uv = a_normal.xz; - uv.y += u_windData.w * yFreq; + uv.y = (u_windData.w * yFreq) + uv.y; float windZ = TEXTURE(u_noiseTexture, uv).r; windZ *= 2.0; windZ -= 1.0; - position.x += windX * totalScale; - position.z += windZ * totalScale; - position.xz += (u_windData.xz * strength * 2.0) * totalScale; + position.x = (windX * totalScale) + position.x; + position.z = (windZ * totalScale) + position.z; + position.xz = ((u_windData.xz * strength * 2.0) * totalScale) + position.xz; //------------------------------// //wind from billboard vertex colour (above) @@ -149,6 +149,7 @@ static const std::string BillboardVertexShader = R"( vertPos.xy = floor(vertPos.xy); vertPos.xy = ((vertPos.xy / u_scaledResolution) * 2.0) - 1.0; vertPos.xyz *= vertPos.w;*/ + gl_Position = vertPos; v_texCoord0 = a_texCoord0; diff --git a/samples/golf/src/golf/CelShader.inl b/samples/golf/src/golf/CelShader.inl index c314be846..6ac9cb557 100644 --- a/samples/golf/src/golf/CelShader.inl +++ b/samples/golf/src/golf/CelShader.inl @@ -128,7 +128,7 @@ static const std::string CelVertexShader = R"( vec2 texCoord = a_texCoord1; float scale = texCoord.y; float instanceOffset = mod(gl_InstanceID, MAX_INSTANCE) * u_offsetMultiplier; - texCoord.y = mod(u_time + (0.15 * instanceOffset), u_maxTime); + texCoord.y = mod((0.15 * instanceOffset)+ u_time, u_maxTime); vec4 position = vec4(decodeVector(u_vatsPosition, texCoord) * scale, 1.0); #else @@ -203,7 +203,7 @@ static const std::string CelVertexShader = R"( v_texCoord = a_texCoord0; #if defined (VATS) v_texCoord.x /= MAX_INSTANCE; - v_texCoord.x += (1.0 / MAX_INSTANCE) * mod(gl_InstanceID, MAX_INSTANCE); + v_texCoord.x = ((1.0 / MAX_INSTANCE) * mod(gl_InstanceID, MAX_INSTANCE)) + v_texCoord.x; #endif #endif @@ -371,7 +371,7 @@ static const std::string CelFragmentShader = R"( { for(int y = 0; y < filterSize; ++y) { - float pcfDepth = TEXTURE(u_shadowMap, vec3(projectionCoords.xy + kernel[y * filterSize + x] * texelSize, cascadeIndex)).r; + float pcfDepth = TEXTURE(u_shadowMap, vec3((kernel[y * filterSize + x] * texelSize) + projectionCoords.xy, cascadeIndex)).r; shadow += (projectionCoords.z - 0.001) > pcfDepth ? 0.4 : 0.0; } } @@ -488,8 +488,8 @@ float greenTerrain = step(0.065, v_colour.r) * (1.0 - step(0.13, v_colour.r)); //complementaryColour(colour.rgb) vec3 holeColour = mix(colour.rgb * vec3(0.67, 0.757, 0.41), colour.rgb, 0.65 + (0.35 * holeHeight)); - holeColour.r += smoothstep(0.45, 0.99, holeHeight) * 0.01; - holeColour.g += smoothstep(0.65, 0.999, holeHeight) * 0.01; + holeColour.r = (smoothstep(0.45, 0.99, holeHeight) * 0.01) + holeColour.r; + holeColour.g = (smoothstep(0.65, 0.999, holeHeight) * 0.01) + holeColour.g; //distances are sqr float holeHeightFade = (1.0 - smoothstep(100.0, 400.0, dot(viewDirection, viewDirection))); @@ -517,7 +517,7 @@ float greenTerrain = step(0.065, v_colour.r) * (1.0 - step(0.13, v_colour.r)); int texY = int(mod(texCheck.y, MatrixSize)); float facing = dot(normal, vec3(0.0, 1.0, 0.0)); - float waterFade = (1.0 - smoothstep(WaterLevel, WaterLevel + (1.15 * (1.0 - smoothstep(0.89, 0.99, facing))), v_worldPosition.y)); + float waterFade = (1.0 - smoothstep(WaterLevel, (1.15 * (1.0 - smoothstep(0.89, 0.99, facing))) + WaterLevel, v_worldPosition.y)); float waterDither = findClosest(texX, texY, waterFade) * waterFade * (1.0 - step(0.96, facing)); #if defined(COMP_SHADE) @@ -546,7 +546,7 @@ float greenTerrain = step(0.065, v_colour.r) * (1.0 - step(0.13, v_colour.r)); #endif #if defined(REFLECTIONS) - colour.rgb += TEXTURE_CUBE(u_reflectMap, reflect(-viewDirection, normal)).rgb * 0.25; + colour.rgb = (TEXTURE_CUBE(u_reflectMap, reflect(-viewDirection, normal)).rgb * 0.25) + colour.rgb; #endif FRAG_OUT = vec4(colour.rgb, 1.0); diff --git a/samples/golf/src/golf/CloudShader.inl b/samples/golf/src/golf/CloudShader.inl index 8d09cf1a3..b7d9e0e40 100644 --- a/samples/golf/src/golf/CloudShader.inl +++ b/samples/golf/src/golf/CloudShader.inl @@ -225,7 +225,7 @@ static const std::string CloudOverheadFragment = R"( float rimAmount = dot(vec3(0.0, -1.0, 0.0), normal); rimAmount += 1.0; - rimAmount /= 2.0; + rimAmount *= 0.5; rim *= smoothstep(0.5, 0.9, rimAmount); @@ -306,7 +306,7 @@ void main() check *= 2.0; check -= 1.0; - lightAmount += (0.05 * check); + lightAmount = (0.05 * check) + lightAmount; FRAG_OUT = mix(u_colourA, u_colourB, step(0.5, lightAmount)); })"; \ No newline at end of file diff --git a/samples/golf/src/golf/ProfileState.cpp b/samples/golf/src/golf/ProfileState.cpp index 44ced307d..9dff1bf75 100644 --- a/samples/golf/src/golf/ProfileState.cpp +++ b/samples/golf/src/golf/ProfileState.cpp @@ -1044,7 +1044,7 @@ void ProfileState::buildScene() #ifdef USE_GNS randomButton.getComponent().setNextIndex(ButtonCancel, ButtonWorkshop); #else - entity.getComponent().setNextIndex(ButtonCancel, ButtonHairColour); + randomButton.getComponent().setNextIndex(ButtonCancel, ButtonHairColour); #endif if (!Social::isSteamdeck()) { @@ -1085,8 +1085,8 @@ void ProfileState::buildScene() nameButton.getComponent().setNextIndex(ButtonWorkshop, ButtonBallSelect); nameButton.getComponent().setPrevIndex(ButtonWorkshop, ButtonCancel); #else - entity.getComponent().setNextIndex(ButtonDescUp, ButtonBallSelect); - entity.getComponent().setPrevIndex(ButtonNextHair, ButtonBallSelect); + nameButton.getComponent().setNextIndex(ButtonDescUp, ButtonBallSelect); + nameButton.getComponent().setPrevIndex(ButtonNextHair, ButtonBallSelect); #endif //ball arrow buttons diff --git a/samples/golf/src/golf/ShaderIncludes.inl b/samples/golf/src/golf/ShaderIncludes.inl index 42c38b520..982b56b9e 100644 --- a/samples/golf/src/golf/ShaderIncludes.inl +++ b/samples/golf/src/golf/ShaderIncludes.inl @@ -125,7 +125,7 @@ static inline const std::string HSV = R"( vec3 hsv2rgb(vec3 c) { - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec4 K = vec4(1.0, 0.666667, 0.333333, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } @@ -154,12 +154,12 @@ static inline const std::string WindCalc = R"( WindResult retVal = WindResult(vec2(0.0), vec2(0.0), 0.0); vec2 uv = localPos; //uv.x += u_windData.w * (hFreq + (hFreq * u_windData.y)); - uv.x += u_windData.w * hFreq; + uv.x = (u_windData.w * hFreq) + uv.x; retVal.highFreq.x = TEXTURE(u_noiseTexture, uv).r; uv = localPos; //uv.y += u_windData.w * (hFreq + (hFreq * u_windData.y)); - uv.y += u_windData.w * hFreq; + uv.y = (u_windData.w * hFreq) + uv.y; retVal.highFreq.y = TEXTURE(u_noiseTexture, uv).r; uv = worldPos; @@ -175,13 +175,13 @@ static inline const std::string WindCalc = R"( retVal.highFreq -= 1.0; retVal.highFreq *= u_windData.y; //retVal.highFreq *= hMagnitude; - retVal.highFreq *= hMagnitude + (hMagnitude * u_windData.y); + retVal.highFreq *= (hMagnitude * u_windData.y) + hMagnitude; retVal.lowFreq *= 2.0; retVal.lowFreq -= 1.0; - retVal.lowFreq *= (0.6 + (0.4 * u_windData.y)); + retVal.lowFreq *= ((0.4 * u_windData.y)+ 0.6); //retVal.lowFreq *= lMagnitude; - retVal.lowFreq *= lMagnitude + (lMagnitude * u_windData.y); + retVal.lowFreq *= (lMagnitude * u_windData.y) + lMagnitude; retVal.strength = u_windData.y; retVal.strength *= dirMagnitude; diff --git a/samples/golf/src/golf/TerrainShader.inl b/samples/golf/src/golf/TerrainShader.inl index 69977a698..5e79aa67c 100644 --- a/samples/golf/src/golf/TerrainShader.inl +++ b/samples/golf/src/golf/TerrainShader.inl @@ -73,16 +73,11 @@ static const std::string TerrainVertexShader = R"( //VARYING_OUT float v_viewDepth; #endif - vec3 lerp(vec3 a, vec3 b, float t) - { - return a + ((b - a) * t); - } - void main() { v_cameraWorldPosition = u_cameraWorldPosition; - vec4 position = u_worldMatrix * vec4(lerp(a_position.xyz, a_tangent, u_morphTime), 1.0); + vec4 position = u_worldMatrix * vec4(mix(a_position.xyz, a_tangent, u_morphTime), 1.0); //gl_Position = u_viewProjectionMatrix * position; vec4 vertPos = u_viewProjectionMatrix * position; @@ -105,7 +100,7 @@ static const std::string TerrainVertexShader = R"( #endif //this should be a slerp really but lerp is good enough for low spec shenanigans - v_normal = u_normalMatrix * lerp(a_normal, a_bitangent, u_morphTime); + v_normal = u_normalMatrix * mix(a_normal, a_bitangent, u_morphTime); v_colour = a_colour; v_worldPosition = position.xyz; v_texCoord = vec2(position.x / 100.0, position.z / -62.5); diff --git a/samples/golf/src/golf/TreeShader.inl b/samples/golf/src/golf/TreeShader.inl index 3a126e58e..cec971de8 100644 --- a/samples/golf/src/golf/TreeShader.inl +++ b/samples/golf/src/golf/TreeShader.inl @@ -92,7 +92,7 @@ R"( float offset = randVal * u_randAmount; vec4 position = a_position; #if defined(HQ) - position.xyz += (a_normal * offset); + position.xyz = (a_normal * offset) + position.xyz; #endif v_data.normal = normalMatrix * a_normal; @@ -101,16 +101,16 @@ R"( #if !defined(HQ) float t = (u_windData.w * 15.0) + gl_InstanceID + gl_VertexID; float highFreq = sin(t) * Amp * a_colour.r; - position.y += highFreq * (0.2 + (0.8 * u_windData.y)); + position.y = (highFreq * ((0.8 * u_windData.y) + 0.2)) + position.y; #endif vec4 worldPosition = worldMatrix * position; //wind #if defined (HQ) -WindResult windResult = getWindData(position.xz, worldPosition.xz); -windResult.lowFreq *= 0.5 + (0.5 * u_windData.y); -windResult.highFreq *= 0.5 + (0.5 * u_windData.y); + WindResult windResult = getWindData(position.xz, worldPosition.xz); + windResult.lowFreq *= (0.5 * u_windData.y) + 0.5; + windResult.highFreq *= (0.5 * u_windData.y) + 0.5; float x = windResult.highFreq.x; float y = windResult.lowFreq.y; @@ -125,27 +125,27 @@ windResult.highFreq *= 0.5 + (0.5 * u_windData.y); v_data.rotation[1]= rot; dirStrength += 1.0; - dirStrength /= 2.0; + dirStrength *= 0.5; windOffset += windDir * u_windData.y * dirStrength * 2.0; worldPosition.xyz += windOffset * MaxWindOffset * u_windData.y; -worldPosition.x += windResult.lowFreq.x; -worldPosition.z += windResult.lowFreq.y; + worldPosition.x += windResult.lowFreq.x; + worldPosition.z += windResult.lowFreq.y; #else float time = (u_windData.w * 15.0) + gl_InstanceID; - float x = sin(time * 2.0) / 8.0; - float y = cos(time) / 2.0; + float x = sin(time * 2.0) * 0.125; + float y = cos(time) * 0.5; vec3 windOffset = vec3(x, y, x) * a_colour.b * 0.1; vec3 windDir = normalize(vec3(u_windData.x, 0.f, u_windData.z)); float dirStrength = a_colour.b; - windOffset += windDir * u_windData.y * dirStrength; - worldPosition.xyz += windOffset * MaxWindOffset * u_windData.y; + windOffset = (windDir * u_windData.y * dirStrength) + windOffset; + worldPosition.xyz = (windOffset * MaxWindOffset * u_windData.y) + worldPosition.xyz; #endif #if defined(WOBBLE) @@ -166,16 +166,16 @@ worldPosition.z += windResult.lowFreq.y; #if defined(HQ) float variation = rand(-vec2(gl_VertexID)); - variation = 0.5 + (0.5 * variation); + variation = (0.5 * variation) + 0.5; - float pointSize = u_leafSize + ((u_leafSize * 2.0) * offset); + float pointSize = ((u_leafSize * 2.0) * offset) + u_leafSize; pointSize *= variation; vec3 camForward = vec3(u_viewMatrix[0][2], u_viewMatrix[1][2], u_viewMatrix[2][2]); vec3 eyeDir = normalize(u_cameraWorldPosition - worldPosition.xyz); float facingAmount = dot(v_data.normal, camForward); - pointSize *= 0.8 + (0.2 * facingAmount); + pointSize *= (0.2 * facingAmount) + 0.8; //shrink 'backfacing' to zero //pointSize *= step(0.0, facingAmount); @@ -323,8 +323,8 @@ R"( float amount = dot(normalize(v_data.normal), -u_lightDirection); amount *= 2.0; amount = round(amount); - amount /= 2.0; - amount = 0.4 + (amount * 0.6); + amount *= 0.5; + amount = (amount * 0.6) + 0.4; #if defined(VERTEX_COLOURED) vec3 colour = mix(complementaryColour(v_data.colour.rgb), v_data.colour.rgb, amount); #else @@ -468,8 +468,8 @@ std::string BranchFragment = R"( float amount = dot(normalize(v_normal), -u_lightDirection); amount *= 2.0; amount = round(amount); - amount /= 2.0; - amount = 0.6 + (amount * 0.4); + amount *= 0.5; + amount = (amount * 0.4) + 0.6; colour.rgb *= amount * v_darkenAmount; FRAG_OUT = colour; diff --git a/samples/golf/src/golf/WaterShader.inl b/samples/golf/src/golf/WaterShader.inl index 7bbe435b5..e07b5950d 100644 --- a/samples/golf/src/golf/WaterShader.inl +++ b/samples/golf/src/golf/WaterShader.inl @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------- -Matt Marchant 2021 - 2022 +Matt Marchant 2021 - 2023 http://trederia.blogspot.com Super Video Golf - zlib licence. @@ -119,7 +119,7 @@ uniform sampler2DArray u_depthMap; const float zNear = 10.02; //note these have to match the near/far plane of the depthmap camera const float zFar = 10.48; - return zNear * zFar / (zFar + d * (zNear - zFar)); + return zNear * zFar / ((d * (zNear - zFar)) + zFar); } #if !defined(NO_DEPTH) @@ -133,7 +133,7 @@ uniform sampler2DArray u_depthMap; float index = clamp((y * ColCount) + x, 0.0, 39.0); float u = (v_worldPosition.x - (x * MetresPerTexture)) / MetresPerTexture; - float v = -(v_worldPosition.z + (y * MetresPerTexture)) / MetresPerTexture; + float v = -((y * MetresPerTexture) + v_worldPosition.z) / MetresPerTexture; float stepX = step(0.0, v_worldPosition.x) * (1.0 - step(320.0, v_worldPosition.x)); float stepY = step(0.0, -v_worldPosition.z) * (1.0 - step(200.0, -v_worldPosition.z)); @@ -151,11 +151,11 @@ uniform sampler2DArray u_depthMap; vec2 pixelCoord = floor(mod(coord, 1.0) * PixelCount); float wave = noise(pixelCoord); - wave *= sin(waveSpeed + (wave * 300.0)) + 1.0 / 2.0; + wave *= sin(waveSpeed + (wave * 300.0)) + 1.0 * 0.5; wave = smoothstep(0.25, 1.0, wave); - float coordOffset = sin(((u_windData.w * 15.0) / 4.0) + (gl_FragCoord.z * 325.0)) * 0.0002; + float coordOffset = sin(((u_windData.w * 15.0) * 0.25) + (gl_FragCoord.z * 325.0)) * 0.0002; coordOffset += wave * 0.002; //reflection @@ -169,14 +169,14 @@ uniform sampler2DArray u_depthMap; float fresnel = dot(reflect(-eyeDirection, normal), normal); const float bias = 0.6; - fresnel = bias + (fresnel * (1.0 - bias)); + fresnel = (fresnel * (1.0 - bias)) + bias; vec3 blendedColour = mix(reflectColour.rgb, WaterColour.rgb, fresnel); float edgeWave = wave; //wave *= 0.2 * pow(reflectCoords.y, 4.0); - wave *= 0.01 + (0.19 * pow(reflectCoords.y, 4.0)); + wave *= (0.19 * pow(reflectCoords.y, 4.0)) + 0.01; blendedColour.rgb += wave; @@ -202,8 +202,8 @@ uniform sampler2DArray u_depthMap; depth *= findClosest(x,y,pow(depth, 3.0)); edgeWave *= 0.07; - blendedColour += edgeWave * depth; - blendedColour += depth * 0.18; + blendedColour = (edgeWave * depth) + blendedColour; + blendedColour = (depth * 0.18) + blendedColour; #endif FRAG_OUT = vec4(blendedColour, 1.0); })"; diff --git a/samples/scratchpad/src/MyApp.cpp b/samples/scratchpad/src/MyApp.cpp index 4f65f8608..c5a289538 100644 --- a/samples/scratchpad/src/MyApp.cpp +++ b/samples/scratchpad/src/MyApp.cpp @@ -164,8 +164,8 @@ bool MyApp::initialise() m_stateStack.registerState(States::ScratchPad::Log); #ifdef CRO_DEBUG_ - //m_stateStack.pushState(States::ScratchPad::Log); - m_stateStack.pushState(States::ScratchPad::MainMenu); + m_stateStack.pushState(States::ScratchPad::BatCat); + //m_stateStack.pushState(States::ScratchPad::MainMenu); #else m_stateStack.pushState(States::ScratchPad::MainMenu); #endif