Jump to content

  • Log In with Google      Sign In   
  • Create Account

BrentChua

Member Since 05 Jul 2011
Offline Last Active Feb 04 2014 08:01 AM

#5127381 Sharing my 2D platformer demo

Posted by BrentChua on 29 January 2014 - 11:38 PM

Hi Guys,

 

Just wanted to share a little demo i made for a game programming class i teach in my local university. The class is about exploring game systems and architectures used in developing (2D) games.

 

I was nearing the end of the course's lecture and i felt a sudden urge to create a concrete example tying all the systems we have covered so far. This way the students will have a better understanding on how these systems interact with one another to form a whole game. Its not much but i think its enough to show its functionality and get their creativity flowing for their game project. 

 

Source and executable is included in the download link below. This was a quick and dirty implementation of the demo so i'm sure there's a ton of bugs and some poor OOP designs and gameplay code but this was just a demo i came up for 2 nights(mostly trying to get the basic collision/physics system to work). I'd like to continue working on this some more but that's the only time i've got. 

 

Enjoy!

 

Screenshot: 

platformer screen 2.jpg platformer screen.jpg Platformer screen 3.jpg

 

Link: https://mega.co.nz/#!ClgDQQLB!liGauqpSWu2QjTgRcPf2z1_c17a4wumVk0r06DTMo0A




#5090000 Updating constant buffers?

Posted by BrentChua on 28 August 2013 - 10:52 PM

If you're using the same constant buffer then you don't need to keep on re-binding them after the first bind every time you update the constant buffer since its already bound in the pipeline.




#5089839 A proper way for help screen?

Posted by BrentChua on 28 August 2013 - 08:51 AM

i forgot the word anchor so i used the word position locking instead but thanks for bringing that correct word up.




#5089824 A proper way for help screen?

Posted by BrentChua on 28 August 2013 - 08:06 AM

In addition to these UI scene data as what NightCreature83 said. The nodes representing a UI element may have other attributes associated to it. Like position locking and position ratios relative to the screen. This can be useful especially if your game runs on different screen sizes as they can just automatically adjust based on these attributes than having an absolute position values.




#5089803 How to develop a very basic game? I don't have any programming knowledge...

Posted by BrentChua on 28 August 2013 - 06:40 AM

How is this brilliant Jimstyle guy getting a negative rep? he's just asking honest questions.




#5089228 DX11 - Sending Textures

Posted by BrentChua on 26 August 2013 - 11:43 AM

I've read somewhere in this forum that constantly binding the texture every frame even if it doesn't change takes some performance hit i think.

 

In Jason Zink's graphics engine, his graphics pipeline layer has a state monitoring system that defers the actual binding of GPU resources until the time that's actually needed. The graphics pipeline layer allows the cpu code to bind and change as many resources as it wants in the current frame through caching the resources to be bound then evaluating it when its time to draw the mesh. Once the cpu calls DrawIndexed, the state monitoring system checks the cpu bounded resource and the actual resource that is currently bound in the gpu; It only binds the resource to the GPU if the state monitor detects different cached and GPU bound resources and binds those cached resources.




#5086402 Buffer<uint> reading wrong values

Posted by BrentChua on 16 August 2013 - 12:08 AM

That would definitely help me a lot; I'll include it in my code. I actually have the Real-Time Rendering Book. I've only read the first few chapters before i laid it off because of work and just totally forgot to get back reading into it. Thanks again for all your help. I really appreciate it.




#5086256 Buffer<uint> reading wrong values

Posted by BrentChua on 15 August 2013 - 03:24 PM

Also, prior to the new lighting equation, the phong lighting model was a lot brighter. Now it looks very dark! lol

Attached Thumbnails

  • forward+.jpg



#5086249 Buffer<uint> reading wrong values

Posted by BrentChua on 15 August 2013 - 03:17 PM

sigh... it would have saved me a lot of time if I simply looked at my output window. It turned out i wasn't clearing the bound UAV so when i render the geometry, DX was forcing the SRV to null. Thanks for your amazing help to the community, MJP!

 

Also if you don't mind me asking, i just pretty much copy-pasted the entire lighting equation and i simply don't have any idea on how do some parts of these equation work. I'm guessing that this is a part of the Physically Based BRDFs thing? I've been meaning to learn more about Physically Based Rendering but most of the resources ive seen seem to assume that you already have prior knowledge about these stuff already which just confuses me more. I was wondering if you could provide maybe some articles or a book i could read that talks more in-depth about these topics?




#5086233 Buffer<uint> reading wrong values

Posted by BrentChua on 15 August 2013 - 02:35 PM

I'm currently trying to get a basic Forward+ renderer working. I've managed to get the first two steps which is the z-prepass, and the lighting stage working. In the lighting stage i have an RWBuffer<uint> that has the format of R8_UINT that stores the tile light indices. That R8_UINT buffer is then passed on to the forward shading stage as an Buffer<uint>. My problem is that when it reads the value of the Buffer<uint>, it always returns 0 even if the buffer contains a different value.

 

