mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Move to parallax.glsl
This commit is contained in:
parent
b4dda045a6
commit
b59b2c6d6d
@ -11,6 +11,7 @@ set(SHADER_FILES
|
||||
terrain_vertex.glsl
|
||||
terrain_fragment.glsl
|
||||
lighting.glsl
|
||||
parallax.glsl
|
||||
)
|
||||
|
||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR} ${DDIR} "${SHADER_FILES}")
|
||||
|
8
files/shaders/parallax.glsl
Normal file
8
files/shaders/parallax.glsl
Normal file
@ -0,0 +1,8 @@
|
||||
#define PARALLAX_SCALE 0.04
|
||||
#define PARALLAX_BIAS -0.02
|
||||
|
||||
vec2 getParallaxOffset(vec3 eyeDir, mat3 tbn, float height)
|
||||
{
|
||||
vec3 TSeyeDir = normalize((vec4(normalize(tbn * eyeDir),0)).xyz);
|
||||
return TSeyeDir.xy * ( height * PARALLAX_SCALE + PARALLAX_BIAS );
|
||||
}
|
@ -25,12 +25,11 @@ varying vec3 passViewPos;
|
||||
varying vec3 passNormal;
|
||||
|
||||
#if @parallax
|
||||
#define PARALLAX_SCALE 0.04
|
||||
#define PARALLAX_BIAS -0.02
|
||||
uniform mat4 osg_ViewMatrixInverse;
|
||||
#endif
|
||||
|
||||
#include "lighting.glsl"
|
||||
#include "parallax.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -53,9 +52,7 @@ void main()
|
||||
#if @parallax
|
||||
vec3 cameraPos = osg_ViewMatrixInverse[3].xyz;
|
||||
vec3 eyeDir = normalize(cameraPos - (osg_ViewMatrixInverse * vec4(passViewPos, 1)).xyz);
|
||||
vec3 TSeyeDir = normalize((vec4(normalize(tbn * eyeDir),0)).xyz);
|
||||
|
||||
adjustedUV += TSeyeDir.xy * ( normalTex.a * PARALLAX_SCALE + PARALLAX_BIAS );
|
||||
adjustedUV += getParallaxOffset(eyeDir, tbn, normalTex.a);
|
||||
|
||||
// update normal using new coordinates
|
||||
normalTex = texture2D(normalMap, adjustedUV);
|
||||
|
Loading…
Reference in New Issue
Block a user