Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Hawkblood

Member Since 21 Jan 2013
Offline Last Active Nov 29 2014 10:29 PM

#5156983 Why does game GUI have to be rectangles?

Posted by Hawkblood on 30 May 2014 - 10:27 AM

Locking even a single bitmap each frame can cost you precious ticks. Your button will be an image of the button with transparency values. Lock it once when you load it, check the alpha of each pixil, and set an array of bytes (same diminsions as the image) to either 0 or 1, then use that array as a check for "is it on the button"......


#5151006 Planet sized terrain method

Posted by Hawkblood on 02 May 2014 - 04:31 PM

I am wanting to generate a planet's terrain. I want the detail to increase as the viewer approaches the surface. Here is a video showing it in action: (this is not mine, it's just an example)

The rough idea is to have 6 surfaces (cube faces) that will be "spherefied" once the detail level and the height map is applied. This will make a planet-shaped mesh with a rough surface. Each of the face of the cube is a separate quadtree object that uses the "distance" from the center (camera) to determine what detail level each chunk of the quadtree is at.

This works fine on approach, but I have a maximum level of detail that I can't get past. I'm using Perlin noise to generate the surface features, but it seems very plain until I get around 10 levels of detail. At 10 and higher, the noise starts to become lines like rows of plants in a garden. Here is an image:
Untitled.png

I'm really not sure where to start to correct this. I think there is a limitation to Perlin noise that is causing this. It may be the use of floats causing this or it could be the sample size..... Don't know.

If this limitation exists, I think I might have to come up with a way to generate greater detail using a trick I've been thinking about.....

I don't want to waste too much time on this because I want to get back to the meat of my game. I put this part of it off as long as I can...




#5149227 DX11 Hardware Voxel Terrain (your opinion)

Posted by Hawkblood on 24 April 2014 - 03:41 PM

Wow. What a mess of a file. When I clicked the link for the "lookup tables" it came out as a hot mess. Here is a more coherent format:TransVoxel.txt

 

EDIT: I originally placed it in a code fragment, but the page takes forever to load that way. So I uploaded it as a .txt file.

 

[Mod edit] The copyright holder of that file just asked for us to remove it, saying you don't have permission to be redistrubuting it




#5148376 DX11 instancing. Help.

Posted by Hawkblood on 20 April 2014 - 11:08 AM

As it happens (and it happens more than I would like), I posted something JUST BEFORE the solution presented itself.

 

The SemanticIndex for the second instanced description should have been set to 2.......




#5146609 Tips for Programming a GUI

Posted by Hawkblood on 12 April 2014 - 06:56 PM

I've made a few GUIs before. It can get tricky and time consuming. Break down the GUI into the simplest components you need to accommodate your program.

-button

-list

-textbox

-dropdown

-tabmenu

 

These are the basic ones I use. I also have "menu groups" which are like their own window and contain the menu items listed above (as needed). Each of these items you need to be able to reference in your program so that they can "do something".

 

If it's at all possible, you should try to find a third party GUI. If you are set on doing it yourself, I can help you if you want.




#5146569 DX11 HLSL help, please.

Posted by Hawkblood on 12 April 2014 - 02:33 PM

I finally figured out the specular problem. Here is the shader:

vs:

/////////////
// GLOBALS //
/////////////
cbuffer MatrixBuffer
{
    matrix worldMatrix;
    matrix viewMatrix;
    matrix projectionMatrix;
};


//////////////
// TYPEDEFS //
//////////////
struct VertexInputType
{
    float4 position : POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
    float3 tangent : TANGENT;
    float3 binormal : BINORMAL;
};

struct PixelInputType
{
    float4 position : SV_POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
    float3 tangent : TANGENT;
    float3 binormal : BINORMAL;
	float3 worldPos : TEXCOORD1;
	float3 cdir : TEXCOORD2;
};


