i need to tile the texture after the parallax mapping shaders r applied.
but the shader ignores the texture scale…
what should i do?
sry to bump this up, but i really need help on this~~~
thx
Multiply the texture coordinates in the vertex shader by gl_TextureMatrix[0].
Momoko_Fan said:
Multiply the texture coordinates in the vertex shader by gl_TextureMatrix[0].
sry but i really dont know how to do that. can u drop in a few lines plz~
thx
Fine, post the shader and I'll fix it.
Momoko_Fan said:
Fine, post the shader and I'll fix it.
haha~u r the best :D
heres the vertex shader
!!ARBvp1.0
PARAM mvi[4] = {state.matrix.modelview.inverse};
PARAM mvit[4] = {state.matrix.modelview.invtrans};
PARAM mvp[4] = {state.matrix.mvp};
ATTRIB tangent = vertex.texcoord[1];
ATTRIB binormal = vertex.texcoord[2];
ATTRIB normal = vertex.normal;
TEMP light0pos, light0vec;
TEMP light1pos, light1vec;
TEMP eyevec, eyevects;
TEMP temp;
# vector pointing to light0
DP4 light0pos.x, mvi[0], state.light[0].position;
DP4 light0pos.y, mvi[1], state.light[0].position;
DP4 light0pos.z, mvi[2], state.light[0].position;
DP4 light0pos.w, mvi[3], state.light[0].position;
SUB light0vec, light0pos, vertex.position;
# transform light0 vector into tangent space (DO NOT NORMALIZE)
DP3 result.texcoord[1].x, light0vec, tangent;
DP3 result.texcoord[1].y, light0vec, binormal;
DP3 result.texcoord[1].z, light0vec, normal;
MOV result.texcoord[1].w, 1.0;
# vector pointing to light1
DP4 light1pos.x, mvi[0], state.light[1].position;
DP4 light1pos.y, mvi[1], state.light[1].position;
DP4 light1pos.z, mvi[2], state.light[1].position;
DP4 light1pos.w, mvi[3], state.light[1].position;
SUB light1vec, light1pos, vertex.position;
# transform light1 vector into tangent space (DO NOT NORMALIZE)
DP3 result.texcoord[2].x, light1vec, tangent;
DP3 result.texcoord[2].y, light1vec, binormal;
DP3 result.texcoord[2].z, light1vec, normal;
MOV result.texcoord[2].w, 1.0;
# vector pointing to eye
SUB eyevec, mvit[3], vertex.position;
# transform eye vector into tangent space (DO NOT NORMALIZE)
DP3 result.texcoord[3].x, eyevec, tangent;
DP3 result.texcoord[3].y, eyevec, binormal;
DP3 result.texcoord[3].z, eyevec, normal;
MOV result.texcoord[3].w, 1.0;
# regular output
DP4 result.position.x, mvp[0], vertex.position;
DP4 result.position.y, mvp[1], vertex.position;
DP4 result.position.z, mvp[2], vertex.position;
DP4 result.position.w, mvp[3], vertex.position;
MOV result.color, vertex.color;
MOV result.texcoord[0], vertex.texcoord[0];
END
Try this:
PARAM mvi[4] = {state.matrix.modelview.inverse};
PARAM mvit[4] = {state.matrix.modelview.invtrans};
PARAM mvp[4] = {state.matrix.mvp};
PARAM mvt[4] = {state.matrix.texture};
ATTRIB tangent = vertex.texcoord[1];
ATTRIB binormal = vertex.texcoord[2];
ATTRIB normal = vertex.normal;
TEMP light0pos, light0vec;
TEMP light1pos, light1vec;
TEMP eyevec, eyevects;
TEMP temp;
# vector pointing to light0
DP4 light0pos.x, mvi[0], state.light[0].position;
DP4 light0pos.y, mvi[1], state.light[0].position;
DP4 light0pos.z, mvi[2], state.light[0].position;
DP4 light0pos.w, mvi[3], state.light[0].position;
SUB light0vec, light0pos, vertex.position;
# transform light0 vector into tangent space (DO NOT NORMALIZE)
DP3 result.texcoord[1].x, light0vec, tangent;
DP3 result.texcoord[1].y, light0vec, binormal;
DP3 result.texcoord[1].z, light0vec, normal;
MOV result.texcoord[1].w, 1.0;
# vector pointing to light1
DP4 light1pos.x, mvi[0], state.light[1].position;
DP4 light1pos.y, mvi[1], state.light[1].position;
DP4 light1pos.z, mvi[2], state.light[1].position;
DP4 light1pos.w, mvi[3], state.light[1].position;
SUB light1vec, light1pos, vertex.position;
# transform light1 vector into tangent space (DO NOT NORMALIZE)
DP3 result.texcoord[2].x, light1vec, tangent;
DP3 result.texcoord[2].y, light1vec, binormal;
DP3 result.texcoord[2].z, light1vec, normal;
MOV result.texcoord[2].w, 1.0;
# vector pointing to eye
SUB eyevec, mvit[3], vertex.position;
# transform eye vector into tangent space (DO NOT NORMALIZE)
DP3 result.texcoord[3].x, eyevec, tangent;
DP3 result.texcoord[3].y, eyevec, binormal;
DP3 result.texcoord[3].z, eyevec, normal;
MOV result.texcoord[3].w, 1.0;
# regular output
DP4 result.position.x, mvp[0], vertex.position;
DP4 result.position.y, mvp[1], vertex.position;
DP4 result.position.z, mvp[2], vertex.position;
DP4 result.position.w, mvp[3], vertex.position;
MOV result.color, vertex.color;
DP4 result.texcoord.x, mvt[0], vertex.texcoord;
DP4 result.texcoord.y, mvt[1], vertex.texcoord;
DP4 result.texcoord.z, mvt[2], vertex.texcoord;
DP4 result.texcoord.w, mvt[3], vertex.texcoord;
END
i got this gl exception
org.lwjgl.opengl.OpenGLException: Invalid operation (1282)
at org.lwjgl.opengl.Util.checkGLError(Util.java:53)
at org.lwjgl.opengl.Display.swapBuffers(Display.java:591)
at org.lwjgl.opengl.Display.update(Display.java:609)
at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(LWJGLRenderer.java:518)
at com.jme.app.BaseGame.start(BaseGame.java:85)
at munch.utility.export.ParallaxExporter.main(ParallaxExporter.java:50)
Works perfectly fine for me.
Did you put a !!ARBvp1.0 at the beginning? You need the header otherwise it won't compile.
Momoko_Fan said:
Works perfectly fine for me.
Did you put a !!ARBvp1.0 at the beginning? You need the header otherwise it won't compile.
haha, forgot about that~ :D
thx alot it works really well.