Convert water/ripple defines to camelCase

pull/3235/head
Alexei Kotov 9 months ago
parent 612177be09
commit f2e0129436

@ -161,7 +161,7 @@ CSMWorld::Data::Data(ToUTF8::FromType encoding, const Files::PathContainer& data
defines["radialFog"] = "0"; defines["radialFog"] = "0";
defines["lightingModel"] = "0"; defines["lightingModel"] = "0";
defines["reverseZ"] = "0"; defines["reverseZ"] = "0";
defines["refraction_enabled"] = "0"; defines["waterRefraction"] = "0";
for (const auto& define : shadowDefines) for (const auto& define : shadowDefines)
defines[define.first] = define.second; defines[define.first] = define.second;
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines); mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);

@ -441,7 +441,7 @@ namespace MWRender
globalDefines["radialFog"] = (exponentialFog || Settings::fog().mRadialFog) ? "1" : "0"; globalDefines["radialFog"] = (exponentialFog || Settings::fog().mRadialFog) ? "1" : "0";
globalDefines["exponentialFog"] = exponentialFog ? "1" : "0"; globalDefines["exponentialFog"] = exponentialFog ? "1" : "0";
globalDefines["skyBlending"] = mSkyBlending ? "1" : "0"; globalDefines["skyBlending"] = mSkyBlending ? "1" : "0";
globalDefines["refraction_enabled"] = "0"; globalDefines["waterRefraction"] = "0";
globalDefines["useGPUShader4"] = "0"; globalDefines["useGPUShader4"] = "0";
globalDefines["useOVR_multiview"] = "0"; globalDefines["useOVR_multiview"] = "0";
globalDefines["numViews"] = "1"; globalDefines["numViews"] = "1";

