加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mesh.vert 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
wujilingfeng 提交于 2024-03-07 14:32 . tset
#version 440 core
layout( location = 0 ) in vec3 vPosition;
layout(location=1) in vec4 aColor;
layout(location=2) in vec2 aTexCoord;
layout(location=3) in vec3 nor;
layout(location=4) in float element_id;
layout(location=5) in float face_index_marked;
out vec4 outColor;
out vec2 texcoord;
out float e_id;
out float f_i_marked1;
out float f_i_marked2;
out vec3 norf;
out vec3 dirf;
uniform mat4 Proj;
//camera_matrix_inverse
uniform mat4 Camera_Matrix;
uniform mat4 Object_Matrix;
//gl_Pointsize
void set_color()
{
//outColor=aColor;
norf=(Camera_Matrix*vec4(normalize(vec3(nor.x,nor.y,nor.z)),0.0)).xyz;
dirf=normalize(vec3(0,0,1));
float st=step(length(nor),0);
//vec3 temp_nor=normalize(norf);
//temp_nor=(Camera_Matrix*vec4(temp_nor,0.0)).xyz;
//vec3 dir=normalize(vec3(0,0,1));
outColor=vec4(st*aColor.xyz+(1-st)*max(dot(norf,dirf),0.25)*aColor.xyz,aColor.w);
//outColor=aColor;
}
void main()
{
gl_PointSize=10.0f;
texcoord=aTexCoord;
set_color();
//outColor=aColor;
//因为opengl的三维坐标系不是右手坐标系,所以vPosition的z分量要加个负号
gl_Position =Proj*Camera_Matrix*Object_Matrix*vec4(vPosition.x,vPosition.y,vPosition.z,1);
gl_Position.z=-gl_Position.z;
e_id=element_id;
f_i_marked1=face_index_marked;
f_i_marked2=face_index_marked*face_index_marked;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化