Files
MoGoEagleEye/libraries/mapmodule/src/main/assets/shaders/vSelfCar_Shader.glsl
2023-08-07 11:21:55 +08:00

39 lines
1.2 KiB
GLSL

#version 300 es
precision mediump float;
uniform mat4 modelMat;
uniform mat4 viewMat;
uniform mat4 projMat;
uniform vec3 lightWorldPos; //光源的世界坐标
uniform int changeColorCmd;
uniform float changeColorRatio;
layout(location = 0) in vec4 pos;
layout(location = 2) in vec3 normal;
layout(location = 3) in vec2 texCoord;
out vec2 fragTexCoord;
out vec3 fragEyeNormal;
out vec3 fragEyePos; //光源的人眼坐标
out vec3 lightEyePos;
out vec3 posInEye;
out float _changeColorCmd;
out float _changeColorRatio;
out float _changeColorOff;
void main()
{
_changeColorCmd = float(changeColorCmd);
_changeColorRatio = changeColorRatio;
if(_changeColorCmd==0.0)
_changeColorOff = 0.0;
else if(abs(_changeColorCmd)<3.0)
_changeColorOff = pos.x/500.0 + 0.5;
else
_changeColorOff = pos.y/1000.0 + 0.5;
gl_Position = projMat * viewMat * modelMat * pos;
fragTexCoord = texCoord;
mat3 normalMat = mat3(transpose(inverse(viewMat * modelMat)));
fragEyeNormal = normalize(normalMat * normal); //法线矩阵变换
fragEyePos = (viewMat * modelMat * pos).xyz;
lightEyePos = (viewMat*vec4(lightWorldPos,1.0)).xyz;
posInEye = (modelMat * pos).xyz;
}