Jump to content

cube face texture rotation


eboo
 Share

Recommended Posts

  • 3 months later...

This should be the default for cubes.  With seamless textures you would get 4 faces that look nicely connected. With the default configuration you get 0 faces that look connected.  What @eboo is asking is also the default cube configuration in frameworks like Second Life.

Link to comment
Share on other sites

I've been playing with this and I'm trying to find a way to tint the colour.  

I've learnt that I can change colour doing this:

BABYLON.Effect.ShadersStore["boxTexturePixelShader"] =
	"precision highp float;\n\
varying vec3 nrm;\n\
varying vec2 vUV;\n\
\n\
uniform sampler2D tex1;\n\
uniform sampler2D tex2;\n\
vec4 tint = vec4(1,0,0,1);\n\
 \n\
void main(void) {\n\
vec4 col = texture2D(tex1, vec2( 1.-vUV.y,1.-vUV.x)  );\n\
vec4 col2 = texture2D(tex1, vec2(vUV.x,1.-vUV.y)  );\n\
vec4 col3 = texture2D(tex1, vec2(1.-vUV.x,  vUV.y ) );\n\
if(nrm.x != 0.   && col.w > 0.7 )\n\
    gl_FragColor = vec4(col.rgb,1.)+tint;\n\
else if(nrm.z >  0.   && col2.w > 0.7 )\n\
    gl_FragColor = vec4(col2.rgb,1.)+tint;\n\
else if(nrm.z <  0.   && col3.w > 0.7 )\n\
    gl_FragColor = vec4(col3.rgb,1.)+tint;\n\
	else   gl_FragColor = vec4(texture2D(tex2,   vUV  ).rgb,1.)+tint;\n\
}";

but I don't know how to access that tint colour using setColor4.  When I try mesh.material.setColor4("tint",new BABYLON.Color4.FromInts(255, 0, 0, 1)) nothing happens.  Mind you, I'm very noob at shaders.

 

My attempt here:

http://www.babylonjs-playground.com/#TRNYD#15

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...