Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 26 Mar 2013
Offline Last Active Today, 11:09 AM

#5292094 What is this artifact in my shadow map?

Posted by markypooch on 17 May 2016 - 11:19 AM

Two thoughts come to mind.


Have you tried playing around with the bias? Tweaking it until the issue is not visible on the geometry?

Also, are you using a nullified Sampler State, or did you specify a clamped sampler?


Marcus Hansen

#5290448 XNA Width And Height Problem

Posted by markypooch on 06 May 2016 - 11:32 AM

To further elaborate on nscu121978's answer.


"If you request a back-buffer resolution that is not supported by the output device, the XNA Framework automatically selects the highest resolution supported by the output device. For example, if a graphics back buffer with a resolution of 1920×1080 (1080p or 1080i) is created and displayed on a device with 480i resolution, the back buffer automatically is resized to 480i."




This is verbatim from the MSDN website on the use of preferredBackBufferWidth & Height.

Also, it seems there's a general consensus that the ApplyChanges Method should only be called within the update method of your game class, not entirely sure that it matters, but it's worth a shot.


Marcus Hansen

#5289067 triangle culling in close proximity to other triangles?

Posted by markypooch on 28 April 2016 - 04:43 AM



haha, it would probably help if I knew what I was looking at ;)


But have you ruled out the possibility of inverted normals on the mesh, with BF culling that would certainly create the issue of triangles not appearing...


Marcus Hansen

#5288014 Going multi-threaded | Batches and Jobs

Posted by markypooch on 21 April 2016 - 12:01 PM

Basicly I don't understand what 'Batches' and 'Jobs' are.


What are 'Batches' and 'Jobs' when generally speaking about Thread Pooling?

What are the best way to identify a function call as a 'Batch' or either as a 'Job'?


Hello Julien,


Essentially when he means jobs, he simply is implying work that an engine sub-system has to perform. When he says batch, it's just a conceptualization in the context of the article of a group of individual objects deli-metered based upon some logical segmentation (A BSP Tree perhaps) being submitted to a ThreadPool Queue.


How would one go about creating a multi-thread system?


To my knowledge, C/C++ by itself has no notion of multi-threading. But, here goes a pretty simple example in C, from MSDN, also I'm pretty sure the threading code here is not portable. But, I think Boost does offer a portable solution...



// sample_multithread_c_program.c
// compile with: /c
//  Bounce - Creates a new thread each time the letter 'a' is typed.
//  Each thread bounces a happy face of a different color around
//  the screen. All threads are terminated when the letter 'Q' is
//  entered.

#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <process.h>

#define MAX_THREADS  32

// The function getrandom returns a random number between
// min and max, which must be in integer range.
#define getrandom( min, max ) (SHORT)((rand() % (int)(((max) + 1) - \
                               (min))) + (min))

int main( void );                    // Thread 1: main
void KbdFunc( void  );               // Keyboard input, thread dispatch
void BounceProc( void * MyID );      // Threads 2 to n: display
void ClearScreen( void );            // Screen clear
void ShutDown( void );               // Program shutdown
void WriteTitle( int ThreadNum );    // Display title bar information

HANDLE  hConsoleOut;                 // Handle to the console
HANDLE  hRunMutex;                   // "Keep Running" mutex
HANDLE  hScreenMutex;                // "Screen update" mutex
int     ThreadNr;                    // Number of threads started
CONSOLE_SCREEN_BUFFER_INFO csbiInfo; // Console information

int main() // Thread One
    // Get display screen information & clear the screen.
    hConsoleOut = GetStdHandle( STD_OUTPUT_HANDLE );
    GetConsoleScreenBufferInfo( hConsoleOut, &csbiInfo );
    WriteTitle( 0 );

    // Create the mutexes and reset thread count.
    hScreenMutex = CreateMutex( NULL, FALSE, NULL );  // Cleared
    hRunMutex = CreateMutex( NULL, TRUE, NULL );      // Set
    ThreadNr = 0;

    // Start waiting for keyboard input to dispatch threads or exit.

    // All threads done. Clean up handles.
    CloseHandle( hScreenMutex );
    CloseHandle( hRunMutex );
    CloseHandle( hConsoleOut );

void ShutDown( void ) // Shut down threads
    while ( ThreadNr > 0 )
        // Tell thread to die and record its death.
        ReleaseMutex( hRunMutex );

    // Clean up display when done
    WaitForSingleObject( hScreenMutex, INFINITE );

