1
0
forked from 0ad/0ad

Calculates LOS texture coordinates in shaders for overlay lines only if needed.

This was SVN commit r24140.
This commit is contained in:
Vladislav Belov 2020-11-07 21:34:35 +00:00
parent 627ed773df
commit 212f1bdec4
4 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,7 @@
!!ARBvp1.0 !!ARBvp1.0
#if !IGNORE_LOS
PARAM losTransform = program.local[0]; PARAM losTransform = program.local[0];
#endif
ATTRIB position = vertex.position; ATTRIB position = vertex.position;
DP4 result.position.x, state.matrix.mvp.row[0], position; DP4 result.position.x, state.matrix.mvp.row[0], position;
@ -8,7 +10,9 @@ DP4 result.position.z, state.matrix.mvp.row[2], position;
DP4 result.position.w, state.matrix.mvp.row[3], position; DP4 result.position.w, state.matrix.mvp.row[3], position;
MOV result.texcoord[0], vertex.texcoord[0]; MOV result.texcoord[0], vertex.texcoord[0];
#if !IGNORE_LOS
MAD result.texcoord[1], position.xzzz, losTransform.x, losTransform.y; MAD result.texcoord[1], position.xzzz, losTransform.x, losTransform.y;
#endif
MOV result.color, vertex.color; MOV result.color, vertex.color;

View File

@ -11,13 +11,13 @@
<stream name="pos"/> <stream name="pos"/>
<stream name="uv0"/> <stream name="uv0"/>
<stream name="color" if="!USE_OBJECTCOLOR"/> <stream name="color" if="!USE_OBJECTCOLOR"/>
<uniform name="losTransform" loc="0" type="vec2"/> <uniform name="losTransform" loc="0" type="vec2" if="!IGNORE_LOS"/>
</vertex> </vertex>
<fragment file="arb/overlayline.fp"> <fragment file="arb/overlayline.fp">
<uniform name="baseTex" loc="0" type="sampler2D"/> <uniform name="baseTex" loc="0" type="sampler2D"/>
<uniform name="maskTex" loc="1" type="sampler2D"/> <uniform name="maskTex" loc="1" type="sampler2D"/>
<uniform name="losTex" loc="2" type="sampler2D"/> <uniform name="losTex" loc="2" type="sampler2D" if="!IGNORE_LOS"/>
<uniform name="objectColor" loc="0" type="vec3" if="USE_OBJECTCOLOR"/> <uniform name="objectColor" loc="0" type="vec3" if="USE_OBJECTCOLOR"/>
</fragment> </fragment>

View File

@ -11,7 +11,10 @@ varying vec4 v_color;
#endif #endif
varying vec2 v_tex; varying vec2 v_tex;
#if !IGNORE_LOS
varying vec2 v_los; varying vec2 v_los;
#endif
void main() void main()
{ {

View File

@ -1,6 +1,8 @@
#version 120 #version 120
#if !IGNORE_LOS
uniform vec2 losTransform; uniform vec2 losTransform;
#endif
attribute vec3 a_vertex; attribute vec3 a_vertex;
attribute vec2 a_uv0; attribute vec2 a_uv0;
@ -11,12 +13,17 @@ varying vec4 v_color;
#endif #endif
varying vec2 v_tex; varying vec2 v_tex;
#if !IGNORE_LOS
varying vec2 v_los; varying vec2 v_los;
#endif
void main() void main()
{ {
v_tex = a_uv0; v_tex = a_uv0;
#if !IGNORE_LOS
v_los = a_vertex.xz * losTransform.x + losTransform.yy; v_los = a_vertex.xz * losTransform.x + losTransform.yy;
#endif
#if !USE_OBJECTCOLOR #if !USE_OBJECTCOLOR
v_color = a_color; v_color = a_color;
#endif #endif