Feed on
Posts
Comments

Tag 'Bad excuse for not blogging more often'

Click the post title to be able to read and write comments.

I recently got the idea to try to create a procedural shader system for DirectX 11. This basically entails that one simply throws a mesh at the shader generator and it generates a customized shader for this mesh that suits it perfectly.
I knew it is being done in high-end game engines but I had no idea how one actually does it. I spent quite a lot of time on google trying to find this, but it basically looks like some universal secret even though it actually is quite simple. So I played around with it a bit and I managed to get it to work in the end. So the follow code snippet is the procedure I used for getting it to work, probably a whole load of other ones out there.
Just hope this saves other people the same frustrations I had for a while.

void GenerateShader()
{
        ostringstream shader;

        // Basic Vertex Shader
	shader << "float4 BasicVS( float4 Pos : POSITION ) : SV_POSITION" << endl;
	shader << "{" << endl;
	shader << "	return Pos;" << endl;
	shader << "}" << endl;

        // Basic Pixel Shader
	shader << "float4 BasicPS( float4 Pos : SV_POSITION ) : SV_Target" << endl;
	shader <<"{" << endl;
	shader <<"	return float4( 1.0f, 1.0f, 1.0f, 1.0f );" << endl;
	shader <<"}" << endl;

        // A standard DirectX 10 technique
	shader << "technique10 DefaultTechnique" << endl;
	shader << "{" << endl;
	shader << "	pass p0" << endl;
	shader << "	{" << endl;
	shader << "		SetGeometryShader(NULL);" << endl;
	shader << "		SetVertexShader(CompileShader(vs_4_0, BasicVS()));" << endl;
	shader << "		SetPixelShader(CompileShader(ps_4_0, BasicPS()));" << endl;
	shader << "	}" << endl;
	shader << "}" << endl;         

        // This is where the "magic" is at. Grab the char* from your stringstream
        // and feed it into D3DCompile() along with whatever other parameters you usually send it.
        ID3DBlob* errorBlob;
        unsigned int shaderSize = shader.str().size() * sizeof(char);
        HRESULT hr = D3DCompile(shader.str().c_str(), shaderSize, "none", 0, 0, "DefaultTechnique",
                                          "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &blob_, &errorBlob);
	if( FAILED(hr) )
        {
                OutputDebugStringA( (char*)errorBlob->GetBufferPointer() );
	}
	SAFE_RELEASE( errorBlob );
}

So now all that is left is 99.9% of the work to actually switch case together a shader that supports all the things your different meshes might need.
Maybe I will post something on that later when I manage to make a dent in that daunting task :p

So… It’s been a while.

Life is good, excluding the torment of a dying molar, and not a whole lot has happened in this time of silence. Work has been good, but has not really been related to what I wanted to write about in this blog so I opted to stay quiet for a while.

Lately I started looking at available positions in various game companies and it was somewhat upsetting to notice that you are not really suited for filling any position other than as a junior. So I basically decided that I really needed to do something about my portfolio. It was a while back that I decided this, but there was Christmas and stuff in the way so I haven’t really started doing stuff until now. Now it has begun though.

The general idea is that I will simply implement all the various things I have always wanted to try and then post the results in the portfolio section (hopefully with some binaries as well). The types of thing I will be implementing will mostly be 3D graphics related, since this is the area I always seem to find myself drooling over. But there will also be some other stuff like resource management and so on.

I have already implemented the first thing I will be putting on the portfolio (relief mapping) and it will be going up there shortly (probably not today though). Other things to be expected, in the very near future, are things like, just to name a few: Parallax mapping, Screen Space Ambient Occlusion, Deferred rendering.

If one refuses to work for any other industry one can only blame themselves for not doing everything in their power to be worthy of working there.

No news is good news?

Yeah so I haven’t written in a while. Been busy with school so there hasn’t been much progress with the “furthering of my career” aspect of my life.

One of the courses I am taking is assignment oriented, so there is no exam, which makes the assignments very time consuming. So I have been working alot at that.

After these few weeks of being back to school I have convinced myself that I really need to try harder to find a job. School is nice and stuff, but I feel ready to make a name for myself and gain proper work experience.

So I updated my portfolio a bit today (just added info about my Bachelor’s thesis) and found a job I am going to apply for as well. So the rest of the day will be dedicated to three tasks.

  1. Write a cover letter and apply for the job.
  2. Start looking at the next assignment.
  3. Go to Amiralen (a local shopping center) and do some grocery shopping (Dragons need food apparently).

So yeah, thats about it.

Give me a job!