////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType BumpMapVertexShader(VertexInputType input)
{
    PixelInputType output;
    

    // Change the position vector to be 4 units for proper matrix calculations.
    input.position.w = 1.0f;

    // Calculate the position of the vertex against the world, view, and projection matrices.
    output.position = mul(input.position, worldMatrix);
	output.worldPos=output.position;
    output.position = mul(output.position, viewMatrix);
    output.position = mul(output.position, projectionMatrix);
    
    // Store the texture coordinates for the pixel shader.
    output.tex = input.tex;
    
    // Calculate the normal vector against the world matrix only and then normalize the final value.
    output.normal = mul(input.normal, (float3x3)worldMatrix);
    output.normal = normalize(output.normal);


    // Calculate the tangent vector against the world matrix only and then normalize the final value.
    output.tangent = mul(input.tangent, (float3x3)worldMatrix);
    output.tangent = normalize(output.tangent);

    // Calculate the binormal vector against the world matrix only and then normalize the final value.
    output.binormal = mul(input.binormal, (float3x3)worldMatrix);
    output.binormal = normalize(output.binormal);

	output.cdir=normalize(-output.worldPos);

    return output;
}


ps:

/////////////
// GLOBALS //
/////////////


Texture2D shaderTextures[2];
SamplerState SampleType;


cbuffer LightBuffer
{
	float4 Ambient;
	float4 NumberOfLights;
	float4 PLPos[8];
	float4 PLColor[8];
	float4 PLRange[8];
	float4 DLightColor;
	float4 DLightDir;
	float4 SLPos[8];
	float4 SLDir[8];
	float4 SLColor[8];
	float4 SLData[8];//icone==.x, ocone==.y, range==.z
};


//////////////
// TYPEDEFS //
//////////////
struct PixelInputType
{
    float4 position : SV_POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
    float3 tangent : TANGENT;
    float3 binormal : BINORMAL;
	float3 worldPos : TEXCOORD1;
	float3 cdir : TEXCOORD2;
};

////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 BumpMapPixelShader(PixelInputType input) : SV_TARGET
{
    float4 textureColor;
    float4 bumpMap;
    float3 bumpNormal;
    float3 lightDir;
    float4 color=float4(0,0,0,0);
	float3 viewDirection;

    // Sample the texture pixel at this location.
    textureColor = shaderTextures[0].Sample(SampleType, input.tex);
	
    // Sample the pixel in the bump map.
    bumpMap = shaderTextures[1].Sample(SampleType, input.tex);

    // Expand the range of the normal value from (0, +1) to (-1, +1).
    bumpMap = (bumpMap * 2.0f) - 1.0f;

    // Calculate the normal from the data in the bump map.
    bumpNormal = (bumpMap.x * input.tangent) + (bumpMap.y * input.binormal) + (bumpMap.z * input.normal);
    // Normalize the resulting bump normal.
    bumpNormal = normalize(bumpNormal);


	float3 h,l;
	float nDotH,nDotL,power;
	{[branch]
		if (NumberOfLights.x>0){//directional

			l=-DLightDir.xyz;
			nDotL = saturate(dot(bumpNormal, l));
			h = normalize(l + input.cdir);
        
			nDotH = saturate(dot(bumpNormal, h));
			power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, 256.0f);
        
			color += DLightColor*(nDotL+power);

		}
	}
	{[loop]
		for (int i=0;i<NumberOfLights.y;i++){//point lights

			l=PLPos[i].xyz-input.worldPos;//use this for distance calc
			{[branch]
				if (length(l)<PLRange[i].x*1.25f){
					lightDir=l/PLRange[i].x;
					l=normalize(l);
					float atten=saturate(1.0f-dot(lightDir,lightDir));

					h = normalize(l+input.cdir);
					nDotL = saturate(dot(bumpNormal, l));
					nDotH = saturate(dot(bumpNormal, h));
					power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, 16.0f);
					color += (PLColor[i]*(nDotL+power)) * atten;
				}
			}
		}
	}
	{[loop]
		for (int i=0;i<NumberOfLights.z;i++){//spot lights
			l = (SLPos[i].xyz - input.worldPos);
			{[branch]
				if (length(l)<SLData[i].z*1.25f){
					l /= SLData[i].z;
					float atten = saturate(1.0f - dot(l, l));
					l = normalize(l);
					float2 cosAngles = cos(float2(SLData[i].y, SLData[i].x) * 0.5f);
					float3 dl=SLDir[i];//SLDir[i] should ALWAYS be normalized on input
					float spotDot = dot(-l, dl);
					float spotEffect = smoothstep(cosAngles[0], cosAngles[1], spotDot);
    
					atten *= spotEffect;

					h = normalize(l + input.cdir);
        
					nDotL = saturate(dot(bumpNormal, l));

					nDotH = saturate(dot(bumpNormal, h));
					power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, 256.0f);
        
					color += (SLColor[i]*(nDotL+power)) * atten;
				}
			}
		}
	}
    // Combine the final bump light color and ambient with the texture color.
    color = saturate(color+Ambient) * textureColor;

	
    return color;
}