void KbdFunc( void ) // Dispatch and count threads.
    int         KeyInfo;

        KeyInfo = _getch();
        if ( tolower( KeyInfo ) == 'a' &&
             ThreadNr < MAX_THREADS )
            _beginthread( BounceProc, 0, &ThreadNr );
            WriteTitle( ThreadNr );
    } while( tolower( KeyInfo ) != 'q' );


void BounceProc( void *pMyID )
    char    MyCell, OldCell;
    WORD    MyAttrib, OldAttrib;
    char    BlankCell = 0x20;
    COORD   Coords, Delta;
    COORD   Old = {0,0};
    DWORD   Dummy;
    char    *MyID = (char*)pMyID;

    // Generate update increments and initial
    // display coordinates.
    srand( (unsigned int) *MyID * 3 );

    Coords.X = getrandom( 0, csbiInfo.dwSize.X - 1 );
    Coords.Y = getrandom( 0, csbiInfo.dwSize.Y - 1 );
    Delta.X = getrandom( -3, 3 );
    Delta.Y = getrandom( -3, 3 );

    // Set up "happy face" & generate color
    // attribute from thread number.
    if( *MyID > 16)
        MyCell = 0x01;          // outline face
        MyCell = 0x02;          // solid face
    MyAttrib =  *MyID & 0x0F;   // force black background

        // Wait for display to be available, then lock it.
        WaitForSingleObject( hScreenMutex, INFINITE );

        // If we still occupy the old screen position, blank it out.
        ReadConsoleOutputCharacter( hConsoleOut, &OldCell, 1,
                                    Old, &Dummy );
        ReadConsoleOutputAttribute( hConsoleOut, &OldAttrib, 1,
                                    Old, &Dummy );
        if (( OldCell == MyCell ) && (OldAttrib == MyAttrib))
            WriteConsoleOutputCharacter( hConsoleOut, &BlankCell, 1,
                                         Old, &Dummy );

        // Draw new face, then clear screen lock
        WriteConsoleOutputCharacter( hConsoleOut, &MyCell, 1,
                                     Coords, &Dummy );
        WriteConsoleOutputAttribute( hConsoleOut, &MyAttrib, 1,
                                     Coords, &Dummy );
        ReleaseMutex( hScreenMutex );

        // Increment the coordinates for next placement of the block.
        Old.X = Coords.X;
        Old.Y = Coords.Y;
        Coords.X += Delta.X;
        Coords.Y += Delta.Y;

        // If we are about to go off the screen, reverse direction
        if( Coords.X < 0 || Coords.X >= csbiInfo.dwSize.X )
            Delta.X = -Delta.X;
            Beep( 400, 50 );
        if( Coords.Y < 0 || Coords.Y > csbiInfo.dwSize.Y )
            Delta.Y = -Delta.Y;
            Beep( 600, 50 );
    // Repeat while RunMutex is still taken.
    while ( WaitForSingleObject( hRunMutex, 75L ) == WAIT_TIMEOUT );

void WriteTitle( int ThreadNum )
    enum {
        sizeOfNThreadMsg = 80
    char    NThreadMsg[sizeOfNThreadMsg];

    sprintf_s( NThreadMsg, sizeOfNThreadMsg,
               "Threads running: %02d.  Press 'A' "
               "to start a thread,'Q' to quit.", ThreadNum );
    SetConsoleTitle( NThreadMsg );

void ClearScreen( void )
    DWORD    dummy;
    COORD    Home = { 0, 0 };
    FillConsoleOutputCharacter( hConsoleOut, ' ',
                                csbiInfo.dwSize.X * csbiInfo.dwSize.Y,
                                Home, &dummy );


So this is pretty simple. While 'q' has not been pressed, and if 'a' has been pressed, and if ntThread is less than 32; increment ntThread, pass the BounceProc function as an argument to the __beginThread() function.


insofar as how to structure this in a typical Game Engine though the article gave some high level insight on it, a deeper explanation on it however would probably be a question best reserved for some other members here, as my only real experience with Multi-Threading was with Java several years ago.


Marcus Hansen

#5281543 Match-3 puzzle game algorithms

Posted by markypooch on 16 March 2016 - 02:57 PM


I want a 9X9 grid layout for the game and I would like to have some guidance to design the algorithms to fill up the empty cells of the grid, after match making takes place. I also would like some guidance on how to design the level progression and ramp up the difficulty in a match three puzzle game.


Well I'm not sure how you have your program structured so far (And if you've chosen to have your board represented by a simple array), but code for populating a 1D, or 2D array (in the following example 2D) is quite simple, and can be expressed in many ways. But one simple way is:

