Jump to content

  • Log In with Google      Sign In   
  • Create Account

SIC Games

Member Since 22 Jun 2012
Offline Last Active Oct 03 2014 09:17 AM

#5168561 Create Vertex Shader from compiled file

Posted by SIC Games on 22 July 2014 - 09:45 PM

I had to re-read  your post carefully. What I believe you would have to do is to read the HLSL Binary like you do with binary files. then use the function D3DX10CompileFromMemory - there's possibly some interesting tutorials. I'll need to convert my shaders into binary to protect my game so modders won't get funny with it. If you're looking into how you would actually read a whole binary file - you would have to get the full size of the file and create a pointer with that size.

char *data;
unsigned long fileSz; 

std::ifstream input("myshaderbinary.hlsl", std::ios_base::binary);
if(input) { //-- make sure it's opened first.
        input.seekg(0, std::ios_base::end);
        fileSz = input.tellg(); //-- Get the file size.
        input.seekg(0,std::ios_base::beg); //-- rewind to beginning of file.

        if(fileSz > 0)  {  //-- just making sure there's over zero.
        data = new char[fileSz]; //-- Allocate enough storage to stuff the data.
        input.read(data, 0, sizeof(char) * fileSz);
         }
}

//-- Now we can continue to use D3DX10CompileFromMemoryA function. 

The D3DX10CompileFromMemoryA reads ascii such as char or const char. it won't read const wchar_t * or wchar_t* or LPCWSTR which is shortened for const wchar_t*. The D3DX10CompileFromMemory will read the LPCWSTR, wchar_t * and const wchar_t*.

 

I'm sure there's some examples are here or on google but because I haven't read any shader files in binary yet - I believe this is the approach you'll have to take. Anyone that would like to point out a more effective way then you'll most likely benefit from them. I'm not too sure yet.  Just remembered how I loaded my video textures with D3DX11LoadShaderResourceFromMemoryA bit.

 the input.read is incorrect. it should be input.read(data, sizeof(char) *  fileSz);




#5168560 Create Vertex Shader from compiled file

Posted by SIC Games on 22 July 2014 - 09:43 PM

I had to re-read  your post carefully. What I believe you would have to do is to read the HLSL Binary like you do with binary files. then use the function D3DX10CompileFromMemory - there's possibly some interesting tutorials. I'll need to convert my shaders into binary to protect my game so modders won't get funny with it. If you're looking into how you would actually read a whole binary file - you would have to get the full size of the file and create a pointer with that size.

char *data;
unsigned long fileSz; 

std::ifstream input("myshaderbinary.hlsl", std::ios_base::binary);
if(input) { //-- make sure it's opened first.
        input.seekg(0, std::ios_base::end);
        fileSz = input.tellg(); //-- Get the file size.
        input.seekg(0,std::ios_base::beg); //-- rewind to beginning of file.

        if(fileSz > 0)  {  //-- just making sure there's over zero.
        data = new char[fileSz]; //-- Allocate enough storage to stuff the data.
        input.read(data, 0, sizeof(char) * fileSz);
         }
}

//-- Now we can continue to use D3DX10CompileFromMemoryA function. 

The D3DX10CompileFromMemoryA reads ascii such as char or const char. it won't read const wchar_t * or wchar_t* or LPCWSTR which is shortened for const wchar_t*. The D3DX10CompileFromMemory will read the LPCWSTR, wchar_t * and const wchar_t*.

 

I'm sure there's some examples are here or on google but because I haven't read any shader files in binary yet - I believe this is the approach you'll have to take. Anyone that would like to point out a more effective way then you'll most likely benefit from them. I'm not too sure yet.  Just remembered how I loaded my video textures with D3DX11LoadShaderResourceFromMemoryA bit.




#5165902 Specular Mapping in Deferred Rendering

Posted by SIC Games on 09 July 2014 - 04:28 PM

So, I realized my problem was the lack of understanding how deferred shading differs from forward pass rendering. Putting tangent data in a deferred engine wouldn't make sense where I can encode and decode the tangent and biTangent from the normal map already. That's what the spheremap exactly does. The math is confusing because I'm not a mathician and I hate math. I tried to break it down as much possibly why in the world it works the way it works. I believe it takes the colors from the normal map and translate it to object or world space.

 

