Merge branch 'OpenGL3-upgrade' into NDK
Conflicts: src/Nazara/Graphics/SkyboxBackground.cpp src/Nazara/Renderer/RenderTexture.cpp src/Nazara/Renderer/Renderer.cpp Former-commit-id: e8914d4e32a689b7df365dca15a438f10722530c
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
/********************Entrant********************/
|
||||
varying vec2 vTexCoord;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform sampler2D MaterialAlphaMap;
|
||||
uniform float MaterialAlphaThreshold;
|
||||
uniform vec4 MaterialDiffuse;
|
||||
uniform sampler2D MaterialDiffuseMap;
|
||||
uniform vec2 InvTargetSize;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
vec4 fragmentColor = MaterialDiffuse; * vColor;
|
||||
|
||||
#if AUTO_TEXCOORDS
|
||||
vec2 texCoord = gl_FragCoord.xy * InvTargetSize;
|
||||
#else
|
||||
vec2 texCoord = vTexCoord;
|
||||
#endif
|
||||
|
||||
#if DIFFUSE_MAPPING
|
||||
fragmentColor *= texture2D(MaterialDiffuseMap, texCoord);
|
||||
#endif
|
||||
|
||||
#if ALPHA_MAPPING
|
||||
fragmentColor.a *= texture2D(MaterialAlphaMap, texCoord).r;
|
||||
#endif
|
||||
|
||||
#if ALPHA_TEST
|
||||
if (fragmentColor.a < MaterialAlphaThreshold)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
gl_FragColor = fragmentColor;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,97,114,121,105,110,103,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,118,97,114,121,105,110,103,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,50,68,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,125,
|
||||
@@ -1,99 +0,0 @@
|
||||
/********************Entrant********************/
|
||||
#if FLAG_BILLBOARD
|
||||
varying vec3 InstanceData0; // center
|
||||
varying vec4 InstanceData1; // size | sin cos
|
||||
varying vec4 InstanceData2; // color
|
||||
#else
|
||||
varying mat4 InstanceData0;
|
||||
#endif
|
||||
|
||||
varying vec4 VertexColor;
|
||||
varying vec3 VertexPosition;
|
||||
varying vec2 VertexTexCoord;
|
||||
|
||||
/********************Sortant********************/
|
||||
varying vec2 vTexCoord;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform float VertexDepth;
|
||||
uniform mat4 ViewProjMatrix;
|
||||
uniform mat4 WorldViewProjMatrix;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
#if FLAG_VERTEXCOLOR
|
||||
vec4 color = VertexColor;
|
||||
#else
|
||||
vec4 color = vec4(1.0);
|
||||
#endif
|
||||
vec2 texCoords;
|
||||
|
||||
#if FLAG_BILLBOARD
|
||||
#if FLAG_INSTANCING
|
||||
vec3 billboardCenter = InstanceData0;
|
||||
vec2 billboardSize = InstanceData1.xy;
|
||||
vec2 billboardSinCos = InstanceData1.zw;
|
||||
vec4 billboardColor = InstanceData2;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = VertexPosition.x*billboardSinCos.y - VertexPosition.y*billboardSinCos.x;
|
||||
rotatedPosition.y = VertexPosition.y*billboardSinCos.y + VertexPosition.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = billboardCenter + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
color = billboardColor;
|
||||
texCoords = VertexPosition.xy + vec2(0.5, 0.5);
|
||||
#else
|
||||
vec2 billboardCorner = VertexTexCoord - vec2(0.5, 0.5);
|
||||
vec2 billboardSize = VertexUserdata0.xy;
|
||||
vec2 billboardSinCos = VertexUserdata0.zw;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = billboardCorner.x*billboardSinCos.y - billboardCorner.y*billboardSinCos.x;
|
||||
rotatedPosition.y = billboardCorner.y*billboardSinCos.y + billboardCorner.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = VertexPosition + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
#else
|
||||
#if FLAG_INSTANCING
|
||||
#if TRANSFORM
|
||||
gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if TRANSFORM
|
||||
gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
|
||||
vColor = color;
|
||||
#if TEXTURE_MAPPING
|
||||
vTexCoord = vec2(texCoords);
|
||||
#endif
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,237 +0,0 @@
|
||||
#if FLAG_DEFERRED
|
||||
#error Deferred Shading is not supported by compatibility shaders
|
||||
#endif
|
||||
|
||||
#define LIGHT_DIRECTIONAL 0
|
||||
#define LIGHT_POINT 1
|
||||
#define LIGHT_SPOT 2
|
||||
|
||||
/********************Entrant********************/
|
||||
varying mat3 vLightToWorld;
|
||||
varying vec3 vNormal;
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vWorldPos;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
struct Light
|
||||
{
|
||||
int type;
|
||||
vec4 color;
|
||||
vec2 factors;
|
||||
|
||||
vec4 parameters1;
|
||||
vec4 parameters2;
|
||||
vec2 parameters3;
|
||||
};
|
||||
|
||||
// Lumières
|
||||
uniform Light Lights[3];
|
||||
|
||||
// Matériau
|
||||
uniform sampler2D MaterialAlphaMap;
|
||||
uniform float MaterialAlphaThreshold;
|
||||
uniform vec4 MaterialAmbient;
|
||||
uniform vec4 MaterialDiffuse;
|
||||
uniform sampler2D MaterialDiffuseMap;
|
||||
uniform sampler2D MaterialEmissiveMap;
|
||||
uniform sampler2D MaterialNormalMap;
|
||||
uniform float MaterialShininess;
|
||||
uniform vec4 MaterialSpecular;
|
||||
uniform sampler2D MaterialSpecularMap;
|
||||
|
||||
// Autres
|
||||
uniform vec3 EyePosition;
|
||||
uniform vec4 SceneAmbient;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
vec4 diffuseColor = MaterialDiffuse * vColor;
|
||||
|
||||
#if AUTO_TEXCOORDS
|
||||
vec2 texCoord = gl_FragCoord.xy * InvTargetSize;
|
||||
#else
|
||||
vec2 texCoord = vTexCoord;
|
||||
#endif
|
||||
|
||||
#if DIFFUSE_MAPPING
|
||||
diffuseColor *= texture(MaterialDiffuseMap, texCoord);
|
||||
#endif
|
||||
|
||||
#if ALPHA_MAPPING
|
||||
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;
|
||||
#endif
|
||||
|
||||
#if ALPHA_TEST
|
||||
if (diffuseColor.a < MaterialAlphaThreshold)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
vec3 lightAmbient = vec3(0.0);
|
||||
vec3 lightDiffuse = vec3(0.0);
|
||||
vec3 lightSpecular = vec3(0.0);
|
||||
|
||||
#if NORMAL_MAPPING
|
||||
vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0));
|
||||
#else
|
||||
vec3 normal = normalize(vNormal);
|
||||
#endif
|
||||
|
||||
if (MaterialShininess > 0.0)
|
||||
{
|
||||
vec3 eyeVec = normalize(EyePosition - vWorldPos);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (Lights[i].type == LIGHT_DIRECTIONAL)
|
||||
{
|
||||
vec3 lightDir = -Lights[i].parameters1.xyz;
|
||||
|
||||
// Ambient
|
||||
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
|
||||
// Specular
|
||||
vec3 reflection = reflect(-lightDir, normal);
|
||||
float specularFactor = max(dot(reflection, eyeVec), 0.0);
|
||||
specularFactor = pow(specularFactor, MaterialShininess);
|
||||
|
||||
lightSpecular += specularFactor * Lights[i].color.rgb;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_POINT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
|
||||
// Specular
|
||||
vec3 reflection = reflect(-lightDir, normal);
|
||||
float specularFactor = max(dot(reflection, eyeVec), 0.0);
|
||||
specularFactor = pow(specularFactor, MaterialShininess);
|
||||
|
||||
lightSpecular += att * specularFactor * Lights[i].color.rgb;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_SPOT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
// Modification de l'atténuation pour gérer le spot
|
||||
float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);
|
||||
float outerAngle = Lights[i].parameters3.y;
|
||||
float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;
|
||||
att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
|
||||
// Specular
|
||||
vec3 reflection = reflect(-lightDir, normal);
|
||||
float specularFactor = max(dot(reflection, eyeVec), 0.0);
|
||||
specularFactor = pow(specularFactor, MaterialShininess);
|
||||
|
||||
lightSpecular += att * specularFactor * Lights[i].color.rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (Lights[i].type == LIGHT_DIRECTIONAL)
|
||||
{
|
||||
vec3 lightDir = -Lights[i].parameters1.xyz;
|
||||
|
||||
// Ambient
|
||||
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_POINT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
}
|
||||
else if (Lights[i].type == LIGHT_SPOT)
|
||||
{
|
||||
vec3 lightDir = Lights[i].parameters1.xyz - vWorldPos;
|
||||
float lightDirLength = length(lightDir);
|
||||
lightDir /= lightDirLength; // Normalisation
|
||||
|
||||
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
|
||||
|
||||
// Ambient
|
||||
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x * (MaterialAmbient.rgb + SceneAmbient.rgb);
|
||||
|
||||
// Diffuse
|
||||
float lambert = max(dot(normal, lightDir), 0.0);
|
||||
|
||||
// Modification de l'atténuation pour gérer le spot
|
||||
float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);
|
||||
float outerAngle = Lights[i].parameters3.y;
|
||||
float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;
|
||||
att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);
|
||||
|
||||
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lightSpecular *= MaterialSpecular.rgb;
|
||||
#if SPECULAR_MAPPING
|
||||
lightSpecular *= texture(MaterialSpecularMap, texCoord).rgb; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens
|
||||
#endif
|
||||
|
||||
vec3 lightColor = (lightAmbient + lightDiffuse + lightSpecular);
|
||||
vec4 fragmentColor = vec4(lightColor, 1.0) * diffuseColor;
|
||||
|
||||
#if EMISSIVE_MAPPING
|
||||
float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11));
|
||||
|
||||
vec3 emissionColor = MaterialDiffuse.rgb * texture(MaterialEmissiveMap, texCoord).rgb;
|
||||
RenderTarget0 = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a);
|
||||
#else
|
||||
RenderTarget0 = fragmentColor;
|
||||
#endif // EMISSIVE_MAPPING
|
||||
#else
|
||||
RenderTarget0 = diffuseColor;
|
||||
#endif // LIGHTING
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,135 +0,0 @@
|
||||
/********************Entrant********************/
|
||||
#if FLAG_BILLBOARD
|
||||
varying vec3 InstanceData0; // center
|
||||
varying vec4 InstanceData1; // size | sin cos
|
||||
varying vec4 InstanceData2; // color
|
||||
#else
|
||||
varying mat4 InstanceData0;
|
||||
#endif
|
||||
|
||||
varying vec3 VertexPosition;
|
||||
varying vec3 VertexNormal;
|
||||
varying vec3 VertexTangent;
|
||||
varying vec2 VertexTexCoord;
|
||||
|
||||
/********************Sortant********************/
|
||||
varying mat3 vLightToWorld;
|
||||
varying vec3 vNormal;
|
||||
varying vec2 vTexCoord;
|
||||
varying vec3 vWorldPos;
|
||||
varying vec4 vColor;
|
||||
|
||||
/********************Uniformes********************/
|
||||
uniform float VertexDepth;
|
||||
uniform mat4 ViewProjMatrix;
|
||||
uniform mat4 WorldMatrix;
|
||||
uniform mat4 WorldViewProjMatrix;
|
||||
|
||||
/********************Fonctions********************/
|
||||
void main()
|
||||
{
|
||||
#if FLAG_VERTEXCOLOR
|
||||
vec4 color = VertexColor;
|
||||
#else
|
||||
vec4 color = vec4(1.0);
|
||||
#endif
|
||||
vec2 texCoords;
|
||||
|
||||
#if FLAG_BILLBOARD
|
||||
#if FLAG_INSTANCING
|
||||
vec3 billboardCenter = InstanceData0;
|
||||
vec2 billboardSize = InstanceData1.xy;
|
||||
vec2 billboardSinCos = InstanceData1.zw;
|
||||
vec4 billboardColor = InstanceData2;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = VertexPosition.x*billboardSinCos.y - VertexPosition.y*billboardSinCos.x;
|
||||
rotatedPosition.y = VertexPosition.y*billboardSinCos.y + VertexPosition.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = billboardCenter + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
color = billboardColor;
|
||||
texCoords = VertexPosition.xy + vec2(0.5, 0.5);
|
||||
#else
|
||||
vec2 billboardCorner = VertexTexCoord - vec2(0.5, 0.5);
|
||||
vec2 billboardSize = VertexUserdata0.xy;
|
||||
vec2 billboardSinCos = VertexUserdata0.zw;
|
||||
|
||||
vec2 rotatedPosition;
|
||||
rotatedPosition.x = billboardCorner.x*billboardSinCos.y - billboardCorner.y*billboardSinCos.x;
|
||||
rotatedPosition.y = billboardCorner.y*billboardSinCos.y + billboardCorner.x*billboardSinCos.x;
|
||||
rotatedPosition *= billboardSize;
|
||||
|
||||
vec3 cameraRight = vec3(ViewMatrix[0][0], ViewMatrix[1][0], ViewMatrix[2][0]);
|
||||
vec3 cameraUp = vec3(ViewMatrix[0][1], ViewMatrix[1][1], ViewMatrix[2][1]);
|
||||
vec3 vertexPos = VertexPosition + cameraRight*rotatedPosition.x + cameraUp*rotatedPosition.y;
|
||||
|
||||
gl_Position = ViewProjMatrix * vec4(vertexPos, 1.0);
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
#else
|
||||
#if FLAG_INSTANCING
|
||||
#if TRANSFORM
|
||||
gl_Position = ViewProjMatrix * InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = InstanceData0 * vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if TRANSFORM
|
||||
gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);
|
||||
#else
|
||||
#if UNIFORM_VERTEX_DEPTH
|
||||
gl_Position = vec4(VertexPosition.xy, VertexDepth, 1.0);
|
||||
#else
|
||||
gl_Position = vec4(VertexPosition, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
texCoords = VertexTexCoord;
|
||||
#endif
|
||||
|
||||
vColor = color;
|
||||
|
||||
#if LIGHTING
|
||||
#if FLAG_INSTANCING
|
||||
mat3 rotationMatrix = mat3(InstanceData0[0].xyz, InstanceData0[1].xyz, InstanceData0[2].xyz);
|
||||
#else
|
||||
mat3 rotationMatrix = mat3(WorldMatrix[0].xyz, WorldMatrix[1].xyz, WorldMatrix[2].xyz);
|
||||
#endif
|
||||
|
||||
#if NORMAL_MAPPING
|
||||
vec3 binormal = cross(VertexNormal, VertexTangent);
|
||||
vLightToWorld[0] = normalize(rotationMatrix * VertexTangent);
|
||||
vLightToWorld[1] = normalize(rotationMatrix * binormal);
|
||||
vLightToWorld[2] = normalize(rotationMatrix * VertexNormal);
|
||||
#else
|
||||
vNormal = normalize(rotationMatrix * VertexNormal);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if TEXTURE_MAPPING
|
||||
vTexCoord = vec2(texCoords);
|
||||
#endif
|
||||
|
||||
#if LIGHTING && PARALLAX_MAPPING
|
||||
vViewDir = EyePosition - VertexPosition;
|
||||
vViewDir *= vLightToWorld;
|
||||
#endif
|
||||
|
||||
#if LIGHTING && !FLAG_DEFERRED
|
||||
#if FLAG_INSTANCING
|
||||
vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0));
|
||||
#else
|
||||
vWorldPos = vec3(WorldMatrix * vec4(VertexPosition, 1.0));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user