@ -100,7 +100,7 @@ namespace MWRender
{ {
auto& shaderManager = mResourceSystem->getSceneManager()->getShaderManager(); auto& shaderManager = mResourceSystem->getSceneManager()->getShaderManager();
Shader::ShaderManager::DefineMap defineMap = { { "ripple_map_size", std::to_string(sRTTSize) + ".0" } }; Shader::ShaderManager::DefineMap defineMap = { { "rippleMapSize", std::to_string(sRTTSize) + ".0" } };
osg::ref_ptr<osg::Shader> vertex = shaderManager.getShader("fullscreen_tri.vert", {}, osg::Shader::VERTEX); osg::ref_ptr<osg::Shader> vertex = shaderManager.getShader("fullscreen_tri.vert", {}, osg::Shader::VERTEX);

@ -700,11 +700,11 @@ namespace MWRender
{ {
// use a define map to conditionally compile the shader // use a define map to conditionally compile the shader
std::map<std::string, std::string> defineMap; std::map<std::string, std::string> defineMap;
defineMap["refraction_enabled"] = std::string(mRefraction ? "1" : "0"); defineMap["waterRefraction"] = std::string(mRefraction ? "1" : "0");
const int rippleDetail = Settings::water().mRainRippleDetail; const int rippleDetail = Settings::water().mRainRippleDetail;
defineMap["rain_ripple_detail"] = std::to_string(rippleDetail); defineMap["rainRippleDetail"] = std::to_string(rippleDetail);
defineMap["ripple_map_world_scale"] = std::to_string(RipplesSurface::sWorldScaleFactor); defineMap["rippleMapWorldScale"] = std::to_string(RipplesSurface::sWorldScaleFactor);
defineMap["ripple_map_size"] = std::to_string(RipplesSurface::sRTTSize) + ".0"; defineMap["rippleMapSize"] = std::to_string(RipplesSurface::sRTTSize) + ".0";
defineMap["sunlightScattering"] = Settings::water().mSunlightScattering ? "1" : "0"; defineMap["sunlightScattering"] = Settings::water().mSunlightScattering ? "1" : "0";
defineMap["wobblyShores"] = Settings::water().mWobblyShores ? "1" : "0"; defineMap["wobblyShores"] = Settings::water().mWobblyShores ? "1" : "0";

@ -13,7 +13,7 @@ uniform vec2 offset;
void main() void main()
{ {
vec2 uv = (gl_FragCoord.xy + offset) / @ripple_map_size; vec2 uv = (gl_FragCoord.xy + offset) / @rippleMapSize;
vec4 color = texture2D(imageIn, uv); vec4 color = texture2D(imageIn, uv);
float wavesizeMultiplier = getTemporalWaveSizeMultiplier(osg_SimulationTime); float wavesizeMultiplier = getTemporalWaveSizeMultiplier(osg_SimulationTime);

@ -6,9 +6,9 @@ uniform sampler2D imageIn;
void main() void main()
{ {
vec2 uv = gl_FragCoord.xy / @ripple_map_size; vec2 uv = gl_FragCoord.xy / @rippleMapSize;
float pixelSize = 1.0 / @ripple_map_size; float pixelSize = 1.0 / @rippleMapSize;
float oneOffset = pixelSize; float oneOffset = pixelSize;
float oneAndHalfOffset = 1.5 * pixelSize; float oneAndHalfOffset = 1.5 * pixelSize;

@ -144,7 +144,7 @@ void main(void)
float fresnel = clamp(fresnel_dielectric(viewDir, normal, ior), 0.0, 1.0); float fresnel = clamp(fresnel_dielectric(viewDir, normal, ior), 0.0, 1.0);
vec2 screenCoordsOffset = normal.xy * REFL_BUMP; vec2 screenCoordsOffset = normal.xy * REFL_BUMP;
#if @refraction_enabled #if @waterRefraction
float depthSample = linearizeDepth(sampleRefractionDepthMap(screenCoords), near, far); float depthSample = linearizeDepth(sampleRefractionDepthMap(screenCoords), near, far);
float surfaceDepth = linearizeDepth(gl_FragCoord.z, near, far); float surfaceDepth = linearizeDepth(gl_FragCoord.z, near, far);
float realWaterDepth = depthSample - surfaceDepth; // undistorted water depth in view direction, independent of frustum float realWaterDepth = depthSample - surfaceDepth; // undistorted water depth in view direction, independent of frustum
@ -169,7 +169,7 @@ void main(void)
vec3 rainSpecular = abs(rainRipple.w)*mix(skyColorEstimate, vec3(1.0), 0.05)*0.5; vec3 rainSpecular = abs(rainRipple.w)*mix(skyColorEstimate, vec3(1.0), 0.05)*0.5;
float waterTransparency = clamp(fresnel * 6.0 + specular, 0.0, 1.0); float waterTransparency = clamp(fresnel * 6.0 + specular, 0.0, 1.0);
#if @refraction_enabled #if @waterRefraction
// selectively nullify screenCoordsOffset to eliminate remaining shore artifacts, not needed for reflection // selectively nullify screenCoordsOffset to eliminate remaining shore artifacts, not needed for reflection
if (cameraPos.z > 0.0 && realWaterDepth <= VISIBILITY_DEPTH && waterDepthDistorted > VISIBILITY_DEPTH) if (cameraPos.z > 0.0 && realWaterDepth <= VISIBILITY_DEPTH && waterDepthDistorted > VISIBILITY_DEPTH)
screenCoordsOffset = vec2(0.0); screenCoordsOffset = vec2(0.0);
@ -217,7 +217,7 @@ void main(void)
gl_FragData[0].rgb += specular * sunSpec.rgb + rainSpecular; gl_FragData[0].rgb += specular * sunSpec.rgb + rainSpecular;
#if @refraction_enabled && @wobblyShores #if @waterRefraction && @wobblyShores
// wobbly water: hard-fade into refraction texture at extremely low depth, with a wobble based on normal mapping // wobbly water: hard-fade into refraction texture at extremely low depth, with a wobble based on normal mapping
vec3 normalShoreRippleRain = texture2D(normalMap,normalCoords(UV, 2.0, 2.7, -1.0*waterTimer, 0.05, 0.1, normal3)).rgb - 0.5 vec3 normalShoreRippleRain = texture2D(normalMap,normalCoords(UV, 2.0, 2.7, -1.0*waterTimer, 0.05, 0.1, normal3)).rgb - 0.5
+ texture2D(normalMap,normalCoords(UV, 2.0, 2.7, waterTimer, 0.04, -0.13, normal4)).rgb - 0.5; + texture2D(normalMap,normalCoords(UV, 2.0, 2.7, waterTimer, 0.04, -0.13, normal4)).rgb - 0.5;

@ -21,7 +21,7 @@ void main(void)
position = gl_Vertex; position = gl_Vertex;
worldPos = position.xyz + nodePosition.xyz; worldPos = position.xyz + nodePosition.xyz;
rippleMapUV = (worldPos.xy - playerPos.xy + (@ripple_map_size * @ripple_map_world_scale / 2.0)) / @ripple_map_size / @ripple_map_world_scale; rippleMapUV = (worldPos.xy - playerPos.xy + (@rippleMapSize * @rippleMapWorldScale / 2.0)) / @rippleMapSize / @rippleMapWorldScale;
vec4 viewPos = modelToView(gl_Vertex); vec4 viewPos = modelToView(gl_Vertex);
linearDepth = getLinearDepth(gl_Position.z, viewPos.z); linearDepth = getLinearDepth(gl_Position.z, viewPos.z);

@ -9,7 +9,7 @@ vec4 sampleReflectionMap(vec2 uv)
return texture2D(reflectionMap, uv); return texture2D(reflectionMap, uv);
} }
#if @refraction_enabled #if @waterRefraction
uniform sampler2D refractionMap; uniform sampler2D refractionMap;
uniform sampler2D refractionDepthMap; uniform sampler2D refractionDepthMap;

@ -6,7 +6,7 @@
vec4 sampleReflectionMap(vec2 uv); vec4 sampleReflectionMap(vec2 uv);
#if @refraction_enabled #if @waterRefraction
vec4 sampleRefractionMap(vec2 uv); vec4 sampleRefractionMap(vec2 uv);
float sampleRefractionDepthMap(vec2 uv); float sampleRefractionDepthMap(vec2 uv);
#endif #endif

@ -12,7 +12,7 @@ vec4 sampleReflectionMap(vec2 uv)
return texture(reflectionMap, vec3((uv), gl_ViewID_OVR)); return texture(reflectionMap, vec3((uv), gl_ViewID_OVR));
} }
#if @refraction_enabled #if @waterRefraction
uniform sampler2DArray refractionMap; uniform sampler2DArray refractionMap;
uniform sampler2DArray refractionDepthMap; uniform sampler2DArray refractionDepthMap;

@ -1,8 +1,6 @@
#ifndef LIB_WATER_RIPPLES #ifndef LIB_WATER_RIPPLES
#define LIB_WATER_RIPPLES #define LIB_WATER_RIPPLES
#define RAIN_RIPPLE_DETAIL @rain_ripple_detail
const float RAIN_RIPPLE_GAPS = 10.0; const float RAIN_RIPPLE_GAPS = 10.0;
const float RAIN_RIPPLE_RADIUS = 0.2; const float RAIN_RIPPLE_RADIUS = 0.2;
@ -51,7 +49,7 @@ vec4 circle(vec2 coords, vec2 corner, float adjusted_time)
float d = length(toCenter); float d = length(toCenter);
float ringfollower = (phase-d/r)/RAIN_RING_TIME_OFFSET-1.0; // -1.0 ~ +1.0 cover the breadth of the ripple's ring float ringfollower = (phase-d/r)/RAIN_RING_TIME_OFFSET-1.0; // -1.0 ~ +1.0 cover the breadth of the ripple's ring
#if RAIN_RIPPLE_DETAIL > 0 #if @rainRippleDetail > 0
// normal mapped ripples // normal mapped ripples
if(ringfollower < -1.0 || ringfollower > 1.0) if(ringfollower < -1.0 || ringfollower > 1.0)
return vec4(0.0); return vec4(0.0);
@ -88,7 +86,7 @@ vec4 rain(vec2 uv, float time)
vec2 f_part = fract(uv); vec2 f_part = fract(uv);
vec2 i_part = floor(uv); vec2 i_part = floor(uv);
float adjusted_time = time * 1.2 + randPhase(i_part); float adjusted_time = time * 1.2 + randPhase(i_part);
#if RAIN_RIPPLE_DETAIL > 0 #if @rainRippleDetail > 0
vec4 a = circle(f_part, i_part, adjusted_time); vec4 a = circle(f_part, i_part, adjusted_time);
vec4 b = circle(f_part, i_part, adjusted_time - RAIN_RING_TIME_OFFSET); vec4 b = circle(f_part, i_part, adjusted_time - RAIN_RING_TIME_OFFSET);
vec4 c = circle(f_part, i_part, adjusted_time - RAIN_RING_TIME_OFFSET*2.0); vec4 c = circle(f_part, i_part, adjusted_time - RAIN_RING_TIME_OFFSET*2.0);
@ -115,11 +113,11 @@ vec4 rainCombined(vec2 uv, float time) // returns ripple normal in xyz and fake
return return
rain(uv, time) rain(uv, time)
+ rain(complex_mult(uv, vec2(0.4, 0.7)) + vec2(1.2, 3.0),time) + rain(complex_mult(uv, vec2(0.4, 0.7)) + vec2(1.2, 3.0),time)
#if RAIN_RIPPLE_DETAIL == 2 #if @rainRippleDetail == 2
+ rain(uv * 0.75 + vec2( 3.7,18.9),time) + rain(uv * 0.75 + vec2( 3.7,18.9),time)
+ rain(uv * 0.9 + vec2( 5.7,30.1),time) + rain(uv * 0.9 + vec2( 5.7,30.1),time)
+ rain(uv * 1.0 + vec2(10.5 ,5.7),time) + rain(uv * 1.0 + vec2(10.5 ,5.7),time)
#endif #endif
; ;
} }

Loading…
Cancel
Save