初次提交
This commit is contained in:
8
第11章 常用3D开发技巧案例/Sample11_6/assets/frag.sh
Normal file
8
第11章 常用3D开发技巧案例/Sample11_6/assets/frag.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
precision mediump float;
|
||||
varying vec2 vTextureCoord; //接收从顶点着色器过来的参数
|
||||
uniform sampler2D sTexture;//纹理内容数据
|
||||
void main()
|
||||
{
|
||||
//给此片元从纹理中采样出颜色值
|
||||
gl_FragColor = texture2D(sTexture, vTextureCoord);
|
||||
}
|
||||
37
第11章 常用3D开发技巧案例/Sample11_6/assets/frag_mountion.sh
Normal file
37
第11章 常用3D开发技巧案例/Sample11_6/assets/frag_mountion.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
precision mediump float;
|
||||
varying vec2 vTextureCoord; //接收从顶点着色器过来的参数
|
||||
uniform sampler2D sTexture;//纹理内容数据
|
||||
varying float currY;
|
||||
uniform sampler2D sTextureGrass;//纹理内容数据(草皮)
|
||||
uniform sampler2D sTextureRock;//纹理内容数据(岩石)
|
||||
uniform float landStartY;//陆地起始Y
|
||||
uniform float landYSpan;//陆地Y偏移量
|
||||
|
||||
void main()
|
||||
{
|
||||
float min=0.25;
|
||||
float max=0.7;
|
||||
|
||||
float currYRatio=(currY-landStartY)/landYSpan;
|
||||
|
||||
vec4 gColor=texture2D(sTextureGrass, vTextureCoord);
|
||||
vec4 rColor=texture2D(sTextureRock, vTextureCoord);
|
||||
|
||||
vec4 finalColor;
|
||||
|
||||
if(currYRatio<min)
|
||||
{
|
||||
finalColor=gColor;
|
||||
}
|
||||
else if(currYRatio>max)
|
||||
{
|
||||
finalColor=rColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
float rockBL=(currYRatio-min)/(max-min);
|
||||
finalColor=rockBL*rColor+(1.0-rockBL)*gColor;
|
||||
}
|
||||
//给此片元从纹理中采样出颜色值
|
||||
gl_FragColor = finalColor;
|
||||
}
|
||||
9
第11章 常用3D开发技巧案例/Sample11_6/assets/vertex.sh
Normal file
9
第11章 常用3D开发技巧案例/Sample11_6/assets/vertex.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
uniform mat4 uMVPMatrix; //总变换矩阵
|
||||
attribute vec3 aPosition; //顶点位置
|
||||
attribute vec2 aTexCoor; //顶点纹理坐标
|
||||
varying vec2 vTextureCoord; //用于传递给片元着色器的变量
|
||||
void main()
|
||||
{
|
||||
gl_Position = uMVPMatrix * vec4(aPosition,1); //根据总变换矩阵计算此次绘制此顶点位置
|
||||
vTextureCoord = aTexCoor;//将接收的纹理坐标传递给片元着色器
|
||||
}
|
||||
11
第11章 常用3D开发技巧案例/Sample11_6/assets/vertex_mountion.sh
Normal file
11
第11章 常用3D开发技巧案例/Sample11_6/assets/vertex_mountion.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
uniform mat4 uMVPMatrix; //总变换矩阵
|
||||
attribute vec3 aPosition; //顶点位置
|
||||
attribute vec2 aTexCoor; //顶点纹理坐标
|
||||
varying vec2 vTextureCoord; //用于传递给片元着色器的变量
|
||||
varying float currY;
|
||||
void main()
|
||||
{
|
||||
gl_Position = uMVPMatrix * vec4(aPosition,1); //根据总变换矩阵计算此次绘制此顶点位置
|
||||
vTextureCoord = aTexCoor;//将接收的纹理坐标传递给片元着色器
|
||||
currY=aPosition.y;
|
||||
}
|
||||
Reference in New Issue
Block a user