All pastes #556234 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-06-10 13:58 UTC
rendered paste body
[renderpass]
feature=ERPF_USER0
lang=glsl
quality=100
stage=ERPS_MAIN
numtextures=4
[vertexshader]
code=\
uniform vec3 fvEyePosition;\
\
varying vec2 Texcoord;\
varying vec3 ViewDirection;\
varying vec3 LightDirection;\
varying vec3 nr;\
varying vec3 ViewDirectionraw;\
\
attribute vec3 tangent;\
   \
void main( void )\
{\
   gl_Position = ftransform();\
   Texcoord    = gl_MultiTexCoord0.xy;\
    \
   vec4 fvObjectPosition = gl_ModelViewMatrix * gl_Vertex;\
   \
   ViewDirectionraw  = fvEyePosition - fvObjectPosition.xyz;\
   vec3 fvLightDirection = gl_LightSource[0].position.xyz - fvObjectPosition.xyz;\
     \
   vec3 fvNormal         = (gl_ModelViewMatrix * vec4(gl_Normal,0)).xyz;\
   vec3 fvTangent        = (gl_ModelViewMatrix * vec4(gl_Normal,0)).xyz;\
   vec3 fvBinormal       = cross(fvTangent.xyz , fvNormal.xyz);\
   \
\
   nr= fvNormal;\
   gl_FrontColor=gl_Color;\
   ViewDirection.x  = dot( fvTangent, ViewDirectionraw );\
   ViewDirection.y  = dot( fvBinormal,ViewDirectionraw );\
   ViewDirection.z  = dot( fvNormal, ViewDirectionraw );\
   \
   LightDirection.x  = dot( fvTangent, fvLightDirection.xyz );\
   LightDirection.y  = dot( fvBinormal, fvLightDirection.xyz );\
   LightDirection.z  = dot( fvNormal, fvLightDirection.xyz );\
   \
}
[/vertexshader]
[pixelshader]
code=\
\
uniform sampler2D tex0;\
uniform sampler2D tex1;\
uniform samplerCube tex2;\
uniform samplerCube tex3;\
varying vec2 Texcoord;\
varying vec3 ViewDirection;\
varying vec3 ViewDirectionraw;\
varying vec3 LightDirection;\
varying vec3 nr;\
void main( void )\
{\
   vec3  fvLightDirection = normalize( LightDirection );\
   vec3  fvNormal         = normalize( ( texture2D( tex1, Texcoord ).xyz * 2.0 ) - 1.0 );\
   float fNDotL           = dot( fvNormal, fvLightDirection ); \
   \
   vec3  fvReflection     = normalize( ( ( 2.0 * fvNormal ) * fNDotL ) - fvLightDirection ); \
   vec3  fvViewDirection  = normalize( ViewDirection );\
   float fRDotV           = max( 0.0, dot( fvReflection, fvViewDirection ) );\
   \
   vec4  fvBaseColor      = texture2D( tex0, Texcoord );\
 \
   vec4  AmbientAo = textureCube(tex2,nr)*gl_Color;\
   vec4  Refl = max(textureCube(tex3,nr)*(50/dot(nr, ViewDirectionraw)),0);\
   vec4  fvTotalAmbient   = AmbientAo ;\
   vec4  fvTotalDiffuse   = fNDotL * fvBaseColor; \
   vec4  fvTotalSpecular  = pow( fRDotV, fvBaseColor.a *30 );\
  \
   gl_FragColor = normalize(vec4(nr,1));//fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular+Refl;\
       \
}
[/pixelshader]
[builtinparam]
name=fvEyePosition
type=ERPPB_EYEPOS_VEC3
[/builtinparam]
[/renderpass]