Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Mar 2006
Offline Last Active Jun 13 2016 10:21 AM

#5279566 Kinect depth problem

Posted by on 04 March 2016 - 05:02 PM

NUI data is 16 bits with 3 reserved bits for player masks.

I.e., the conversion looks like: (((unsigned short*)depthPixels)[(((i * depthWidth)+j))] >> 3)


Which means that if you want to destroy your data and convert to 8 bit, that you need to scale by 2^13-1 instead of 2^8-1.

awfulDepth = (((kinectDepth >> 3) / 2^13-1)) * (2^8-1).


Why on earth you would want to do this is beyond me, but good luck.

#5272281 Detecting Boundaries in triangles with adjacency

Posted by on 22 January 2016 - 01:05 PM

You can grab the index in the vertex shader with SV_VertexID and pass it along. Maybe that helps.


Interesting thought.

The vertex shader would only run on vertices present in the vertex buffer though :P.

What I'm really interested in is what the gpu does with indices that are -1 when forming the input vertices for triangleadj:

void gs( triangleadj vertex input[6], inout TriangleStream<vertex> triStream )

Mind you, this approach would definitely be a faster method of testing if I were to replace the -1 adjacency indices with index-1 when I compute the adjacency buffer.

for (uint id = 0; id<6; id+=2)
    uint index0 = (uint)fmod( id, 6.0f );
    if (input[index0].vertexId == input[index0+1].vertexId)

#5193896 Proper C++ header file?

Posted by on 20 November 2014 - 07:57 PM


I would also suggest to replace







#pragma once


it's simpler and you don't need the #endif at the end smile.png


The only problem with it is that it is not part of the C/C++ standard, so while it is supported by major compilers, it can't be guaranteed to always work.




I thought that I should extend this a little.

Compiler support for this is wide.



However, I'm yet to see someone screw up #ifndef INCLUDED_#

(Aside from me, just then). tongue.png.


Maybe I'm just being old and crotchety and indicating to people to get off of my lawn. 

For me, I prefer #ifndef/#define.

I prefer not to see "#pragma" in my code unless it is inline adding a library (which I prefer it wouldn't (still guilty of this myslef)), or disabling particularly annoying Microsoft compile warnings.

I started with Visual Studio 5.0, and #pragma meant "hear be dragons" to me.


I think that preference on this may fit under "religious/other".



#5193869 Proper C++ header file?

Posted by on 20 November 2014 - 03:59 PM

Some general thoughts and ramblings.

Ramblings are inlined in comments. :).


// You are only using string.
// You should only include string.
// Judiciously including only what you use will improve compile times.
// This is so important that people have written tools to ensure that a
// code base adheres to this:
// https://code.google.com/p/include-what-you-use/wiki/WhyIWYU
#include <string>

// Style guides, totally worth reading up on.
// Seeing as you are just starting out, choose a different one for every project.
// Adhere to it. Learn what you don't like about it:
// http://google-styleguide.googlecode.com/svn/trunk/cppguide.html
// http://udn.epicgames.com/Three/CodingStandard.html
// http://wiki.ros.org/CppStyleGuide
// Many more by googling "c++ style guide" + some company name.
class TileMap
    // Declare the default constructor. Even though a default is provided, it is
    // a really, really good habit to get into.

    // Declare the copy constructor. It will save you later.
    // I would also (maybe) suggest looking into the concept of "non copyable".
    TileMap(const TileMap& from);
    TileMap(const std::string& name, const std::string& location);

    // Declare the default destructor. Even though a default is provided, it is a 
    // life saving habit to get into.

    // Again, one is provided, but quite honestly, this is a another life saving habit
    // to get into when you are just starting out.
    TileMap&            operator=(const TileMap &);

    // Const references for input when setting a value.
    void                setName(const std::string& inName);

    // I assume that "loc" is location. 
    // A longer variable name will help you later when you have other stuff to think about.
    void                setLocation(const std::string& inLocation);

    // Accessors usually are const. I tend to loathe using get on the "gettor".
    // Returning a const ref here is also faster. 
    // I also suggest reading up on return value optimization...
    // http://en.wikipedia.org/wiki/Return_value_optimization
    // If you are aiming for well performing code I would recommend doing away with
    // the use of std::string all together and using const char*.
    // Supplying a const char* in the "create" function should also lead you onto
    // topics such as "copy on write", which is something totally worth reading about:
    // (But not until you know why you shouldn't have a function 
    //  operator in a class declaration :) ).
    // http://en.wikipedia.org/wiki/Copy-on-write 
    // Now I'm rambling, so I will stop.
    const std::string&  name() const;
    const std::string&  location() const;

    // You should probably consider marking your members with a character 
    // that indicates the variable is a member. 
    // Some naming models become very elaborate at the expense of readability.
    // I prefer underscores, others prefer m, some specs prefer extended information
    // for pointers. I.e., if _name were a pointer, the variable would be _pName or mpName.
    std::string         _name; // or mName
    std::string         _loc; // or mLoc


#5191944 Tool release for physically based rendering

Posted by on 09 November 2014 - 12:43 PM

I've recently released an image based lighting baker for physically based rendering to generate preconvonvolved specular cube maps (computed against a user specified brdf) using the seperable method proposed by Epic during Siggraph 2013.


The tool also bakes out the BRDF LUT, and a diffuse irradiance environment map. Cubemaps are saved as both MDR and HDR.


You can find the tool at:
There are also a number of walkthrough and example videos at:

I have also supplied 2 Maya example scenes to test the cubemap outputs using Viewport 2.0 and cgfx.


Please contact me through my github account if you find any bugs, have questions or have any suggestions. The code is based on some of my older framework code. You'll have to hold your nose around some of the more horrible bits.


Hopefully some of you find this useful.

If there is any interest, I'd consider writing an article on this.


I thought I'd throw in another quick demo of this tech applied to character rendering. (Still proof of concept really):

#5049073 Free texture image memory after binding it

Posted by on 01 April 2013 - 09:42 PM

Yes, glTexImage2D is copying your image data.


Probably worth mentioning GL synchronization notes:

This stuff used to be a little different, and has improved immensely:


From: http://www.opengl.org/wiki/Synchronization

Legacy Note: The only OpenGL functions that behave differently are functions that end in Pointer​. When these use client-side memory (which is no longer permitted in core OpenGL), the pointers are stored for a period of time. During that period, they must remain valid.

These are usually used for rendering calls; in which case, once the rendering call has returned, the memory to be read from client data has been read. Modifications to client memory after the rendering call will only affect future rendering calls, not those that have already passed.
This is generally why Buffer Objects are better than using client memory for rendering. A rendering call with buffers does not have to handle the possibility of the user changing the memory later, so it can simply write a few tokens into the command stream. With client memory, it must copy all of the vertices out of the client-side arrays.