In forward pass rendering where it calculates the light and the geometry data each draw call - that's what got me confused; What really confused me was the whole topic of this thread was about transforming tangent space into world or view space (object space) before rendering it out to the render target. Last night I've became frustrated on thinking how do you transform tangent space into view space. Transpose(TNB) gave me a closer idea what was going on. I stumbled upon this deferred shading demo that I downloaded and it had spherical normal mapping (spheremap). I plugged it in my gbuffer shader - now I can safely say it works. I looked at the code where the encoding and decoding parts to figure out how does it work. I suck at math but my guess is that it essentially transforms the normal map data into object space or view space.

 

Tangent normal maps look different than object space normal maps - thus giving them the effect of depth when lit.

 

So back to your question Phil - now does the specular lighting change when I"m in relation to the light? The light is at (0,-1,-1) inverted (0,1,1) When the light intensity is above 0.0 by the dot product ot the normal map and the light position then the reflection of the specular if full when I'm facing the object at 0,1,1 but dims when I'm viewing at position -5,1,1.

 

It doesn't pop back in nor pop back out like it use to - so I can safely say everything's in running condition. It wasn't just me that was confused about the difference of rendering normal mapping in deferred shading - a lot of people was unsure also.

 

So that's all for now. Thanks Julien and everyone who contributed to this thread. Also thanks for Phil for pushing me in the right direction.




#5155772 DirectSound or XAudio2

Posted by SIC Games on 24 May 2014 - 08:10 PM

FMOD was really easy to implemend! I love it! Great suggestion Cozzie!




#5149748 how draw multiple objects in DirectX 11

Posted by SIC Games on 26 April 2014 - 07:06 PM

A way to do what I think you're doing is -  you want to load multiple meshes that are different? So for example: bigBird.obj and Kermit.obj? You're able to load which is good. Now the OBJ parse loads all the vertex information and the indice data dn places them inside your struct, right? For instance:

struct MeshVertexData {
XMFLOAT3 position;
XMFLOAT2 textureCoords;
XMFLOAT3 Normals;
};

If this is the case then what you could do is stuff the important information that is required for rending: IndiceBuffer, VertexBuffer, PixelShader, VertexShaders, InputLayouts including the vertexData structure you hold the information about the OBJ file. Anything that's important in one different structure; including a texture resource. For an example:

struct MySpecialModels {

MeshVertexData *meshData;
ID3D11Buffer *VertexBuffer, *IndiceBuffer;
ID3D11PixelShader *pixelShader;
ID3D11VertexShader *vertexShader;
ID3D11InputLayout *inputLayout;
XMMATRIX WorldMatrix, TransformMatrix,ScaleMatrix,RotationMatrix;
ID3D11ShaderResourceVIew *textureResource;

};

That's the important information about your mesh. When you parse your OBJ; you fill out your SpecialMeshStruct - once you filled the entire structure up then you have to put it inside a list or a vector or whatever stl collector.

 

My custom mesh structure goes inside a vector.

#include <vector>

std::vector<MySpecialMeshStruct> meshCollections;

So after you're done filling up your structure like I said before you have to place them inside the vector by declairing. meshCollections.push_back(myspecialStructureThatBeenFilled);

 

The "mysecialStructureThatBeenFilled" is just a temporary structure to fill up the mesh collection list.

 

When you are about to render you can ilerate through the mesh collection list by calling AND after you cleared the render target and depth stencil view.. I'm not sure if this is overwhelming you or not.  But you should get the basic gist of how to render multiple meshes at once. 




#5148786 Why DX 11 Geometry Shader isn't rendering anything out?

Posted by SIC Games on 22 April 2014 - 12:14 PM

Okay, now I can scream and bang my head against the wall. Thank you again Julien, you were right on the money! It was the issue with input.worldpos + float3() section. I gave you thumbs up and I wish I can give again but thanks!




#4989129 string::size_type

Posted by SIC Games on 11 October 2012 - 09:27 AM

I have been wrong too; it is all about how you handle it.
http://www.gamedev.n...67#entry4965067

People don’t lose respect for you for being wrong. They lose respect for you for handling it poorly.


L. Spiro


True. I probably woke up on the wrong side of the bed today. You're right bro, if a game critic gave me poor game review - probably would aggravate me. So, yeah - I agree I have to react more proactive and professional about. I also have to realize critizism comes in a helping manner and less of a attack. I was being defensive and that's not good demonstration for others to see on this forum. Professionalism is the way to lead people in the right direction. Which, again I have to work upon if I am ever going to be taken seriously. So, yeah I agree with the quote above.


#4989123 string::size_type

Posted by SIC Games on 11 October 2012 - 09:13 AM


sizeof returns the length in bytes of a char. - whether it be a array or what not. Whatever - I was trying to help out; screw that idea.

