• Advertisement

Kjell Andersson

Member
  • Content count

    143
  • Joined

  • Last visited

Community Reputation

657 Good

About Kjell Andersson

  • Rank
    Member

Personal Information

  • Interests
    Business
    Programming
  1. Blooming OpenFX plugin

    For those doing promotional videos for their games we have released a video plugin that allows you to add glow, aka blooming, as a post effect in your video pipeline. The plugin is an OpenFX plugin that works in video editing software such as Nuke, Catalyst Edit, Natron or any other OpenFX compatible host software. The blooming filter allows you to set the threshold intensities that you want affected by the glow. You can also color tint the glow or make it anisotropic for stretched glow effects typically used for really bright intensity light streaks. Sample of an image before the blooming effect is applied: Image after blooming has been applied: You can find out more about this plugin on the Genifect OpenFX plugin suite page.
  2. DX11 3D Model Coding Question - DX11

    The Autodesk FBX SDK is a widely used toolkit for loading models and playback of animations. The SDK is generic and can be tied to whatever 3D API you want to use (OpenGL, DirectX etc) in the sence that it loads and animates the mesh and when it is finished you have to transfer the computed mesh vertices to your favorite 3D API. The SDK contains examples on how to use the SDK but if I recall it only contains the glue towards OpenGL. That can be translated over to DirectX quite easily though since you are just dealing with simple vertices and material properties.
  3. OpenGL OpenGL legacy to shader mapping

    Thank you Zao, you saved my day! You gave the exact answer I was looking for. I had my doubts about interoperability between legacy and modern OpenGL, and you confirmed it. It is however as you say, the texture coordinate was to be found at position 8 when I tested it, but since this may be NVIDIA specific I have to find a way around it.
  4. I'm trying to get some legacy OpenGL code to run with a shader pipeline, The legacy code uses glVertexPointer(), glColorPointer(), glNormalPointer() and glTexCoordPointer() to supply the vertex information. I know that it should be using setVertexAttribPointer() etc to clearly define the layout but that is not an option right now since the legacy code can't be modified to that extent. I've got a version 330 vertex shader to somewhat work: #version 330 uniform mat4 osg_ModelViewProjectionMatrix; uniform mat4 osg_ModelViewMatrix; layout(location = 0) in vec4 Vertex; layout(location = 2) in vec4 Normal; // Velocity layout(location = 3) in vec3 TexCoord; // TODO: is this the right layout location? out VertexData { vec4 color; vec3 velocity; float size; } VertexOut; void main(void) { vec4 p0 = Vertex; vec4 p1 = Vertex + vec4(Normal.x, Normal.y, Normal.z, 0.0f); vec3 velocity = (osg_ModelViewProjectionMatrix * p1 - osg_ModelViewProjectionMatrix * p0).xyz; VertexOut.velocity = velocity; VertexOut.size = TexCoord.y; gl_Position = osg_ModelViewMatrix * Vertex; } What works is the Vertex and Normal information that the legacy C++ OpenGL code seem to provide in layout location 0 and 2. This is fine. What I'm not getting to work is the TexCoord information that is supplied by a glTexCoordPointer() call in C++. Question: What layout location is the old standard pipeline using for glTexCoordPointer()? Or is this undefined? Side note: I'm trying to get an OpenSceneGraph 3.4.0 particle system to use custom vertex, geometry and fragment shaders for rendering the particles.
  5. Personal Dance VR

    It's time for a game release again. This time it's going on Steam GreenLight (for as long as it's still available).   This is quite a different type of game in that it's not actually a game per se but more of an amusement experience for virtual reality that is playing with the feeling of personal connection. It's a virtual dance floor where you get to dance with virtual characters to your favourite music. I guarantee you that your dance partner will notice your presence!   Check it out on Steam: http://steamcommunity.com/sharedfiles/filedetails/?id=864584902      
  6. Text Rendering In D3D11/12

    If you want to go all-in for a good implementation of text rendering you should look up the concept of "Signed Distance Field Text Rendering".   The original article that introduced the concept was written by Valve and can be found here: http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
  7. Caustics Generator for Mac OS X

    The Caustics Generator is now also available in a Free version for all you Mac hobby developers.
  8. Help me decide - shadow under hood/cowl or not?

    I like the one with the eyes more. It gives the character more personality.   You could go half way and keep a small shadow instead of going all black.
  9. Caustics Generator for Mac OS X

    Caustics Generator is now available for Mac OS X. This is the first release on the Mac platform of the software and has been longed for by the graphical artists and designers that love to work on their Mac. The Caustics Generator software allows artists to create faked water lighting by generating pre-calculated caustics textures that seamlessly tile and animate. These texture can be used for both real-time graphics such as games and simulations but are also very popular by the architect, movie and advertising industry as part of the rendering pipeline for creating computer graphics visualizations. The Caustics Generator software has previously only been available for Windows and Linux, but this release meets many artists on their choice of computer. More information about the Caustics Generator can be found at: https://www.dualheights.se/caustics  
  10. Exporting mesh vertex group to text.

    The following code provides you with vertices and face indices from a D3DXMesh. You will have to write the code that saves it to file yourself, but that should be easy. LPD3DXMESH m_pD3DMesh; void MeshXWrapper::GetMeshData(int *pMeshVertexCount, dVector3 **ppMeshVertices, int *pMeshIndexCount, int **ppMeshIndices) { LPDIRECT3DVERTEXBUFFER9 pVB = NULL; m_pD3DMesh->GetVertexBuffer(&pVB); struct MY_FVF { float x; float y; float z; }; void *pbVertexData; if (SUCCEEDED(pVB->Lock(0, 0, &pbVertexData, D3DLOCK_READONLY))) { DWORD numBytesPerVertex = m_pD3DMesh->GetNumBytesPerVertex(); int numVertices = m_pD3DMesh->GetNumVertices(); *ppMeshVertices = new dVector3[numVertices]; unsigned char *pVBDataPos = (unsigned char*)pbVertexData; for (int i=0; i < numVertices; i++) { (*ppMeshVertices)[i][0] = ((MY_FVF*)pVBDataPos)->x; (*ppMeshVertices)[i][1] = ((MY_FVF*)pVBDataPos)->y; (*ppMeshVertices)[i][2] = ((MY_FVF*)pVBDataPos)->z; (*ppMeshVertices)[i][3] = 0; pVBDataPos += numBytesPerVertex; } pVB->Unlock(); *pMeshVertexCount = m_pD3DMesh->GetNumVertices(); } // Index buffer LPDIRECT3DINDEXBUFFER9 pIB; m_pD3DMesh->GetIndexBuffer(&pIB); D3DINDEXBUFFER_DESC indexDesc; pIB->GetDesc(&indexDesc); LPVOID pbIndexData; if (SUCCEEDED(m_pD3DMesh->LockIndexBuffer(D3DLOCK_READONLY, &pbIndexData))) { *pMeshIndexCount = indexDesc.Size / sizeof(unsigned short); *ppMeshIndices = new int[*pMeshIndexCount]; for (int i=0; i<(*pMeshIndexCount)/3; i++) { unsigned short i0 = ((unsigned short*)pbIndexData)[i*3+0]; unsigned short i1 = ((unsigned short*)pbIndexData)[i*3+1]; unsigned short i2 = ((unsigned short*)pbIndexData)[i*3+2]; (*ppMeshIndices)[i*3+0] = i0; (*ppMeshIndices)[i*3+1] = i1; (*ppMeshIndices)[i*3+2] = i2; } m_pD3DMesh->UnlockIndexBuffer(); } pIB->Release(); pVB->Release(); }
  11. IOTD broken

    Oh, forgot to mention that it was the IOTD game I meant. Silly me. But it seems to be working now again so it's all right.
  12. IOTD broken

    The right side image is always broken and never loads (404).
  13. Dumping every frame to an image file

    This is the code that I use to take screenshots in-app. Note that if run in windowed mode it captures the entire desktop and cuts out the window area. This means that if some other window is put in front of your window it will capture that data as well. LPDIRECT3DSURFACE9 CaptureScreen() { UINT width; UINT height; if (IsFullscreen()) { width = GetDisplayWidth(); height = GetDisplayHeight(); } else { width = GetSystemMetrics(SM_CXSCREEN); height = GetSystemMetrics(SM_CYSCREEN); } LPDIRECT3DSURFACE9 pCaptureSurface; HRESULT hr = GetD3DDevice()->CreateOffscreenPlainSurface(width, height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pCaptureSurface, NULL); if (FAILED(hr)) { SAFE_RELEASE(pCaptureSurface); return NULL; } hr = GetD3DDevice()->GetFrontBufferData(0, pCaptureSurface); if (FAILED(hr)) { SAFE_RELEASE(pCaptureSurface); return NULL; } return pCaptureSurface; } bool TakeScreenshot(const std::wstring& filename) { LPDIRECT3DSURFACE9 pCaptureSurface = GetGraphicsDevice()->CaptureScreen(); HRESULT hr = E_FAIL; if (pCaptureSurface != NULL) { D3DXIMAGE_FILEFORMAT imageFileFormat = D3DXIFF_JPG; std::wstring fileExtention = GXFile::GetFileExtention(filename); if (GXString::CompareNoCase(fileExtention.c_str(), L"bmp")) { imageFileFormat = D3DXIFF_BMP; } else if (GXString::CompareNoCase(fileExtention.c_str(), L"png")) { imageFileFormat = D3DXIFF_PNG; } if (GetGraphicsDevice()->IsFullscreen()) { hr = D3DXSaveSurfaceToFile(filename.c_str(), imageFileFormat, pCaptureSurface, NULL, NULL); if (FAILED(hr)) { GXLOG_WARN_F(L"Failed to save fullscreen screenshot to %s", filename.c_str()); } } else { // Calculate the rectangle within the screen that the window is currently located. // I.e. 0,0 is top left of screen for all screens even on multi-monitor setups. RECT rcWindow; GetClientRect(m_hWnd, &rcWindow); POINT topPoint = {rcWindow.left, rcWindow.top}; POINT bottomPoint = {rcWindow.right, rcWindow.bottom}; ClientToScreen(m_hWnd, &topPoint); ClientToScreen(m_hWnd, &bottomPoint); rcWindow.left = topPoint.x; rcWindow.top = topPoint.y; rcWindow.right = bottomPoint.x; rcWindow.bottom = bottomPoint.y; for (unsigned int i = 0; i < m_displays.size(); i++) { RECT rcDest; if (IntersectRect(&rcDest, &m_displays[i].rect, &rcWindow)) { rcWindow.left -= m_displays[i].rect.left; rcWindow.top -= m_displays[i].rect.top; rcWindow.right -= m_displays[i].rect.left; rcWindow.bottom -= m_displays[i].rect.top; break; } } hr = D3DXSaveSurfaceToFile(filename.c_str(), imageFileFormat, pCaptureSurface, NULL, &rcWindow); if (FAILED(hr)) { GXLOG_WARN_F(L"Failed to save windowed screenshot to %s", filename.c_str()); } } SAFE_RELEASE(pCaptureSurface); } return SUCCEEDED(hr); }
  14. What is the best way of finding D3D9 resource leaks on a Windows 10 machine nowadays? I must add that the leak is not easily reproducible also.   I find it more and more difficult to work with legacy D3D9 applications since the debug version no longer works on a modern Windows. Are there any new tools available that can help me, like nSight or GPU PerfStudio or such?
  15. Blinn-Phong artifact in shader

    Thanks! I kind of liked the scattering of specular around the rim before multiplying with NdotL, but I guess that should not be part of the Blinn calculations but rather some subsurface scattering effect.
  • Advertisement