Hi all,
I am using 1.8 I need a displacement mapping for a square lattice, with 128x128 512x512 ... vertices for example I have a new map for every frame I looked at shaders today for the first time, I love them!! :D ..but I realy don't get how to pass the textures to the shader :( first the shader : string dcShader::disp_vp_program = "uniform sampler2D displacementMap;" "\n" "void main(void) {" " vec4 newPos;\n" " vec4 dv;\n" " float df;\n" " vec2 texture_coordinate;\n" " gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" " dv = texture2D(displacementMap, gl_TexCoord[0].xy);\n"//---here is the problem! //" dv = vec4(10.0 , 10.0, 10.0 ,0.0);\n"//---this works! " df = dv.x + dv.y + dv.z;\n" " newPos = vec4(gl_Normal * df, 0.0) + gl_Vertex;\n" " gl_Position = gl_ModelViewProjectionMatrix * newPos;" "}"; string dcShader::disp_fp_program = "vec4 fvAmbient = vec4(0.5, 0.5, 1.0, 1.0);\n" "\n" "void main(void)" "{" " gl_FragColor = fvAmbient;" "}"; SHLChunkPtr shl = SHLChunk::create(); beginEditCP(shl); shl->setVertexProgram(disp_vp_program); shl->setFragmentProgram(disp_fp_program); endEditCP(shl); //my material UChar8* data = new UChar8[rN*cN*4]; for(int i=0;i<rN*cN*4;i++) data[i] = 1; ImagePtr img = Image::create(); beginEditCP(img); img->set( Image::OSG_RGBA_PF, cN, rN, 1, 1, 1, 0, data, Image::OSG_FLOAT32_IMAGEDATA); endEditCP(img); SimpleTexturedMaterialPtr Mat = SimpleTexturedMaterial::create(); beginEditCP(Mat); Mat->setDiffuse(Color3f(0.8,0.8,0.6)); Mat->setAmbient(Color3f(0.4, 0.4, 0.2)); beginEditCP(Mat); Mat->addChunk(shl); endEditCP(Mat); Mat->setImage(img); Mat->setMinFilter(GL_NEAREST); Mat->setMagFilter(GL_NEAREST); Mat->setEnvMode(GL_NONE); endEditCP(Mat); the problem : no displacement when I use the texture data and the application becomes realy slow, but it works perfectly with any other values like the vertex position etc.. my problem is also that I have no clue how to debug a shader.. is there any way for console output? and even if I could know the values from the texture in the shader.. if they are wrong I don't know what to do.. I have no clue how the texture is supposed to get to the shader :/ thanks for reading! Best Regards, Victor
------------------------------------------------------------------------------ Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2
_______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users