79 lines
2.5 KiB
Plaintext
79 lines
2.5 KiB
Plaintext
struct v2f_vertex_lit {
|
|
vec2 uv;
|
|
vec4 diff;
|
|
vec4 spec;
|
|
};
|
|
struct v2f_img {
|
|
vec4 pos;
|
|
vec2 uv;
|
|
};
|
|
struct appdata_img {
|
|
vec4 vertex;
|
|
vec2 texcoord;
|
|
};
|
|
struct v2f {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 color;
|
|
vec2 uv;
|
|
};
|
|
struct appdata_tree_billboard {
|
|
vec4 vertex;
|
|
vec4 color;
|
|
vec4 texcoord;
|
|
vec2 texcoord1;
|
|
};
|
|
uniform vec4 _TreeBillboardCameraFront;
|
|
uniform vec4 _TreeBillboardCameraPos;
|
|
uniform vec3 _TreeBillboardCameraRight;
|
|
uniform vec4 _TreeBillboardCameraUp;
|
|
uniform vec4 _TreeBillboardDistances;
|
|
|
|
void TerrainBillboardTree( inout vec4 pos, in vec2 offset, in float offsetz );
|
|
v2f vert( in appdata_tree_billboard v );
|
|
void TerrainBillboardTree( inout vec4 pos, in vec2 offset, in float offsetz ) {
|
|
vec3 treePos;
|
|
float treeDistanceSqr;
|
|
float billboardAngleFactor;
|
|
float radius;
|
|
float billboardModeFactor;
|
|
float billboardRootOffsetFactor;
|
|
float absRadius;
|
|
treePos = (pos.xyz - _TreeBillboardCameraPos.xyz );
|
|
treeDistanceSqr = dot( treePos, treePos);
|
|
if ( (treeDistanceSqr > _TreeBillboardDistances.x ) ){
|
|
offset.xy = vec2( 0.000000);
|
|
}
|
|
pos.xyz += (_TreeBillboardCameraRight.xyz * offset.x );
|
|
billboardAngleFactor = _TreeBillboardCameraPos.w ;
|
|
radius = mix( offset.y , offsetz, billboardAngleFactor);
|
|
billboardModeFactor = _TreeBillboardCameraUp.w ;
|
|
billboardRootOffsetFactor = _TreeBillboardCameraFront.w ;
|
|
absRadius = abs( radius );
|
|
pos.xyz += mix( ((((_TreeBillboardCameraUp.xyz * max( 0.000000, radius)) * 2.00000) - (vec3( 0.000000, 1.00000, 0.000000) * absRadius)) - ((_TreeBillboardCameraUp.xyz * absRadius) * billboardRootOffsetFactor)), (_TreeBillboardCameraUp.xyz * radius), vec3( billboardModeFactor));
|
|
}
|
|
v2f vert( in appdata_tree_billboard v ) {
|
|
v2f o;
|
|
TerrainBillboardTree( v.vertex, v.texcoord1.xy , v.texcoord.y );
|
|
o.pos = ( gl_ModelViewProjectionMatrix * v.vertex );
|
|
o.fog = o.pos.z ;
|
|
o.uv.x = v.texcoord.x ;
|
|
o.uv.y = float( (v.texcoord.y > 0.000000) );
|
|
o.color = v.color;
|
|
return o;
|
|
}
|
|
varying vec4 xlv_FOG;
|
|
void main() {
|
|
v2f xl_retval;
|
|
appdata_tree_billboard xlt_v;
|
|
xlt_v.vertex = vec4( gl_Vertex);
|
|
xlt_v.color = vec4( gl_Color);
|
|
xlt_v.texcoord = vec4( gl_MultiTexCoord0);
|
|
xlt_v.texcoord1 = vec2( gl_MultiTexCoord1);
|
|
xl_retval = vert( xlt_v);
|
|
gl_Position = vec4( xl_retval.pos);
|
|
xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0);
|
|
gl_FrontColor = vec4( xl_retval.color);
|
|
gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0);
|
|
}
|