rgc183

Member
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

208 Neutral

About rgc183

  • Rank
    Member
  1. I am implementing foveated rendering. My FBO is divided into 2 layers which are concentric. First layer covers 1/3 of Framebuffer whereas second one covers rest of the screen. Now I want to avoid to render meshes in outer layer which are already in inner layer. I have implemented following culling algorithm which is only concerned with culling between the layers: I create a rectangles with min and max corner from the radius of 2 layers. Now these coordinates are in NDC. I have min and max corner of each mesh in local coordinate system. so I transform them into NDC using: vec4 min=mvp * vec4(min_corner,1.0); min=min.xyzw/min.w; I create bounding box using min and max corners. Check whether 2 rectangles overlap or not. Now, when I transform into clip space, the x or y coordinates of min are sometimes greater than max corner. Same issue occurs when I divide them by w. Whats going wrong here?
  2. Texture Data: When we call glTexImage() it uploads data on GPU, in which memory (EDRAM or shared memory for Streamline processors) this data is stored? When we call glGenerateMipmap() does it create mipmap levels in GPU memory or CPU creats levels and uploads them on GPU? While sampling all texture data is sampled in Texture filering unit in GPU, right? All these units are shared between all the streamline processors or each processor has one separate? Framebuffer data: Where are attachments of FBO are stored? Are they stored in main memory from EDRAM? While doing all fragment tests, where is this data compared from, is it from main memory? or is that the data is cached into EDRAM?
  3. I am rendering particles using billboard technique but when i move the camera towards left, orientation of quad changes and they disappears when camera continued to move towards left. here is my GS, my vertex shader is pass through shader. float3 pos=gin[0].Position.xyz; float3 cameraV=normalize(EyePosition.xyz - pos ); float3 up= float3(0.0, 1.0, 0.0); float3 right= normalize(cross(up,cameraV))*0.025 ; up=cross(cameraV,right); gout.position=float4(pos - (right + up),1.0); gout.TexCord = float2(0.0, 0.0); triStream.Append(gout); gout.position=float4(pos + (right- up),1.0); gout.TexCord = float2(0.0, 1.0); triStream.Append(gout); gout.position=float4(pos- (right - up),1.0); gout.TexCord = float2(1.0, 0.0); triStream.Append(gout); gout.position=float4(pos + (right+ up),1.0); gout.TexCord = float2(1.0, 1.0); triStream.Append(gout); triStream.RestartStrip();   settings for culling   CullMode = D3D11_CULL_BACK; FrontCounterClockwise = FALSE;
  4. I am working on particle system using DX11 stream output. But there are some issues with it and not working as expected. Here are the steps I am following.   Technique 1: to update stream buffer 1. Create vertex and pixel shader using CreateShader() call. Set pixel shader to null.  2. create geometry shader using:        D3D11_SO_DECLARATION_ENTRY pDecl[] =     {                 { 0, "SV_POSITION", 0, 0, 4, 0 },           { 0, "VELOCITY", 0, 0, 3, 0 },             { 0, "AGE", 0, 0, 1, 0 },         { 0, "TYPE", 0, 0, 1, 0 }     };                  hr=pD3dDevice->CreateGeometryShaderWithStreamOutput(blob->GetBufferPointer(), blob->GetBufferSize(),pDecl, sizeof(pDecl)/sizeof(D3D11_SO_DECLARATION_ENTRY),NULL,0,0,NULL,&GeometryShader);   3. Create two buffers with flags: `D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_STREAM_OUTPUT` .   technique 2: to render particles 1. compile the shaders using createshader call.    Render:   1. set pixel shader to NULL and disable rasterization using `OMSetDepthStencilState`.  2. update one of the buffers by generating particles in geometry shader. 3. Set both buffer targets to NULL. 4. Use the above buffer to render particles. 5. Set both buffer targets to NULL. 6. swap the buffers.   The problem is that something going wrong while reading from stream buffers. Both the techniques when run individually, works fine and gives correct output but problem arises when stream buffer comes into the picture.  Is there anything i am missing?
  5. I am working on particle system using DX11 stream output. But there are some issues with it and not working as expected. Here are the steps I am following.   Technique 1: to update stream buffer 1. Create vertex and pixel shader using CreateShader() call. Set pixel shader to null.  2. create geometry shader using:          D3D11_SO_DECLARATION_ENTRY pDecl[] =     {         // semantic name, semantic index, start component, component count, output slot         { 0, "SV_POSITION", 0, 0, 4, 0 },   // output all components of position         { 0, "VELOCITY", 0, 0, 3, 0 },     // output the first 3 of the normal         { 0, "AGE", 0, 0, 1, 0 },     // output the first 2 texture coordinates     { 0, "TYPE", 0, 0, 1, 0 }     };                  hr=pD3dDevice->CreateGeometryShaderWithStreamOutput(blob->GetBufferPointer(), blob->GetBufferSize(),pDecl, sizeof(pDecl)/sizeof(D3D11_SO_DECLARATION_ENTRY),NULL,0,0,NULL,&GeometryShader); here the pointers are of geometry shader code.   3. Create two buffers with flags: `D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_STREAM_OUTPUT` .   technique 2: to render particles 1. compile the shaders using createshader call.    Render:   1. set pixel shader to NULL and disable rasterization using `OMSetDepthStencilState`.  2. update one of the buffers by generating particles in geometry shader. 3. Set both buffer targets to NULL. 4. Use the above buffer to render particles. 5. Set both buffer targets to NULL. 6. swap the buffers.   Is there anything i am missing?
  6. I have a object at the center. Other set of objects rotating around center in first orbit. Now i want other objects to rotate around the objects in 1st orbit.   n the above fig, set of triangles are rotating around the square and circles are rotating around the triangle. I have the code which works for 1st orbit, but i am not able to render that second orbit. void display() { for (int k = 0; k < 10; k++) { distance_x = 0.4 * cos(angle1*3.14 / 180); distance_y = 0.4 * sin(angle1*3.14 / 180); angle1 += 60; glPushMatrix(); glRotatef(i, 0.0f, 0.0f, 1.0f); glTranslatef(distance_x, distance_y, 0.0f); glRotatef(-i, 0.0f, 0.0f, 1.0f); DrawTriangle(); glPopMatrix(); } }   I am calling display in loop. i is static global variable. which transformations will do the second orbit?
  7. Animation with glut

    I found my mistake in glTranslatef call. when i changed it to  glTranslatef(distance_x, distance_y, 0.0);   it works.  Now, how can i achieve the same result with glRotatef ? I tried but the motion is not orbial.
  8. Animation with glut

      Thanks for your reply. I tried calling the sequence gltranslate, glrotate and gltranslate but it did not  work properly. I want to move objects in orbital manner around the centre object.    In my above code, i found the mistake it should be  glTranslatef(distance_x, distance_y, 0.0); How can I achieve the same effect with glrotatef and not by above manipulation ? I dont want object to rotate around itself.
  9. Animation with glut

    I am trying to do animation using glut. I have 2 squares overlapping to each other and i want other square to rotate around this central object without rotating themselves. I want to rotate in orbit manner. I am calculating circular path using parametric equation and translating that one of the square to that distance. i am calling this function in a loop Here is my code which is not working as per expected. Let me know where it is going wrong. I have added expected image as well     void DrawShapes() { static float angle = 0;   glClear(GL_COLOR_BUFFER_BIT);   glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glColor3f(0.0f, 0.3f, 0.2f);     glBegin(GL_POLYGON); glVertex2f(-0.2, -0.2); glVertex2f(0.2, -0.2); glVertex2f(0.2, 0.2); glVertex2f(-0.2, 0.2); glEnd();   static int i = 0; distance_x = 0.3 * cos(i*3.14 / 180); distance_y = 0.3* sin(i*3.14 / 180); i++; if (i > 360) i = 0;   glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glTranslatef(distance_x, distance_x, 0.0); glBegin(GL_POLYGON); glVertex2f(-0.2, -0.2); glVertex2f(0.2, -0.2); glVertex2f(0.2, 0.2); glVertex2f(-0.2, 0.2); glEnd();   glPopMatrix(); glutSwapBuffers();   }    
  10. Which sampler variable will work for SNORM textures? isampler, usampler or just sampler? Also data type of texture data? I tried with "sampler" and GL_byte but it did not work out.
  11. I am using render to texture concept with glFramebufferTexture1D. I am drawing a cube on non-default FBO with all the vertices as -1,1 (maximum) in X Y Z direction. Now i am setting viewport to X while rendering on non default FBO. My background is blue with white color of cube. For default FBO, i have created 1-D texture and attached this texture to above FBO with color attachment. I am setting width of texture equal to width*height of above FBO view-port. Now, when i render this texture to on another cube, i can see continuous white color on start or end of each face of the cube. That means part of the face is white and rest is blue. I am not sure whether this behavior is correct or not. I expect all the texels should be white as i am using -1 and 1 coordinates for cube rendered on non-default FBO. [code] #define WIDTH 3 #define HEIGHT 3 GLfloat vertices8[]={ 1.0f,1.0f,1.0f, -1.0f,1.0f,1.0f, -1.0f,-1.0f,1.0f, 1.0f,-1.0f,1.0f,//face 1 1.0f,-1.0f,-1.0f, -1.0f,-1.0f,-1.0f, -1.0f,1.0f,-1.0f, 1.0f,1.0f,-1.0f,//face 2 1.0f,1.0f,1.0f, 1.0f,-1.0f,1.0f, 1.0f,-1.0f,-1.0f, 1.0f,1.0f,-1.0f,//face 3 -1.0f,1.0f,1.0f, -1.0f,1.0f,-1.0f, -1.0f,-1.0f,-1.0f, -1.0f,-1.0f,1.0f,//face 4 1.0f,1.0f,1.0f, 1.0f,1.0f,-1.0f, -1.0f,1.0f,-1.0f, -1.0f,1.0f,1.0f,//face 5 -1.0f,-1.0f,1.0f, -1.0f,-1.0f,-1.0f, 1.0f,-1.0f,-1.0f, 1.0f,-1.0f,1.0f//face 6 }; GLfloat vertices[]= { 0.5f,0.5f,0.5f, -0.5f,0.5f,0.5f, -0.5f,-0.5f,0.5f, 0.5f,-0.5f,0.5f,//face 1 0.5f,-0.5f,-0.5f, -0.5f,-0.5f,-0.5f, -0.5f,0.5f,-0.5f, 0.5f,0.5f,-0.5f,//face 2 0.5f,0.5f,0.5f, 0.5f,-0.5f,0.5f, 0.5f,-0.5f,-0.5f, 0.5f,0.5f,-0.5f,//face 3 -0.5f,0.5f,0.5f, -0.5f,0.5f,-0.5f, -0.5f,-0.5f,-0.5f, -0.5f,-0.5f,0.5f,//face 4 0.5f,0.5f,0.5f, 0.5f,0.5f,-0.5f, -0.5f,0.5f,-0.5f, -0.5f,0.5f,0.5f,//face 5 -0.5f,-0.5f,0.5f, -0.5f,-0.5f,-0.5f, 0.5f,-0.5f,-0.5f, 0.5f,-0.5f,0.5f//face 6 }; GLuint indices[] = { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 15, 14, 12, 14, 13, 16, 17, 18, 16, 18, 19, 20, 23, 22, 20, 22, 21 }; GLfloat texcoord[] = { 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0 }; glGenTextures(1, &id1); glBindTexture(GL_TEXTURE_1D, id1); glGenFramebuffers(1, &Fboid); glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, WIDTH*HEIGHT , 0, GL_RGBA, GL_UNSIGNED_BYTE,0); glBindFramebuffer(GL_FRAMEBUFFER, Fboid); glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_1D,id1,0); draw_cube(); glBindFramebuffer(GL_FRAMEBUFFER, 0); draw(); } draw_cube() { glViewport(0, 0, WIDTH, HEIGHT); glClearColor(0.0f, 0.0f, 0.5f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glEnableVertexAttribArray(glGetAttribLocation(temp.psId,"position")); glVertexAttribPointer(glGetAttribLocation(temp.psId,"position"), 3, GL_FLOAT, GL_FALSE, 0,vertices8); glDrawArrays (GL_TRIANGLE_FAN, 0, 24); } draw() { glClearColor(1.0f, 0.0f, 0.0f, 1.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnableVertexAttribArray(glGetAttribLocation(shader_data.psId,"tk_position")); glVertexAttribPointer(glGetAttribLocation(shader_data.psId,"tk_position"), 3, GL_FLOAT, GL_FALSE, 0,vertices); nResult = GL_ERROR_CHECK((GL_NO_ERROR, "glVertexAttribPointer(position, 3, GL_FLOAT, GL_FALSE, 0,vertices);")); glEnableVertexAttribArray(glGetAttribLocation(shader_data.psId,"inputtexcoord")); glVertexAttribPointer(glGetAttribLocation(shader_data.psId,"inputtexcoord"), 2, GL_FLOAT, GL_FALSE, 0,texcoord); glBindTexture(*target11, id1); glDrawElements ( GL_TRIANGLES, 36,GL_UNSIGNED_INT, indices ); } [/code] when i change WIDTH=HEIGHT=2, and call a glreadpixels with height, width equal to 4 in draw_cube() i can see first 2 pixels with white color, next two with blue(glclearcolor), next two white and then blue and so on.. Now when i change width parameter in glTeximage1D to 16 then ideally i should see alternate patches of white and blue right? But its not the case here. Please help me out ...
  12. I am trying to use gltexsubimage3D with the cube. When i use target as GL_texture_2D_array i get some weird o/p, however same code works fine with gl_texture_3d. I am copying my code and screenshots here: texture coordinates: [code] GLfloat tex_coordinates[]={ 0.0, 0.0,0.0, 1.0, 0.0,1.0, 1.0, 1.0,1.0, 0.0, 1.0,0.0, 0.0, 0.0,0.0, 1.0, 0.0,1.0, 1.0, 1.0,1.0, 0.0, 1.0,0.0, 0.0, 0.0,0.0, 1.0, 0.0,1.0, 1.0, 1.0,1.0, 0.0, 1.0,0.0, 0.0, 0.0,0.0, 1.0, 0.0,1.0, 1.0, 1.0,1.0, 0.0, 1.0,0.0, 0.0, 0.0,0.0, 1.0, 0.0,1.0, 1.0, 1.0,1.0, 0.0, 1.0,0.0, 0.0, 0.0,0.0, 1.0, 0.0,1.0, 1.0, 1.0,1.0, 0.0, 1.0,0.0 }; [/code] Now, i am using 8*8*8 texture, so that i am applying 8 layers of 2D images to each face of the cube. My texture data is [code] for (int i=0; i<size/8; i++) { dataRGBA[4*i]=255; dataRGBA[4*i+1]=0; dataRGBA[4*i+2]=0; dataRGBA[4*i+3]=255; sub_data[4*i]=255; sub_data[4*i+1]=255; sub_data[4*i+2]=255; sub_data[4*i+3]=255; } for (int i=size/8; i<size/4; i++) { dataRGBA[4*i]=0; dataRGBA[4*i+1]=255; dataRGBA[4*i+2]=0; dataRGBA[4*i+3]=255; sub_data[4*i]=128; sub_data[4*i+1]=0; sub_data[4*i+2]=58; sub_data[4*i+3]=255; } for ( int i=size/4; i<(3*size)/8; i++) { dataRGBA[4*i]=0; dataRGBA[4*i+1]=0; dataRGBA[4*i+2]=255; dataRGBA[4*i+3]=255; sub_data[4*i]=128; sub_data[4*i+1]=255; sub_data[4*i+2]=58; sub_data[4*i+3]=255; } for ( int i=(3*size)/8; i<(4*size)/8;i++) { dataRGBA[4*i]=255; dataRGBA[4*i+1]=0; dataRGBA[4*i+2]=255; dataRGBA[4*i+3]=255; sub_data[4*i]=0; sub_data[4*i+1]=0; sub_data[4*i+2]=0; sub_data[4*i+3]=255; } for ( int i=(4*size)/8; i<(5*size)/8;i++) { dataRGBA[4*i]=56; dataRGBA[4*i+1]=150; dataRGBA[4*i+2]=255; dataRGBA[4*i+3]=255; sub_data[4*i]=54; sub_data[4*i+1]=100; sub_data[4*i+2]=12; sub_data[4*i+3]=255; } for ( int i=(5*size)/8; i<(6*size)/8; i++) { dataRGBA[4*i]=150; dataRGBA[4*i+1]=255; dataRGBA[4*i+2]=58; dataRGBA[4*i+3]=255; sub_data[4*i]=56; sub_data[4*i+1]=32; sub_data[4*i+2]=155; sub_data[4*i+3]=255; } for ( int i=(6*size)/8; i<(7*size)/8; i++) { dataRGBA[4*i]=150; dataRGBA[4*i+1]=0; dataRGBA[4*i+2]=255; dataRGBA[4*i+3]=255; sub_data[4*i]=222; sub_data[4*i+1]=15; sub_data[4*i+2]=155; sub_data[4*i+3]=255; } for ( int i=(7*size)/8; i<(8*size)/8; i++) { dataRGBA[4*i]=100; dataRGBA[4*i+1]=128; dataRGBA[4*i+2]=58; dataRGBA[4*i+3]=255; sub_data[4*i]=156; sub_data[4*i+1]=202; sub_data[4*i+2]=15; sub_data[4*i+3]=255; } glTexImage3D(*target11, 0, GL_RGBA, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,dataRGBA); glTexSubImage3D(*target11,0,0, 0,0,8, 4, 8, GL_RGBA,GL_UNSIGNED_BYTE,sub_data); glTexParameteri(*target11, GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(*target11, GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(*target11, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(*target11, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(*target11, GL_TEXTURE_WRAP_R, GL_REPEAT); [/code] GL_TEXTURE_3D [attachment=12754:YT8o9.png] GL_TEXTURE_2D_ARRAY [attachment=12755:R0OUO.png] I tried changing filters. By removing subimage3D call, 2darray works fine. code works fine when xoffset=yoffset=0 and width=height=8