You are, unfortunately, blatantly wrong on this count.

sizeof() returns the correct size for the given type, or the correct length of a statically allocated array. std::string uses dynamically allocated memory to store the string contents, so sizeof() will not see that memory.

#include <string>
#include <cassert>
int main() {
	std::string A = "Hello, World!";
	std::string B = "Hi";

	assert( sizeof(A) == sizeof(B) );
}


Yeah you too have a good day, keep on warning people; bro! Cause you're cool like that.


#4989122 string::size_type

Posted by SIC Games on 11 October 2012 - 09:12 AM


there is size_t; and plus sizeof() returns bytes of characters. Rather it be a sturct, a class or whatever.

“string” is a structure, so sizeof() returns the size of that structure, not the size of the string it manages.
If it was instead:
const char szString[] = "Hello fellow citizens.";
Then sizeof() would return the number of characters, including the terminating NULL.


screw that idea.

I supported you on SIZE_T but I feel less sorry for you after you posted this.


L. Spiro


Watever, dude. Seriously, all I hear is "IM WRONG" "I AM WRONG" from all you people on here. So, whatever. Have a good day; dude.


#4989106 string::size_type

Posted by SIC Games on 11 October 2012 - 08:12 AM


SIZE_T just returns a integar or length of bytes for the string. SIZE_T is the same function of sizeof(). SIZE_T just stores the integar length of a string or what not.


SIZE_T StringLength;
string Greeting = "Hello, I'm George!";
StringLength = sizeof(Greeting);
cout << StringLength;


As you see the SIZE_T is a typdef that stores the integer of length. Where as sizeof function returns the length of the string Greeting.


std::string varString = "Hello World";
unsigned int size = sizeof(varString);
sizeof DOES NOT RETURN THE SIZE OF THE STRING INSIDE THE STD::STRING

It returns the size of the string class. The string class uses dynamic memory to store cstrings. So only the pointer is counted as well as any other members. If you want the size of an std::string you use .size();


sizeof returns the length in bytes of a char. - whether it be a array or what not. Whatever - I was trying to help out; screw that idea.


#4988961 string::size_type

Posted by SIC Games on 10 October 2012 - 10:51 PM

SIZE_T just returns a integar or length of bytes for the string. SIZE_T is the same function of sizeof(). SIZE_T just stores the integar length of a string or what not.


SIZE_T StringLength;
string Greeting = "Hello, I'm George!";
StringLength = sizeof(Greeting);
cout << StringLength;


As you see the SIZE_T is a typdef that stores the integer of length. Where as sizeof function returns the length of the string Greeting.


#4988953 Double to Float

Posted by SIC Games on 10 October 2012 - 10:28 PM

frob is right! Doubles have longer range than floats which takes up more memory. However, conversion from float to double isn't that hard to say at least just impacts the performance. If you wanted to convert a float to a double just put the:


float PI = 3.14;
float ConvertFloat = (double)PI;

-- or --

double AnotherPie = PI;

However, floats are used in most 3D Applications instead of doubles. But if you insist - go ahead and try and see what your results are. If you feel the performance is getting a punch then this would be the reason behind using floats instead of doubles. I forgot how many bytes doubles use but they're way different than floats.


#4977842 What improves better memory performance?

Posted by SIC Games on 07 September 2012 - 04:59 PM

"INTERIOR DEBATE ROOM - NIGHT TIME"

AS THE SMOKE CLEARS, A BIT OF HAZE STILL DRIFTS JUST LINGERING ON THE FLOOR.

Is everyone finished? Cool, Group Hug Everyone! Com'on!


#4973800 Does this sound like the right ideal for PAK?

Posted by SIC Games on 27 August 2012 - 09:18 AM

Thanks bud! I kinda felt I was thinking in the right approach for this. I can also agree with you on writting the offset because logically, to me it's like a sql database, in order for google or whatever to pull up results - the entries are queried. So, this makes a lot more sense Hodgman. I know you didn't say actually sql database but I interpret it a PAK is like a book. Table of Contents with the filenames and the offsets, then the rest of the pages are the binary file.

Also, what you said at run time makes a lot sense because it'll have more performance. I was fooling around last night with the code and just work up - perhaps maybe later tonight I'll get a managed assembly class working. I'll report soon! I need more coffee just woke up lol

-Paul


#4973193 which IDE should i use for opengl?

Posted by SIC Games on 24 August 2012 - 10:57 PM

Visual Studio Express is best. Finally microsoft put in intellisense for C++ language in Visal Studio 2012.




PARTNERS