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 "+ t +", "   + UVFragmentReg +"\n";
code += "div "+ t +".xy, "+ t +".xy, "+ c +".x\n";
code += "frc "+ t +".xy, "+ t +".xy\n";

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

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

code += "add "+ t +".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