The specular power is hard coded but it should be done as an input variable...... That shouldn't be a problem.




#5144713 Linear Velocity and Angular Velocity Point of Intersection

Posted by Hawkblood on 06 April 2014 - 07:36 AM

Give me a visual..... From your post, I am envisioning some object floating in space at a set velocity with a laser attached to it and you want to see if the laser is intersecting a plane?????

 

Or are you talking more like a rocket without guidance? Where the rocket spirals uncontrollably and you want to know if it hits a plane?????

 

Looking at the article, I'm wondering how detailed you want this collision detection? It also looks like it's describing 2D.




#5142732 Recomend some open source games archieved with directx11

Posted by Hawkblood on 27 March 2014 - 07:05 PM

No, I finished my DX9 game. I'm following : http://rastertek.com/tutdx11.html to get a handle on DX11.




#5142297 #ifndef not working

Posted by Hawkblood on 26 March 2014 - 08:15 AM

I thank you both for your help.


#5141719 #ifndef not working

Posted by Hawkblood on 24 March 2014 - 10:04 AM


I'd second Buckeye's suggestion to remove all references to your functions and headers from stdafx.h. Unless you really know what you're doing, it is probably best to reserve stdafx.h for referencing external headers (like Windows.h) that really are used everywhere. In fact, it might be best to leave stdafx.h empty for the time being until you've figured out this problem first.

The problem with doing that is I have dependencies that require a certain order of "inclusion". I can't depend on the compiler to look through the header files in the right order.

 


Please post the revised code

I have a lot of code to look at now. I could post it if you think it will help, but here is the gist of what I have done:

--I have a header file for each .cpp file

--Each header file is "#included" is the stdafx.h file (in the order I need them)

--Each header file has:

     #ifndef (header name in all caps such as GLOBALS_H)

     #define (header name in all caps such as GLOBALS_H)

     ..... all the stuff needed in the header file.......

     #endif

--Each .cpp file "#includes" the stdafx.h file

--stdafx.h has the same #ifndef / #define / #endif stuff as all the other headers

 

Here is the errors I'm getting when I do this:

Error	1	error LNK2005: "float SCREEN_WIDTH" (?SCREEN_WIDTH@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\Grapgics.obj	Empty DX11 Project1
Error	2	error LNK2005: "float SCREEN_HEIGHT" (?SCREEN_HEIGHT@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\Grapgics.obj	Empty DX11 Project1
Error	3	error LNK2005: "struct GRAPHICS Graphics" (?Graphics@@3UGRAPHICS@@A) already defined in globals.obj	C:\Empty DX11 Project1\Grapgics.obj	Empty DX11 Project1
Error	4	error LNK2005: "float SCREEN_WIDTH" (?SCREEN_WIDTH@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\LargeMath.obj	Empty DX11 Project1
Error	5	error LNK2005: "float SCREEN_HEIGHT" (?SCREEN_HEIGHT@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\LargeMath.obj	Empty DX11 Project1
Error	6	error LNK2005: "struct GRAPHICS Graphics" (?Graphics@@3UGRAPHICS@@A) already defined in globals.obj	C:\Empty DX11 Project1\LargeMath.obj	Empty DX11 Project1
Error	7	error LNK2005: "float SCREEN_WIDTH" (?SCREEN_WIDTH@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\main.obj	Empty DX11 Project1
Error	8	error LNK2005: "float SCREEN_HEIGHT" (?SCREEN_HEIGHT@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\main.obj	Empty DX11 Project1
Error	9	error LNK2005: "struct GRAPHICS Graphics" (?Graphics@@3UGRAPHICS@@A) already defined in globals.obj	C:\Empty DX11 Project1\main.obj	Empty DX11 Project1
Error	10	error LNK2005: "float SCREEN_WIDTH" (?SCREEN_WIDTH@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\MeshObject.obj	Empty DX11 Project1
Error	11	error LNK2005: "float SCREEN_HEIGHT" (?SCREEN_HEIGHT@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\MeshObject.obj	Empty DX11 Project1
Error	12	error LNK2005: "struct GRAPHICS Graphics" (?Graphics@@3UGRAPHICS@@A) already defined in globals.obj	C:\Empty DX11 Project1\MeshObject.obj	Empty DX11 Project1
Error	13	error LNK2005: "float SCREEN_WIDTH" (?SCREEN_WIDTH@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\Text.obj	Empty DX11 Project1
Error	14	error LNK2005: "float SCREEN_HEIGHT" (?SCREEN_HEIGHT@@3MA) already defined in globals.obj	C:\Empty DX11 Project1\Text.obj	Empty DX11 Project1
Error	15	error LNK2005: "struct GRAPHICS Graphics" (?Graphics@@3UGRAPHICS@@A) already defined in globals.obj	C:\Empty DX11 Project1\Text.obj	Empty DX11 Project1
Error	16	error LNK1169: one or more multiply defined symbols found	C:\Empty DX11 Project1\Release\DX11Test.exe	1	1	Empty DX11 Project1
	17	IntelliSense: command-line error: invalid macro definition: /MDd	c:\Empty DX11 Project1\Text.cpp	1	1	Empty DX11 Project1

The /MDd error only shows up when the other errors do. When I change it to the way I *was* doing it, that error doesn't occur.....




#5137153 Reversing a procedural generation

Posted by Hawkblood on 07 March 2014 - 11:12 AM


At this point it's probably obvious - there is no encoding that will work like you want it to

That's correct.....

 

To everyone: I've moved away from the idea of using a seed as a save state.

 

Perhaps I should start a new post on saving the state of a galactic sized game.....

Any ideas on minimizing the save game size for really huge games?




#5137028 Reversing a procedural generation

Posted by Hawkblood on 06 March 2014 - 06:25 PM

This is a SUPER SIMPLE random number generator:

int RNSeed=12345;
int randomnum(void){
	RNSeed=abs(RNSeed*8786545643)%987654321;
	return RNSeed;
}

With this initial seed, the first time it's called it results in 770159010, and the second time it results in 808599291.

This will happen EVERY time I start with 12345. The problem with reversing the calculation is the modulus of 987654321. Any seed value greater than that number will be some value that can't be found and therefore the previous seed us unknown. The solution would involve a random number generator that can be reversed-- I don't know how to make that (or if it can be made at all).

 

All of you are either think I don't know how random generators work or you are missing my point entirely.




#5134827 Making basic games yourself with C++

Posted by Hawkblood on 26 February 2014 - 01:41 PM

It was just a suggestion.... If you are already using python, then you should stick with it at least for a while. Start programming and when you get to a point you don't understand, post the problem and I (or someone) can help you.


#5134607 Voxel terrain move

Posted by Hawkblood on 25 February 2014 - 07:20 PM


(I presume blocks 16x16x16 are local size, which scales up with lower-res lod right?)

The idea behind octtree/quadtree is to have a varied size (scale) not vary the number of vertices. For instance, up close the 16x16x16 could represent a block that is 16meterX16metersX16meters in size and a lower level of detail the same 16x16x16 would represent a larger area like 32metersX32metersX32meters-- this is double the size in each direction. For a map (terrain) the expansion of the vertical axis wouldn't be needed as much as the horizontal axis' unless you have a volumetric approach to your terrain where even the empty areas of the sky are represented.....

 

The "geometry clipmaps" is not voxel, or do you mean to modify it into something "voxel"?




#5134602 Making basic games yourself with C++

Posted by Hawkblood on 25 February 2014 - 06:59 PM

If you are looking to make a game with something more simple than C++, then have a look at DarkBasic:

http://forum.thegamecreators.com/?m=forum_read&i=1

 

It's basically happy.png  a basic engine that can be almost as powerful as a C++ designed game. It uses DirectX9.0c and is fairly simple to use.

 

Here is a link to a forum post of mine that illustrates the first game I made using DarkBasic:

http://forum.thegamecreators.com/?m=forum_view&t=166885&b=5

The actual game is VERY simple. It's a 2.5D game that uses lights, normal mapping (.fx), and sounds. You can even download the game (use the [download] button on the right of the SECOND post). Here is a quick video also:






PARTNERS