Jump to content

  • Log In with Google      Sign In   
  • Create Account


GuardianX

Member Since 28 Oct 2011
Offline Last Active Jul 02 2014 01:03 PM
*----

Topics I've Started

Can't understand camera behavior

13 July 2013 - 01:17 PM

Hello.

I'm quite new person in OpenGL graphics. Recently I started to learn OpenGL ES 2.0 technology to be able to make some games on my Android devices. I have a few questions to clear some things up for me.

 

1. Where can I find comprehensive OpenGL ES 2.0 tutorials, or book for making games on Android by means of Java/Android SDK, not C++/NDK? A lot of resources are dedicated to OpenGL ES 1.0 technology, not 2.0 one. In fact it's very hard to find complete tutorials for 2.0 with good non-contradictory code base.

 

2. Why there are almost no 2.0 tutorials? Is it any popular? Google says that devices starting from Android 2.2 can use this new version, so if no one uses it, why? At the first glance it gives more flexible way of doing things.

 

3. I'm a bit confused with the way matrix multiplication system works.

 

Do I have to use:

 

Matrix.setIdentityM( mModelMatrix, 0 );
Matrix.multiplyMM( mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0 );
Matrix.multiplyMM( mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0 );

To get simple mMVPMatrix = mModelMatrix * mMviewMatrix * mProjectionMatrix equation done? Can I use this result matrix as uniform variable in shader?

 
4. Is this the right code to rotate my object around Y axis by some angle 'mAngle':
 
Matrix.setRotateM( mRotationMatrix, 0, mAngle, 0.0f, -1.0f, 0.0f );
Matrix.setIdentityM( mModelMatrix, 0 );
Matrix.multiplyMM( mModelmatrix, 0, mRotationMatrix, 0, mModelMatrix, 0 );
Matrix.multiplyMM( mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0 );
Matrix.multiplyMM( mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0 );

To me it seems legit, but I get really weird results on my phone when I try to render simple textured box. Top, bottom sides of the box rotate around camera, not the opposite way.

 

This is my renderer and simple textured cube classes:

http://pastebin.com/Phd2ym3Z - renderer

http://pastebin.com/i9rb3r6v - textured cube

 

Thanks for your time!


Binding shader resources

12 April 2013 - 10:01 AM

Hello everyone.

 

Recently I have been lurking in DirectX 11 documentation and found interesting thing: PSSetShaderResources function keeps textures bound to graphics pipeline. So I have made up a common header for every shader program which looks like this:

 

// Defines:
// Object color type
#define OBJECT_COLOR_TYPE_COLORED 0
#define OBJECT_COLOR_TYPE_TEXTURED 1
#define USE_NORMAL_MAP 1
#define USE_SHADOW_MAP 1
#define USE_DIFFUSE_MAP 1
#define USE_AMBIENT_MAP 1
#define USE_LIGHT_MAP 1
// Textures:
Texture2D NormalMap : register(t0);
Texture2D ShadowMap : register(t1);
Texture2D DiffuseMap : register(t2);
Texture2D AmbientMap : register(t3);
Texture2D LightMap : register(t4);
// Sampler states:
SamplerState LinearSampler : register(s0);
 

 

Now, I'm trying to update textures per primitive draw call. In example, if the object uses different from previous drawn primitive diffuse color map, I call PSSetShaderResources(2, 1 , resources). Where `resources` is an array, containing single element - shader resource view for new diffuse map texture. But when I have implemented this in my engine, it doesn't render texture maps anymore. All of my shader programs are including this common file.
 
So I'm curious, does DX11 really keep those textures bound to pipeline until I free them? Or do their shader representations actually become undefined if I call PSSetShader() or change render target?

3D models animation

22 March 2013 - 11:31 AM

Hello guys.

 

It is strange, but I can not find any good tutorials about 3D model animation implementation in DirectX 10-11 and C++. I wonder how does animation data usually being stored in files, should I use dynamic vertex buffers or there are other widely used techinques out there? Could someone provide some indepth information on this subject?


Bitmap font engine problem

20 February 2013 - 09:34 AM

Hello.

 

I'm trying to create my own text-rendering engine based on Rastertek's tutorial. The steps I did to make it work:

 

1. Created my own .png file, containing common ASCII symbols divided by spaces. PNG file had not been compressed.

2. Successfully parsed PNG file so that each symbol has it's own texture coordinates and width/height in pixels. The height is the same for each letter and equals to texture height.

3. Created DDS file from PNG font file.

4. Loaded texture from DDS file.

5. Created squares for each letter according to their width/height in pixels and texture coordinates.

6. Created orthogonal projection matrix to project them on the screen within pixel shader without any changes.

 

Everything seems well, but the result looks bad:

Attached File  game.png   415.57KB   81 downloads

 

As you can see, the letters look dirty and unprecise. Thats how DDS file looks in DX texture tool for comparison:

Attached File  font_dds.png   34.61KB   78 downloads


DirectXMath vector operations precision

11 February 2013 - 07:21 AM

Hello.

 

I'm having strange results of XMVector3AngleBetweenVectors function. Consider this code:

 

float angle = XMConvertToDegrees(XMVectorGetX(
        XMVector3AngleBetweenVectors(GMathFV(XMFLOAT3(0.0f, 100.0f, 0.0f)), 
        GMathFV(XMFLOAT3(0.0f, 200.0f, 0.0f)))));
 

 

It's looking for angle between two 3D vectors, described by XMFLOAT3 structures. GMathFV is user-defined function which converts XMFLOAT3 to XMVECTOR as follows:

 

inline XMVECTOR GMathFV(XMFLOAT3& val)
{
    return XMLoadFloat3(&val);    
}
 

 

Everything else is directxmath.h library. Here everything is fine and result angle is 0.00000 just as expected.

 

But for other vectors with negative y-axis value, for example:

 

float angle = XMConvertToDegrees(XMVectorGetX(
        XMVector3AngleBetweenVectors(GMathFV(XMFLOAT3(0.0f, -100.0f, 0.0f)), 
        GMathFV(XMFLOAT3(0.0f, -99.0f, 0.0f)))));
 

 

Result is 0.0197823402, which I can hardly call a zero angle.

 

Please someone help me figure out the problem. Is it negative number precision, too close vector coordinates or maybe something else?

 

UPD: It's very strange, because it gives 0.0197823402 for a(0.0f, 100.0f, 0.0f) x b(0.0f, 99.0f, 0.0f), but 0.000000 for a(0.0f, 101.0f, 0.0f) x b(0.0f, 100.0f, 0.0f)


PARTNERS