Sha256: acfe0a8b24e7fb904590c37b1ad80d6452ba79575e31445067b8b2c8a89fa146

Contents?: true

Size: 1.76 KB

Versions: 12

Compression:

Stored size: 1.76 KB

Contents

attribute vec3 tangent;

uniform vec4 lightPosition; // object space 
uniform vec4 lightPosition1; // object space 
uniform vec4 eyePosition;   // object space 
uniform vec4 spotDirection; // object space
uniform vec4 spotDirection1; // object space
uniform mat4 worldViewProj; // not actually used but here for compat with HLSL
uniform mat4 worldMatrix;
uniform mat4 texViewProj1;
uniform mat4 texViewProj2;


varying vec3 tangentEyeDir;
varying vec3 tangentLightDir[2];
varying vec3 tangentSpotDir[2];
varying vec4 shadowUV[2];

void main()
{
	gl_Position = ftransform();

	vec4 worldPos = worldMatrix * gl_Vertex;

	shadowUV[0] = texViewProj1 * worldPos;
	shadowUV[1] = texViewProj2 * worldPos;

	// pass the main uvs straight through unchanged 
	gl_TexCoord[0] = gl_MultiTexCoord0;

	// calculate tangent space light vector 
	// Get object space light direction 
    vec3 lightDir = normalize(lightPosition.xyz -  (gl_Vertex.xyz * lightPosition.w));
	vec3 lightDir1 = normalize(lightPosition1.xyz -  (gl_Vertex.xyz * lightPosition1.w));
	
	vec3 eyeDir = (eyePosition - gl_Vertex).xyz; 

	// Calculate the binormal (NB we assume both normal and tangent are 
	// already normalised) 
	vec3 binormal = cross(gl_Normal, tangent); 

	// Form a rotation matrix out of the vectors 
	mat3 rotation = mat3(tangent, binormal, gl_Normal); 
    
	// Transform the light vector according to this matrix 
	tangentLightDir[0] = normalize(rotation * lightDir); 
	tangentLightDir[1] = normalize(rotation * lightDir1); 
	// Invert the Y on the eye dir since we'll be using this to alter UVs and
	// GL has Y inverted
	tangentEyeDir = normalize(rotation * eyeDir) * vec3(1, -1, 1); 

	tangentSpotDir[0] = normalize(rotation * -spotDirection.xyz);
	tangentSpotDir[1] = normalize(rotation * -spotDirection1.xyz);	
}

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
ruby-ogre-0.0.5-x86-linux deps/share/OGRE/media/materials/programs/OffsetMappingVp.glsl
ruby-ogre-0.0.4-x86-linux deps/share/OGRE/media/materials/programs/OffsetMappingVp.glsl
ruby-ogre-0.0.3-x86-linux deps/share/OGRE/media/materials/programs/OffsetMappingVp.glsl
ruby-ogre-0.0.2-x86-linux deps/share/OGRE/media/materials/programs/OffsetMappingVp.glsl
ruby-ogre-0.0.1-x86-linux deps/share/OGRE/media/materials/programs/OffsetMappingVp.glsl
ogre.rb-0.2-i686-linux samples/media/materials/programs/OffsetMappingVp.glsl
ogre.rb-0.2-i386-mswin32 samples/media/materials/programs/OffsetMappingVp.glsl
ogre.rb-0.1-i686-linux samples/media/materials/programs/OffsetMappingVp.glsl
ogre.rb-0.1-i386-mswin32 samples/media/materials/programs/OffsetMappingVp.glsl
ogre.rb-0.2-x86_64-linux samples/media/materials/programs/OffsetMappingVp.glsl
shattered_ogrerb-0.5.0.2 vendor/ogrerb/samples/media/materials/programs/OffsetMappingVp.glsl
shattered_ogrerb-0.5.1 vendor/ogrerb/samples/media/materials/programs/OffsetMappingVp.glsl