//Psuedo Code
Cell board[9][9];
for (i = 0 to board.length())
    for (j = 0 to board.length()) //Assuming your board is 
always column, and row symmetrical
        board[i][j] = new Cell() //where 
your default constructor for cell will just self initialize to be representative 
of an empty cell
        //Or alternatively
        board[i][j] = new 

Of course, I would imagine as Frob sated that populating your board at pure random may lead to cases that as soon as your game loads you get a match 3 Or match 4 without player intervention, which is obviously a sign of either a very liberal, and player friendly Matching game, or a poorly designed one. (I once played a version of bejeweled that upon a level loading I would get Match 4s all over the place, haha, let's just say Wisdom Cat was not amused)


One simple to code game would be TicTacToe. This would give you an idea on how a very basic matching game is created, and potentially provide you with a base to build into a more complex project which ultimately seems like what you want.



#5281260 visual problem with texture tiling

Posted by markypooch on 14 March 2016 - 03:35 PM

This is a well know issue. 

One solution would be to flesh out the terrain more, i.e. blend with other textures (A patch of grass that fades into the sand texture?), add supportive meshes (A cactus, a palm tree, a decrepit colonist cart partially devoured by the sand dune, and some ram skulls for good measure ;) ) 


Another one that can be used in conjunction with the previous solution is to use Google! no, haha sorry. But seriously, upon searching your issue in google I found something called Multi-UV mixing which appears to be the result of sampling your base texture with a replica texture at a larger resolution in your shader (I may have butchered that). The results based upon a few articles that I glanced over seem to be something worth looking into


(I'll include the link in the case I completely butchered the idea behind the technique)







#5281211 For beginners

Posted by markypooch on 14 March 2016 - 09:28 AM

The only pre-requisite for making games is to have the desire (Programming/Mathematics knowledge is a huge plus). There are plenty of tools out their that will accommodate peoples desires to make games without even a sliver of technical knowledge.


As far as APIs, it REALLY depends on the game your trying to make, the target audience, or if your doing it to amuse yourself. You can make a fun game with console graphics. In fact I remember back in middle school before I learned D3D coding an animated ascii game. In order to accomplish sprite animation I'd do things like this:


char  frOne[] = {' ',' ',' ',' ','*',' ',' ',' '};

char  frTwo[] = {' ',' ',' ',' ',' ','*',' ',' '}; //The asterisk is just moving to the right.


And I would use a simple timer to animate between these char arrays (though my renditions were much more complicated than a star). This produced a result than brought life to my console games.


If you want to make 3D games your best bet is either an engine/framework like Unreal/Unity, or DIY and learn Direct3D11, OpenGL 4.0 APIs (Though the latter APIs are known for their inherent difficulty to learn for beginners, and are not always user friendly, and this list is certainly not exhaustive).


Python is a great language to start out with (A wealth of information, and tutorials are online), it's simple yet powerful. Ambiguous, and extremely flexible. And right off the bat it forces you to indent your code (Which is something I've laughably seen "Advanced" developers overlook). But that's not in stone. There are other good "beginner" languages as well. I started with C, but there was no real reason behind that at the time. I guess I was under the assumption was that it was the only language out their at the time. haha, ignorance can be bliss. 


This page serves to get your IDE environment, and SDK installed.



This page will take you through the Basics.



Just remember games are games. Graphical finesse though important, is not the prime ingredient for making a fun game. A damn good idea implemented well IS however.



#5280699 D3D9 - Rendering image to texture problem

Posted by markypooch on 11 March 2016 - 08:10 AM

Welcome to the forums!


First off your not an idiot. A lot of us are still learning here. Though some may disagree; the simple fact that your programming implies that you are capable of logical deduction, and flow control which would imply that you have a high level thought process organically accelerated by a human brain, haha.


That being said the first thing I would check are your renderStates.


without making square for it, so the texture will be just the image?


That's a great question.Your referring to Vectorized graphics which is the use of polygons to represent images/textures in graphics. But, I feel if you check over your RenderStates, or your underlying texture itself you'll find that complete transparency with a image is completely possible, and that the use of vectorized graphics for this one case is a little overkill imho



#5238298 What is the easiest way to show effects(ice, fire, thunder, etc...) in direct...

