mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 19:45:40 +00:00
Fix #6386
Use `gl_FragCoords` instead passing the normalised screen-space coordinates to the fragment shader in a numerically unstable way.
This commit is contained in:
parent
b72d59b012
commit
fbc7cf5e65
2 changed files with 3 additions and 12 deletions
|
@ -132,7 +132,6 @@ vec2 normalCoords(vec2 uv, float scale, float speed, float time, float timer1, f
|
||||||
return uv * (WAVE_SCALE * scale) + WIND_DIR * time * (WIND_SPEED * speed) -(previousNormal.xy/previousNormal.zz) * WAVE_CHOPPYNESS + vec2(time * timer1,time * timer2);
|
return uv * (WAVE_SCALE * scale) + WIND_DIR * time * (WIND_SPEED * speed) -(previousNormal.xy/previousNormal.zz) * WAVE_CHOPPYNESS + vec2(time * timer1,time * timer2);
|
||||||
}
|
}
|
||||||
|
|
||||||
varying vec3 screenCoordsPassthrough;
|
|
||||||
varying vec4 position;
|
varying vec4 position;
|
||||||
varying float linearDepth;
|
varying float linearDepth;
|
||||||
|
|
||||||
|
@ -152,6 +151,8 @@ uniform vec3 nodePosition;
|
||||||
|
|
||||||
uniform float rainIntensity;
|
uniform float rainIntensity;
|
||||||
|
|
||||||
|
uniform vec2 screenRes;
|
||||||
|
|
||||||
#define PER_PIXEL_LIGHTING 0
|
#define PER_PIXEL_LIGHTING 0
|
||||||
|
|
||||||
#include "shadows_fragment.glsl"
|
#include "shadows_fragment.glsl"
|
||||||
|
@ -178,8 +179,7 @@ void main(void)
|
||||||
|
|
||||||
float shadow = unshadowedLightRatio(linearDepth);
|
float shadow = unshadowedLightRatio(linearDepth);
|
||||||
|
|
||||||
vec2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
|
vec2 screenCoords = gl_FragCoord.xy / screenRes;
|
||||||
screenCoords.y = (1.0-screenCoords.y);
|
|
||||||
|
|
||||||
#define waterTimer osg_SimulationTime
|
#define waterTimer osg_SimulationTime
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
uniform mat4 projectionMatrix;
|
uniform mat4 projectionMatrix;
|
||||||
|
|
||||||
varying vec3 screenCoordsPassthrough;
|
|
||||||
varying vec4 position;
|
varying vec4 position;
|
||||||
varying float linearDepth;
|
varying float linearDepth;
|
||||||
|
|
||||||
|
@ -13,14 +12,6 @@ void main(void)
|
||||||
{
|
{
|
||||||
gl_Position = projectionMatrix * (gl_ModelViewMatrix * gl_Vertex);
|
gl_Position = projectionMatrix * (gl_ModelViewMatrix * gl_Vertex);
|
||||||
|
|
||||||
mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0,
|
|
||||||
0.0, -0.5, 0.0, 0.0,
|
|
||||||
0.0, 0.0, 0.5, 0.0,
|
|
||||||
0.5, 0.5, 0.5, 1.0);
|
|
||||||
|
|
||||||
vec4 texcoordProj = ((scalemat) * ( gl_Position));
|
|
||||||
screenCoordsPassthrough = texcoordProj.xyw;
|
|
||||||
|
|
||||||
position = gl_Vertex;
|
position = gl_Vertex;
|
||||||
|
|
||||||
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
|
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
|
||||||
|
|
Loading…
Reference in a new issue