Re: [osg-users] How to texturing a cube using shaders

2014-08-07 Thread ying song
he texture coordinates for this model, or apply your own. > > > Might I suggest using other models that do have appropriate texture > coordinate on them for testing. > > > Robert. > > > > On 6 August 2014 15:52, ying song < ()> wrote: > > > He

Re: [osg-users] How to texturing a cube using shaders

2014-08-06 Thread ying song
> > > Robert. > > > > On 5 August 2014 16:31, ying song < ()> wrote: > > > Hello everyone, > > > > I tried texturing a cube by using shaders, but failed. I already tried all > > the way I could think about, but the rendered cube is still to

Re: [osg-users] How to texturing a cube using shaders

2014-08-06 Thread ying song
> > > Robert. > > > > On 5 August 2014 16:31, ying song < ()> wrote: > > > Hello everyone, > > > > I tried texturing a cube by using shaders, but failed. I already tried all > > the way I could think about, but the rendered cube is still to

[osg-users] How to texturing a cube using shaders

2014-08-05 Thread ying song
Hello everyone, I tried texturing a cube by using shaders, but failed. I already tried all the way I could think about, but the rendered cube is still totally black if I use shaders. Could someone help me on this? Here is mycode: cpp file: osg::ref_ptr image = osgDB::readImageFile("Ima

[osg-users] How to texturing a cube using shaders

2014-08-05 Thread ying song
Hello everyone, I tried texturing a cube by using shaders, but failed. I already tried all the way I could think about, but the rendered cube is still totally black if I use shaders. Could someone help me on this? Here is mycode: cpp file: osg::ref_ptr image = osgDB::readImageFile("Ima

[osg-users] Set color in fragment shader

2014-07-29 Thread ying song
Hello everyone, I downloaded a 3d model which is in 3ds file format. At first I distorted this model in the vertex shader. Then I want to set the color of the model as same as the original color, but I don't know how to do it. I tried: 'gl_FragColor = gl_Color;' in the fragment shader, but then

Re: [osg-users] Clip Coordinates

2014-07-25 Thread ying song
Hi Glenn Waldron, Thanks! I solved my probelm and I understand why it'not always commutative. I think the right order of the multiplication is gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex. I tried in shaders both orders of the multiplication, it turns out that gl_Position = gl_Projecti

Re: [osg-users] Clip Coordinates

2014-07-24 Thread ying song
Hello Glenn Waldron I tried pos1 = P1 * modelviewMat * projectionMat, which gives me different results, but still, some of the value are out of the range (-1,1). I thought that P1 * modelviewMat * projectionMat and projectionMat * modelviewMat * P1 would give me the same results, but they are

[osg-users] Clip Coordinates

2014-07-24 Thread ying song
Hello everyone, To understand what is the clipping coordinates, I tested some points using the following code: osg::Matrixd modelviewMat= viewer->getCamera()->getViewMatrix(); osg::Matrixd projectionMat= viewer->getCamera()->getProjectionMatrix(); osg::Vec4 pos1 = projectionMat * modelviewMat *

Re: [osg-users] Access vertexes of a 3D model in the vertex shader

2014-07-09 Thread ying song
Hello, Could you tell me what do you mean "define a mapping from vertex numbers to st coordinate"? Could I do like this in the fragment shader? gl_TexCoord[0].st = vec2(position.x, position.y); gl_FragColor = texture2D(myTexture, gl_TexCoord[0].st); where position is the distorted pixel coordi

Re: [osg-users] Access vertexes of a 3D model in the vertex shader

2014-07-09 Thread ying song
Hi Sebastian, At first I transformed from the camera coordinate system [Xc,Yc,Zc] to the pinhole image projecting system [X=Xc/Zc, Y=Yc/Zc]. Then the distorting is processed based [X,Y]. At last, the projection matrix is mutiplied and the pixel coordinate is getten in this way. Since the input

Re: [osg-users] Access vertexes of a 3D model in the vertex shader

2014-06-30 Thread ying song
Hi Sebastian , The distortion value is a function of the position, and it's for per vextex. It won't change over time. To be more details, the distortion function would calculate pixel coordinates(2d) based on vertex positions(3d). Now I'm really confused about this problem. I found some tuto

Re: [osg-users] Access vertexes of a 3D model in the vertex shader

2014-06-27 Thread ying song
Hi Sebastian , I'm sorry for the confusion. The distortion value is a function of position, and it's for per vextex. It won't changed over time. To be more details, the distortion function will calculate the pixel coordinates based on the passing vertex positions. Thanks! Ying -

Re: [osg-users] Access vertexes of a 3D model in the vertex shader

2014-06-26 Thread ying song
Hi Sebastian , The distortion will be applied to the 3D model's vertexes. So each vertex will be changed to a different position. I wonder how could I achieve this? Should I use 3D texture, and then applying the distortion to the coordinates of the 3D texture? Thank you for the answer! :) Che

[osg-users] Access vertexes of a 3D model in the vertex shader

2014-06-26 Thread ying song
Hello, Would someone tell me how to access all the vertexes of a 3d model in the vertex shader? I want to render a distorted model by chaning the positions of the 3d model's vertexes. I tried to use 'gl_Vertex' to access the vertexes, but seems that it didn't work. Hope someone could help me

Re: [osg-users] Errors when using shaders

2014-06-24 Thread ying song
Hi Robert, Yes, you are right! It's the problem of my driver. I installed a new driver, and the problem is gone now. Thank you!! Cheers, ying -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59864#59864 ___

[osg-users] Errors when using shaders

2014-06-23 Thread ying song
Hello everyone, When running my program for vertex shading, I encountered some problems. Hope someone could help me out of this. The list of errors: Error: glCreateShader not supported by OpenGL driver Error: glShaderSource not supported by OpenGL driver Error: glCompileShader not supported by O

Re: [osg-users] confuse about the rendering of osgdistortion example

2014-06-11 Thread ying song
Hi Robert, Yes, I want to convert a vertex position to a new vertex position. To do so, should I use a vertex shader? Thanks, Ying robertosfield wrote: > Hi Ying, > > On 10 June 2014 16:52, ying song <> wrote: > > > Hi Robert, > > > > I'm trying to

Re: [osg-users] confuse about the rendering of osgdistortion example

2014-06-10 Thread ying song
e depth of the scene > rather than a 3D texture. > > Robert. > > On 10 June 2014 16:12, ying song <> wrote: > > > Hi Robret, > > > > Thanks for the answering. Now I could understand the process of rendering > > more or less. > > > > I´

Re: [osg-users] confuse about the rendering of osgdistortion example

2014-06-10 Thread ying song
them these texture coordinates tell the GPU what part > the texture to use when rendering, if the texture coords were set up > in a regular pattern like the vertices then you wouldn't see any > distortion, however, for this example they are shifted so that desired > distortion is appl

[osg-users] confuse about the rendering of osgdistortion example

2014-06-09 Thread ying song
Hi everyone, I'm now going through the osgdistortion example. Based on my understanding, this example is to rendering the scene on the texture istead of the screen. Through distorting the texture, the distorted model could be build and shown. However, I'm a little confused about the rendering p

[osg-users] [forum] Change the position and rotation angle of the camera

2014-04-09 Thread ying song
Hi, I draw a box using addDrawable. Then I want to change the position and rotation angle of the camera by: viewer->getCamera()->setViewMatrix(cameraTranslationMatrix); But actually it makes no change to the camera. The cube is still in the center of the screen after run the scene. I also tr