mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
134 lines
3.3 KiB
Text
134 lines
3.3 KiB
Text
struct v2f {
|
|
vec4 pos;
|
|
vec2 uv;
|
|
};
|
|
struct appdata_tree_billboard {
|
|
vec4 vertex;
|
|
vec4 color;
|
|
vec4 texcoord;
|
|
vec2 texcoord1;
|
|
};
|
|
uniform vec4 _TreeBillboardDistances;
|
|
uniform vec4 _TreeBillboardCameraUp;
|
|
uniform vec3 _TreeBillboardCameraRight;
|
|
uniform vec4 _TreeBillboardCameraPos;
|
|
uniform vec4 _TreeBillboardCameraFront;
|
|
void TerrainBillboardTree (
|
|
inout vec4 pos,
|
|
in vec2 offset,
|
|
in float offsetz
|
|
)
|
|
{
|
|
float absRadius;
|
|
float billboardRootOffsetFactor;
|
|
float billboardModeFactor;
|
|
float radius;
|
|
float billboardAngleFactor;
|
|
float treeDistanceSqr;
|
|
vec3 treePos;
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = (pos.xyz - _TreeBillboardCameraPos.xyz);
|
|
treePos = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = dot (treePos, treePos);
|
|
float tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
treeDistanceSqr = tmpvar_3;
|
|
if ((treeDistanceSqr > _TreeBillboardDistances.x)) {
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = vec2(0.0, 0.0);
|
|
offset = tmpvar_4.xy.xy;
|
|
};
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = (pos.xyz + (_TreeBillboardCameraRight.xyz * offset.x));
|
|
pos.xyz = tmpvar_5.xyz.xyz;
|
|
float tmpvar_6;
|
|
tmpvar_6 = _TreeBillboardCameraPos.w;
|
|
billboardAngleFactor = tmpvar_6;
|
|
float tmpvar_7;
|
|
tmpvar_7 = mix (offset.y, offsetz, billboardAngleFactor);
|
|
float tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
radius = tmpvar_8;
|
|
float tmpvar_9;
|
|
tmpvar_9 = _TreeBillboardCameraUp.w;
|
|
billboardModeFactor = tmpvar_9;
|
|
float tmpvar_10;
|
|
tmpvar_10 = _TreeBillboardCameraFront.w;
|
|
billboardRootOffsetFactor = tmpvar_10;
|
|
float tmpvar_11;
|
|
tmpvar_11 = abs (radius);
|
|
float tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
absRadius = tmpvar_12;
|
|
float tmpvar_13;
|
|
tmpvar_13 = max (0.0, radius);
|
|
vec3 tmpvar_14;
|
|
tmpvar_14 = vec3(billboardModeFactor);
|
|
vec3 tmpvar_15;
|
|
tmpvar_15 = mix (((((_TreeBillboardCameraUp.xyz * tmpvar_13) * 2.0) - (vec3(0.0, 1.0, 0.0) * absRadius)) - ((_TreeBillboardCameraUp.xyz * absRadius) * billboardRootOffsetFactor)), (_TreeBillboardCameraUp.xyz * radius), tmpvar_14);
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = (pos.xyz + tmpvar_15);
|
|
pos.xyz = tmpvar_16.xyz.xyz;
|
|
}
|
|
|
|
v2f vert (
|
|
in appdata_tree_billboard v
|
|
)
|
|
{
|
|
v2f o;
|
|
TerrainBillboardTree (v.vertex, v.texcoord1.xy, v.texcoord.y);
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex);
|
|
o.pos = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = v.texcoord.x;
|
|
o.uv.x = tmpvar_2;
|
|
float tmpvar_3;
|
|
tmpvar_3 = float((v.texcoord.y > 0.0));
|
|
o.uv.y = vec2(tmpvar_3).y;
|
|
return o;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata_tree_billboard xlt_v;
|
|
v2f xl_retval;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = gl_Vertex.xyzw;
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = tmpvar_1;
|
|
xlt_v.vertex = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = gl_Color.xyzw;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
xlt_v.color = tmpvar_4;
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = gl_MultiTexCoord0.xyzw;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
xlt_v.texcoord = tmpvar_6;
|
|
vec2 tmpvar_7;
|
|
tmpvar_7 = gl_MultiTexCoord1.xy;
|
|
vec2 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
xlt_v.texcoord1 = tmpvar_8;
|
|
v2f tmpvar_9;
|
|
tmpvar_9 = vert (xlt_v);
|
|
v2f tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
xl_retval = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = xl_retval.pos.xyzw;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
gl_Position = tmpvar_12;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13.zw = vec2(0.0, 0.0);
|
|
tmpvar_13.xy = xl_retval.uv.xy;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
gl_TexCoord[0] = tmpvar_14;
|
|
}
|
|
|