thedigga007

Member
  • Content count

    63
  • Joined

  • Last visited

Community Reputation

135 Neutral

About thedigga007

  • Rank
    Member
  1. iOS geometry shader support

    Hmm nevermind looks like OpenGL ES 2.0 doesn't support geometry shaders. Shame, according to powervr the SGXMP supports it.
  2. Does it exist? I've did a few searches on google but didnt find anything useful. Is there an extension available such as EXT_geometry_shader4? Thanks!
  3. 3D LUT Color Correction issue

    I got it! After looking at the PIX capture again I noticed that the LUT was flipped in the Y. I fixed this in my conversion tool (the to 2d to 3d) and it worked. Thanks for all the help!
  4. 3D LUT Color Correction issue

    Here is an image of the original framebuffer. [img]http://i50.tinypic.com/dca436.png[/img] Framebuffer surface format is ARGB and the LUT is ARGB
  5. So I decided to try to implement color correction using 3D lookup tables based on the article found here: [url="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html"]http://http.develope..._chapter24.html[/url] I then used the "color neutral" texture found on the UDN here: [url="http://udn.epicgames.com/Three/ColorGrading.html"]http://udn.epicgames...lorGrading.html[/url] I made sure to convert the color neautral texture from 2D to 3D, so 256x16 => 16x16x16. Here is my shader code for sampling the texture: [source lang="cpp"]half4 outColor; half4 inColor = tex2D(colorMap, inUV); half3 lutSize = half3(16.0h, 16.0h, 16.h); half3 scale = (lutSize - 1.0h) / lutSize; half3 offset = 1.0h / (2.0h * lutSize); outColor.rgb = tex3D(LUTSampler, scale * inColor.rgb + offset); outColor.a = 1.0h; return outColor;[/source] My results are totally weird, for example everything is either bright green and pink. I am assuming either the "color neutral" texture I am using from Epic's website isnt neatral OR I am doing something wrong. If my code is correct does anyone know how I could generate a color neutral 3D lut? Also, I converted the 2D image to 3D by writing a little tool that would write each 16 wide section of the original texture into a new slice of the volume texture. I checked each slice manually in the d3d texture tool and it was correct. I thought maybe the slice order was wrong but that didnt change anything except make it all red and black instead of pink and green. It's almost as if it only samples from the bottom slice... I've attached a screen shot, ignore the vignette... Thanks
  6. Irradiance map issues

    Never mind figured it out. Coordinate system is different from the ones used to generate the cube maps.
  7. I am experimenting with irradiance maps for use in ambient diffuse lighting. I've encountered an issue where when I sample the cube map I get weird banding and harsh falloffs. When I move an object around that is using an irradiance map its extremely noticeable. Anyone have any ideas as to what the issue could be? My shader is very simple: [code]float4 ambientDiffuse = texCUBE(irradianceCubeMap, worldSpaceNormal) * DiffuseTexture; return ambientDiffuse;[/code] This is what I see as a result [img]http://i43.tinypic.com/wqvrdl.png[/img] You'll notice it moves from dark to light very abruptly and it looks terrible when in motion. I've tested with multiple cube maps but I always see the same thing. Thanks for any help
  8. Thanks for the reply. I think I found what I am looking for using Epic's approach: http://udn.epicgames.com/Three/VolumetricLightingGuide.html
  9. Basically I am looking for a good way to simulate light beams or rays of light. I say "non-deferred" because the light beams do not have to interact with the scene they just need to look like rays of light so a z-prepass seems unnecessary. People have been doing this for years not sure why I am having a hard time o.O Anyone have a good technique for doing this? My first approach was to do reverse rim lighting on a cone with a falloff like this: // I assume that the local origin of the object is 0, 0, 0 float transparency = 1 - saturate(length(In.localPosition) / Falloff); float3 V = normalize(In.eyeVec); float3 Nn = normalize(In.worldNormal); float rim = pow(dot(Nn, V), RimPower) * transparency * RimColor.a * RimIntensity; return float4(RimColor.rgb, rim); This looks good only when the surface normals are facing the camera...
  10. Hi I am trying to implement a self shadowing technique in D3D that I already have working in OpenGL and I am confused about one thing. In OpenGL I can set the comparison mode of a texture (using GL_TEXTURE_COMPARE_MODE) meaning I can sample the texture and use that value as a reference in a comparison (getting a value of 0 or 1) rather then sampling like a normal texture. I am fairly new to D3D and couldn't figure out how to do this via the documentation. Any help is appreciated.
  11. I've searched for the answer to this question and can only find documentation for vertex shader 3.0 maximum constants which is 256. Anyone know how many it is for pixel shaders? cheers
  12. OpenGL OpenGL optimizations and bottlenecks

    Anyone know a good free cpu profiler? I'd like to examine which functions are called the most often, it is quite possible that the wrapper functions are taxing the cpu. Also, thanks very much for all the input so far.
  13. OpenGL OpenGL optimizations and bottlenecks

    I have tried changing the usage flag for the vbos dynamic/static/stream and this made zero difference. At the end of the day the drivers decide where the vbo's reside regardless of where you ask them to put the data =/ I emulate the DX flexible vertex formats by setting up vertex streams in the following way: void GL_SetStreamSource(unsigned int stream_num, unsigned int vbo, unsigned int stride, unsigned int format, void* stream) { static unsigned int last_fvf = 0; int base_offset = currentIndexBuffer.base_offset * stride; int buffer_pos = 0; int num_coords = 0; int tex_count = D3DFVF_TEXCOUNT(last_fvf); int i; unsigned char* data; JGASSERTMSG(stream_num < MAX_STREAMS, "TOO MANY STREAMS!"); // If stream is NULL then we are using a VBO which resides // in GPU memory. Once bound all GL vertex ops are done on THAT buffer. if(stream == NULL) { glBindBuffer(GL_ARRAY_BUFFER, vbo); } for(i = 0; i < tex_count; i++) { unsigned int tex_stage = GL_TEXTURE0 + i; glClientActiveTexture(tex_stage); glActiveTexture(tex_stage); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } glClientActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); currentVertexStream[stream_num].format = format; currentVertexStream[stream_num].streamID = stream_num; currentVertexStream[stream_num].stride = stride; currentVertexStream[stream_num].vboID = vbo; currentVertexStream[stream_num].data = stream; last_fvf = format; data = (unsigned char*)stream; // setup the data formats if(format & D3DFVF_XYZ) { if(stream == NULL) glVertexPointer(3, GL_FLOAT, (GLsizei)stride, BUFFER_OFFSET(base_offset)); else glVertexPointer(3, GL_FLOAT, (GLsizei)stride, (GLvoid*)&data[base_offset]); glEnableClientState(GL_VERTEX_ARRAY); buffer_pos += sizeof(rt_vec3); } if(format & D3DFVF_XYZRHW) { if(stream == NULL) glVertexPointer(4, GL_FLOAT, (GLsizei)stride, BUFFER_OFFSET(base_offset)); else glVertexPointer(4, GL_FLOAT, (GLsizei)stride, (GLvoid*)&data[base_offset]); glEnableClientState(GL_VERTEX_ARRAY); buffer_pos += sizeof(rt_vec4); } if(format & D3DFVF_NORMAL) { if(stream == NULL) glNormalPointer(GL_FLOAT, (GLsizei)stride, BUFFER_OFFSET(buffer_pos + base_offset)); else glNormalPointer(GL_FLOAT, (GLsizei)stride, (GLvoid*)&data[buffer_pos + base_offset]); glEnableClientState(GL_NORMAL_ARRAY); buffer_pos += sizeof(rt_vec3); } if(format & D3DFVF_DIFFUSE) { if(stream == NULL) glColorPointer(4, GL_UNSIGNED_BYTE, (GLsizei)stride, BUFFER_OFFSET(buffer_pos + base_offset)); else glColorPointer(4, GL_UNSIGNED_BYTE, (GLsizei)stride, (GLvoid*)&data[buffer_pos + base_offset]); glEnableClientState(GL_COLOR_ARRAY); buffer_pos += sizeof(unsigned int); } tex_count = D3DFVF_TEXCOUNT(format); for(i = 0; i < tex_count; i++) { unsigned int tex_stage = GL_TEXTURE0 + i; num_coords = D3DFVF_TEXCOORDSIZE(format, i); glClientActiveTexture(tex_stage); glActiveTexture(tex_stage); if(stream == NULL) glTexCoordPointer(num_coords, GL_FLOAT, (GLsizei)stride, BUFFER_OFFSET(buffer_pos + base_offset)); else glTexCoordPointer(num_coords, GL_FLOAT, (GLsizei)stride, (GLvoid*)&data[buffer_pos + base_offset]); glEnableClientState(GL_TEXTURE_COORD_ARRAY); buffer_pos += (num_coords * sizeof(float)); } // reset current texture unit glClientActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0); } The glTexEnvi calls are being called when a change is made using SetTextureStageState(unsigned int stage, D3DTEXTURESTAGESTATETYPE type, unsigned int value); This function will change any color op, alpha op, color arguments, or alpha arguments in DX. This function is only called if the value is different then the current value for this current stage. I then only call glTexEnvi IF any of those values are dirty, in other words, a value changes. void GL_SetupTextureEnvironment() { int i; for(i = 0; i < MAX_STAGES; i++) { if(active_texture_stages[i]) { GLenum texture_stage = GL_TEXTURE0 + i; // if the color op is disable we disable all our // texturing units from i to max if(colorOpSettings[i].op == D3DTOP_DISABLE) { int j; for(j = i; j < MAX_STAGES; j++) { glClientActiveTexture(texture_stage); glActiveTexture(texture_stage); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_CUBE_MAP_EXT); texture_stage++; } // exit since all stages after 'i' have been // disabled break; } // activate the current texture stage for our texture // color operations glClientActiveTexture(texture_stage); glActiveTexture(texture_stage); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); if(colorOpSettings[i].is_dirty) GL_DoColorOperations(i); //glTexEnvi calls if(alphaOpSettings[i].is_dirty) GL_DoAlphaOperations(i); //glTexEnvi calls } } } [Edited by - thedigga007 on April 9, 2008 5:27:30 PM]
  14. OpenGL OpenGL optimizations and bottlenecks

    I removed the PBO's earlier and the performance gain was not noticeable. As for the FBO's I am doing them exactly as you said, I have 6 color attachments and change the attachment: void GL_SetRenderTargetAttachment(GLTexture* render_target, unsigned int attachment) { unsigned int gl_attachpoint = GL_COLOR_ATTACHMENT0_EXT + attachment; glDrawBuffer(gl_attachpoint); } I've tried running without FBO's and I gain about 5-10fps but I am still teetering between 35-45fps =/ One other thing that may be worth noting I am using glMultMatrixf() could this be a potential hit since its done on the GPU? Update: So after profiling with gDEBugger I do not seem to find any serious bottlenecks using gDEBugger's profiling mode. As for the OpenGL function call statistics the most calls were made to: glTexEnvi 19.55% glActiveTexture 11.48% glGetUniformLocation 6.79% glMaterialfv 3.12% glDisable - GL_TEXTURE_2D 2.26% Are any of those gl calls particularly costly? If disabling parts of the pipeline do no yield any significant gains then perhaps I am CPU bound? [Edited by - thedigga007 on April 8, 2008 9:35:31 PM]
  15. OpenGL OpenGL optimizations and bottlenecks

    Unfortunately I cannot post a screen shot due to NDA's. Hardware its running on right now: nvidia 7300 GS OC 256MB Pentium D 2.80 Ghz 1G ram dmatter: Yes I've have thought about that as well and perhaps I am just CPU bound from all the wrapper functions (though I doubt that) or the way I am supplying the data to OpenGL is not optimal. Rundown of the rendering process: 1) Set the stream source (glVertexPointer, glNormalPointer, glTexCoordPointer, etc). 2) Set lights. 3) Bind glsl program if model uses one. 4) Bind textures. 5) Setup the texture environment 6) Setup the render states 7) Set any materials if necessary 8) Render code for the render: void GL_DrawIndexedPrimitive(D3DPRIMITIVETYPE primitive_type, unsigned int min_index, unsigned int num_vertices, unsigned int start_index, unsigned int primitive_count) { D3DMATRIX savedProj; GLenum primitive = GL_D3DPrimitiveToOpenGL(primitive_type); GLsizei count = GL_GetElementCount(primitive_type, primitive_count); if(d3dlighting_enabled) { GL_SetD3DLightingConstants(); } // Don't setup the TEV if there is no fragment shader attached. if(shaderContext) { if(!shaderContext->is_fs_attached) GL_SetupTextureEnvironment(); } else GL_SetupTextureEnvironment(); if(currentBlendMode.enable) { glBlendEquation(currentBlendMode.mode); glBlendFunc(currentBlendMode.sfactor, currentBlendMode.dfactor); } if(currentAlphaMode.enable) { glAlphaFunc(currentAlphaMode.func, currentAlphaMode.ref); } // opengl doesnt support pre-transformed geometry if(currentVertexStream[0].format & D3DFVF_XYZRHW) { GL_Set2DMode(&savedProj); } glDrawElements(primitive, count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(sizeof(unsigned short)*start_index)); // reset matrices if(currentVertexStream[0].format & D3DFVF_XYZRHW) { GL_Set3DMode(&savedProj); } } ------------------------------------------- My NDA does not restrict me to posting code containing the actual renderer since it has no proprietary code in it and is simply d3d->opengl calls.