label.vs (pymol-v2.1.0.tar.bz2) | : | label.vs (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
#ifdef PURE_OPENGL_ES_2 | ||||
precision highp float; | ||||
#endif | ||||
#include webgl_header.vs | ||||
attribute vec4 attr_targetpos; | ||||
attribute vec4 attr_worldpos; | attribute vec4 attr_worldpos; | |||
attribute vec3 attr_screenoffset; | attribute vec3 attr_screenoffset; | |||
attribute vec2 attr_texcoords; | attribute vec2 attr_texcoords; | |||
attribute vec3 attr_screenworldoffset; | attribute vec3 attr_screenworldoffset; | |||
attribute vec4 attr_t_pickcolor; // changed name for ATI, optional attribute | attribute vec4 attr_pickcolor; | |||
// cannot be first/0 index, ATI sets index | attribute float attr_relative_mode; | |||
// alphabetically | ||||
varying vec2 textureLookup ; | varying vec2 textureLookup ; | |||
varying vec3 normalizedViewCoordinate; | varying vec3 normalizedViewCoordinate; | |||
varying vec4 pickcolor ; | varying vec4 pickcolor ; | |||
uniform vec2 screenSize; | uniform vec2 screenSize; | |||
uniform vec2 pixelSize; | ||||
uniform float aspectRatioAdjustment; | ||||
uniform float screenOriginVertexScale; | uniform float screenOriginVertexScale; | |||
uniform float scaleByVertexScale; | ||||
uniform float labelTextureSize; | ||||
varying float fog; | varying float fog; | |||
uniform float fog_enabled; // actually bool | ||||
uniform float front; | ||||
uniform float clipRange; | ||||
vec4 normalizeVec4(vec4 point){ | ||||
return vec4(point.xyz/point.w, 1.); | ||||
} | ||||
float convertNormalZToScreenZ(float normalz){ | ||||
float a_centerN = (normalz + 1.) / 2.; | ||||
float ptInPreProjectionZ = -(front + clipRange * a_centerN); | ||||
vec4 ptInPreProjection = vec4(0., 0., ptInPreProjectionZ, 1.); | ||||
vec4 projVect = g_ProjectionMatrix * ptInPreProjection; | ||||
return projVect.z / projVect.w; | ||||
} | ||||
void main() | void main() | |||
{ | { | |||
vec4 pos = gl_ModelViewProjectionMatrix * attr_worldpos; | float drawConnector, isProjected, isScreenCoord, isPixelCoord, zTarget; | |||
pos /= pos.w; | ||||
pos.xy += attr_screenworldoffset.xy / (screenSize.xy * screenOriginVertexScale | ||||
); | ||||
pos.xy += attr_screenoffset.xy * 2. / screenSize * vec2(aspectRatioAdjustment, | ||||
1.); | ||||
// rounding to nearest pixel | drawConnector = step(1., mod(attr_relative_mode, 2.)); | |||
pos.xy = (pixelSize * floor((pos.xy + 1.) / pixelSize)) - 1.; | isScreenCoord = step(2., mod(attr_relative_mode, 4.)); | |||
isPixelCoord = step(4., mod(attr_relative_mode, 8.)); | ||||
zTarget = step(8., mod(attr_relative_mode, 16.)); | ||||
isProjected = step(isPixelCoord + isScreenCoord, 0.5); | ||||
float screenVertexScale = scaleByVertexScale * screenOriginVertexScale * label | ||||
TextureSize + (1. - scaleByVertexScale); | ||||
vec3 viewVector = vec3(vec4(0.,0.,-1.,0.) * g_ModelViewMatrix); | ||||
vec4 transformedPosition = g_ProjectionMatrix * g_ModelViewMatrix * attr_world | ||||
pos; | ||||
vec4 targetPosition = normalizeVec4(g_ProjectionMatrix * g_ModelViewMatrix * a | ||||
ttr_targetpos); | ||||
transformedPosition.xyz = transformedPosition.xyz/transformedPosition.w; | ||||
transformedPosition.xy = ( floor(transformedPosition.xy * screenSize + .5 ) + | ||||
.5 ) / screenSize; | ||||
vec3 viewVector = vec3(gl_ModelViewMatrixTranspose * vec4(0.,0., -1.,0.)); | ||||
vec4 a_center = (attr_worldpos + attr_screenworldoffset.z * vec4(viewVector, 0 .)); | vec4 a_center = (attr_worldpos + attr_screenworldoffset.z * vec4(viewVector, 0 .)); | |||
vec4 transformedPositionZ = gl_ModelViewProjectionMatrix * a_center; | vec4 transformedPositionZ = g_ProjectionMatrix * g_ModelViewMatrix * a_center; | |||
pos.z = transformedPositionZ.z / transformedPositionZ.w; | transformedPositionZ.xyz = transformedPositionZ.xyz/transformedPositionZ.w; | |||
transformedPositionZ.w = 1.; | ||||
vec2 pixOffset = ((2. * attr_worldpos.xy / screenSize) - 1.); | ||||
transformedPosition = isProjected * transformedPosition + isScreenCoord * attr | ||||
_worldpos + isPixelCoord * vec4(pixOffset.x, pixOffset.y, -0.5, 0.); | ||||
transformedPosition.xy = transformedPosition.xy + attr_screenworldoffset.xy/(s | ||||
creenSize*screenOriginVertexScale); | ||||
transformedPosition.z = (1.-zTarget) * ((isProjected * transformedPositionZ.z) | ||||
+ (1.-isProjected) * convertNormalZToScreenZ(attr_worldpos.z)) + zTarget * targ | ||||
etPosition.z; | ||||
gl_Position = pos; | transformedPosition.xy += attr_screenoffset.xy * 2./(screenSize.xy*screenVerte | |||
xScale); | ||||
transformedPosition.w = 1.; | ||||
gl_Position = transformedPosition; | ||||
textureLookup = attr_texcoords; | textureLookup = attr_texcoords; | |||
normalizedViewCoordinate = pos.xyz / 2.0 + 0.5; | normalizedViewCoordinate = (gl_Position.xyz/gl_Position.w) / 2.0 + 0.5; | |||
if (fog_enabled > 0.5) { | #ifdef depth_cue | |||
vec3 eye_pos = vec3(gl_ModelViewMatrix * attr_worldpos); | vec3 eye_pos = mix(attr_worldpos, g_ModelViewMatrix * attr_worldpos, isProject | |||
fog = max(0.0, (gl_Fog.end - abs(eye_pos.z)) * gl_Fog.scale); | ed).xyz; | |||
} else { | fog = (g_Fog_end + eye_pos.z) * g_Fog_scale; | |||
fog = max(fog, 0.0); | ||||
#else | ||||
fog = 1.1; // >= 1.0 | fog = 1.1; // >= 1.0 | |||
} | #endif | |||
pickcolor = attr_t_pickcolor; | ||||
pickcolor = attr_pickcolor; | ||||
} | } | |||
End of changes. 14 change blocks. | ||||
26 lines changed or deleted | 70 lines changed or added |