Fix non-ALS runway shader not implementing shadows
This commit is contained in:
parent
d35c160a50
commit
fc33a8d71a
2 changed files with 97 additions and 1 deletions
|
@ -1041,7 +1041,7 @@
|
|||
|
||||
<program>
|
||||
<!-- <vertex-shader n="0">Shaders/include_fog.vert</vertex-shader> -->
|
||||
<vertex-shader n="1">Shaders/reflect-bump-spec.vert</vertex-shader>
|
||||
<vertex-shader n="1">Shaders/runway.vert</vertex-shader>
|
||||
<vertex-shader n="2">Shaders/shadows-include.vert</vertex-shader>
|
||||
<fragment-shader n="0">Shaders/include_fog.frag</fragment-shader>
|
||||
<fragment-shader n="1">Shaders/runway.frag</fragment-shader>
|
||||
|
@ -1205,6 +1205,27 @@
|
|||
<use>fogtype</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<!-- BEGIN shadows include -->
|
||||
<uniform>
|
||||
<name>shadow_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">10</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>shadows_enabled</name>
|
||||
<type>bool</type>
|
||||
<value>
|
||||
<use>shadows_enabled</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>sun_atlas_size</name>
|
||||
<type>int</type>
|
||||
<value>
|
||||
<use>sun_atlas_size</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<!-- END shadows include -->
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
||||
|
|
75
Shaders/runway.vert
Normal file
75
Shaders/runway.vert
Normal file
|
@ -0,0 +1,75 @@
|
|||
// -*- mode: C; -*-
|
||||
// Licence: GPL v2
|
||||
// © Emilian Huminiuc and Vivian Meazza 2011
|
||||
#version 120
|
||||
|
||||
varying vec3 rawpos;
|
||||
varying float fogCoord;
|
||||
varying vec3 VNormal;
|
||||
varying vec3 VTangent;
|
||||
varying vec3 VBinormal;
|
||||
varying vec3 Normal;
|
||||
varying vec3 vViewVec;
|
||||
varying vec3 reflVec;
|
||||
|
||||
varying vec4 Diffuse;
|
||||
varying float alpha;
|
||||
|
||||
uniform mat4 osg_ViewMatrixInverse;
|
||||
|
||||
attribute vec3 tangent;
|
||||
attribute vec3 binormal;
|
||||
|
||||
////fog "include"////////
|
||||
// uniform int fogType;
|
||||
//
|
||||
// void fog_Func(int type);
|
||||
/////////////////////////
|
||||
|
||||
void setupShadows(vec4 eyeSpacePos);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
rawpos = gl_Vertex.xyz / gl_Vertex.w;
|
||||
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||
ecPosition.xyz = ecPosition.xyz / ecPosition.w;
|
||||
//fogCoord = ecPosition.z;
|
||||
//fog_Func(fogType);
|
||||
|
||||
vec3 n = normalize(gl_Normal);
|
||||
vec3 t = cross(gl_Normal, vec3(1.0,0.0,0.0));
|
||||
vec3 b = cross(n,t);
|
||||
|
||||
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
VTangent = normalize(gl_NormalMatrix * tangent);
|
||||
VBinormal = normalize(gl_NormalMatrix * binormal);
|
||||
Normal = normalize(gl_Normal);
|
||||
|
||||
Diffuse = gl_Color * gl_LightSource[0].diffuse;
|
||||
//Diffuse= gl_Color.rgb * max(0.0, dot(normalize(VNormal), gl_LightSource[0].position.xyz));
|
||||
|
||||
// Super hack: if diffuse material alpha is less than 1, assume a
|
||||
// transparency animation is at work
|
||||
if (gl_FrontMaterial.diffuse.a < 1.0)
|
||||
alpha = gl_FrontMaterial.diffuse.a;
|
||||
else
|
||||
alpha = gl_Color.a;
|
||||
|
||||
// Vertex in eye coordinates
|
||||
vec3 vertVec = ecPosition.xyz;
|
||||
|
||||
vViewVec.x = dot(t, vertVec);
|
||||
vViewVec.y = dot(b, vertVec);
|
||||
vViewVec.z = dot(n, vertVec);
|
||||
|
||||
// calculate the reflection vector
|
||||
vec4 reflect_eye = vec4(reflect(vertVec, VNormal), 0.0);
|
||||
reflVec = normalize(gl_ModelViewMatrixInverse * reflect_eye).xyz;
|
||||
|
||||
gl_FrontColor = gl_FrontMaterial.emission + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient);
|
||||
|
||||
gl_Position = ftransform();
|
||||
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
||||
|
||||
setupShadows(ecPosition);
|
||||
}
|
Loading…
Reference in a new issue