Posted by markypooch on 03 July 2015 - 09:06 PM

It sounds as though you are using a method similar to that of one of the rastertek tutorials for fire. Having implmented it myself it produced an amicable result for a minimal amount of coding/effort.

However, you could try volumetric rendering with spherical billboards. The groundwork for the effect is layed out in ShaderX5, though im sure there is other relevant information to it in other publications.




#5233883 HLSL matrix initialization

Posted by markypooch on 09 June 2015 - 01:42 PM

Might be time for someone with more HLSL knowledge to step in but I think it pertains to how HLSL stores data internally. It stuffs everything into a four-component vector, if anything straddles the 16-byte boundary it is liable to be pushed into a adajcent vector in memory or truncated.



#5233864 HLSL matrix initialization

Posted by markypooch on 09 June 2015 - 12:47 PM

Hmmm, while I may be false in this assumption it looks like your values are indeed being read column major. I think by default HLSL is column-major. Compare/Contrast the values of your matrice to the debugger values (column wise) and you'll see whats going on. Each 4th component is being truncated (read column wise).  


Try using a float4x4 type for your tbn matrix and see if that works



#5233585 The most efficient way to create a const array in HLSL?

Posted by markypooch on 08 June 2015 - 12:43 PM


Put the static keyword in front. In this case, it should only be defined once right?


From my understanding it's the same as in c/c++. Its defined once, and maintains static duration during run-time.



There are const global variables in OpenGL is there such an alternative in D3D?

The equivalent to my knowledge is a ConstantBuffer in D3D (ShaderModel 4.0+). Even if your data is to be declared outside of a constant buffer it still gets tucked into a default constant buffer under the hood.


To clarify a ConstantBuffer is a buffer that is optimized for constant variable usage and enables the app developer to specify data that is constant for that pass through the shader. Those are your constant variables in HLSL.


As to your original question, I don't know if it's the best way to do it (I can't say one way over the other), I don't think the way your doing it now is very performance prohibitive. At most when the function is called it has to allocate 128 bytes in video memory for that array.



#5232995 Engine design, global interfaces

Posted by markypooch on 05 June 2015 - 01:03 PM

I think Josh articulated the big elephant in the room wonderfully. Singletons, and globals for that matter hide dependacies, couple code, and pave the way for poor design to go unnoticed.


However, I'm sure just like any tool, it has a purpose. But like a chainsaw it can be (and usually is) horribly misused.



#5226887 Dissidia

Posted by markypooch on 02 May 2015 - 05:22 PM


What is there to consider when First building a game as such? The stat? the goal? The features? 3d space maneuver?


These are mostly things you would have to guage on your own end. A tiny amount of programming exp.erience is an ambigous statement


The goals ideally are realistic, and are usually directly proportionally to the amount of time you and your team have to invest into the project. Does your team have financial backing for this project, do they have a job, or children? It might sound like a rather unrelated inquire but these things usually have a direct relation to the progression of the project and the projected goals you initally set.



Is it a necessity to create a new physics engine? 
If so, how should i start?


Not nesecarily, you could use a pre-made physics engine and depending on the time-frame you set for the project to be completed, might be a bit more advantegous to prevent scope creep. (Bullet-Engine, Havox are a few pre-made ones)



I hope this doesn't sound, or is actually not too ambitious


It sounds very ambitious, especially if your still learning how to code. But then again nothings impossible. Just remember even the more mundane 3D effects have a lot going on under the hood to produce the final result. The diffculity to reproduce thse effects are usually going to be exemplified exponentially by the less experince you have in programming and 3D application development.



#5194254 MAKE A CHOICE engines

Posted by markypooch on 23 November 2014 - 06:19 AM

I'll assume you have some programming background since your probing around for engines.



i need wich one that can render millions voxel-like objects with out any problems.


That's subjective and ultimately depends on the system that will be executing the build and the overall complexity of the App.


Several factors also weigh into your previous request


-lighting (will your minecraft clone have lighting? If so it adds another layer of calculations for each cube or mesh. (I think, could be mistaken though; MC utilized lightmaps as opposed to the per-vertex lighting available in Fixed Function GL))


-Run-time world-gen (will your world dynamically be generated as the program runs as mineCraft is?)


-Networking (I would say this is a must if you looking to make MineCraft clone)


And that's the VERY tip of the ice-berg. All of these things MineCraft has (In some form or another). Pinpoint your needs and your projected end-goal, and try choosing an egine based upon that