I have verified that i am binding the buffer correctly and its value after the lighting stage(compute shader) through the VS Graphics Debugger. Currently, i'm setting my scene so that there are no lights and the light indices buffer are all filled with the max lights value of 256. When it gets to my forward shader though, when it reads the light indices buffer it is always 0. I have checked the buffer bound to my light indices buffer and the xbyte values are all 0xff which should give me 255(uint) but all i get when i read the buffer are all 0. Do i need to do something with the buffer after the compute shader but just before it gets to my forward shader?

 

My implementation is an adoption from MJP's IndexedDeferred demo.




#5085858 How does a “Build” button in game engine editor window works?

Posted by BrentChua on 14 August 2013 - 10:43 AM


How these executables access those assets and scripts if they are packed into single archive?

 

Hi zgintasz. Will you be making a resource packer using c/c++ or a different language? I wrote a step-by-step article on a virtual file system many years ago. It more describes my (old) implementation in detail than a general literature on virtual file systems but it handles packing of resources, unpacking, and individual file access with compression. 

 

http://mrcodesushi.wordpress.com/?s=virtual+file+system

 

The provided source code in those articles are now gone since i moved to a new repo. The new Virtual File System can be located here:

https://pulsetec.codeplex.com/SourceControl/latest#Source/Pulse-Tec/Include/FileSystem.h

https://pulsetec.codeplex.com/SourceControl/latest#Source/Pulse-Tec/Source/FileSystem.cpp

https://pulsetec.codeplex.com/SourceControl/latest#Source/Pulse-Tec/Include/ResourceFile.h

https://pulsetec.codeplex.com/SourceControl/latest#Source/Pulse-Tec/Source/ResourceFile.cpp

 

I did a very terrible job writing this article as it was just more of a developer journal for me to write stuff out in my mind but if this helps you even in littlest way, i'm glad that it did. 




#5082407 Launching a Direct3D window from a win32 dialog box

Posted by BrentChua on 02 August 2013 - 12:43 AM

The MainDlgProc that you pass in is your defined function right? You should be able to catch the message that Jason Z is talking there.




#5082206 Weird Specular Light

Posted by BrentChua on 01 August 2013 - 08:49 AM

specPower = pow( max( dot( reflectionVec, toEye ), 0.0f ), materialPower );

 

where:

reflectionVec = lightDirection -  (2 * surfaceNormal * dot( lightDirection, surfaceNormal )) // Use reflect( lightDirection, surfaceNormal )

toEye = cameraPos - IN.worldPos // your viewDir

 

 

You dot your viewDir to your reflectionVec not your halfVector.




#5081464 Pixel Shader never gets called, but is set?

Posted by BrentChua on 29 July 2013 - 09:05 AM

Is VertexOut the data you're returning in your vertex shader? If you're passing in the projected vertices i think you need to set the semantic for your pos as SV_Position(or SV_POSITION?); not just POSITION.  Oops unbird already said this...

 

As an addition though... if the clip space vertices are also not in the viewport, your pixel shader won't get called too. So once you've get the semantics fixed and your pixel shader still isn't running, double check your view proj matrices and make sure you're passing these matrices to your shaders. Or just hard code the clip space values and pass these to your pixel shader.




#5080800 object flickering

Posted by BrentChua on 26 July 2013 - 12:28 PM



D3D10_MAP_WRITE_DISCARD

 


D3D10_MAP_WRITE_DISCARD

Resource is mapped for writing; the previous contents of the resource will be undefined. The resource must have been created with write access (see D3D10_CPU_ACCESS_WRITE).

 

You either want to use D3D10_MAP_READ_WRITE (remember that reading from GPU memory is SLOW) or re-generate the vertices from scratch.

Oh wow totally missed that. mdias is right. The data in your Vertex* v is undefined. Your code v[i].pos+displacement adds a value to v[i] which is undefined. You should have the position value, along with the rest of the data in your vertex buffer, saved in system memory then use those values to assign it to v[].

 

So it should look something like this:

// This is stored somewhere in system memory
VertexData m_vertices;

Vertex* v = 0;
mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v );
 
for(int i = 0;i < mNumVertices;i++)
{
   // Update position
   m_vertices[i].pos += displacement;

   // Replace new data
   v[i].pos = m_vertices[i].pos;
   // Also replace the rest of the attributes as well.. (color, normal, texCoord, etc...)
}

The reason why its probably flickering is that the api will give you a system memory with the values you initially assigned to the vb in one frame then the next frame the api will give you a totally different system memory with garbage values (resulting in a position with crazy values off the screen).

 

Thanks for the heads up mdias!






PARTNERS