Wrap Texture, Mirror texture address mode

Software: Away3D 4.x

mgiachetti, Newbie
Posted: 29 August 2012 06:28 PM   Total Posts: 1

Hi,

It would be great if you add support for Mirror texture address mode.

Mirror Texture Address Mode

I know it not supported yet by stage3d, but it can be solved in the fragment shader.

At the moment, I solved it by adding this lines before calling the tex instruccion in agal.

code += "mov "+", "   UVFragmentReg +"\n";
code += "div "+".xy, "+".xy, "+".x\n";
code += "frc "+".xy, "+".xy\n";

    
code += "sge "temp +".x, "+".x, "+".y\n";
code += "sge "temp +".y, "+".y, "+".y\n";
code += "slt "temp +".z, "+".x, "+".y\n";
code += "slt "temp +".w, "+".y, "+".y\n";

code += "frc "+".xy, "UVFragmentReg +".xy\n";
code += "sub "+".z, "+".z, "+".x\n";
code += "sub "+".w, "+".z, "+".y\n";
    
code += "mul "temp +".x, "+".z, "temp +".x\n";
code += "mul "temp +".y, "+".w, "temp +".y\n";
code += "mul "temp +".z, "+".x, "temp +".z\n";
code += "mul "temp +".w, "+".y, "temp +".w\n";

code += "add "+".xy, "temp +".xy, "temp +".zw\n"

Var explanation:
temp -> temp variable
t ->is the texcoord used in the tex instruccion.
UVFragmentReg -> Varing variable from the vertex shader
c -> const variables.
  c.x = 2
  c.y = 0.5
  c.z = 1

The texture sampler must be in clamp mode to work properly

Hope it helps.
Sorry my bad english

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X