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

#5179974 Light - Dot function

Posted by SIC Games on 12 September 2014 - 03:18 PM

Thanks, float4 PosD = float4(0, 1, 0, 0); resolved problem with dot funtion.

But i still have problem with this lightning.

struct PS_INS_INPUT{

	float4 Pos : SV_POSITION;
	float4 Nor : NORMAL;
	float2 Tex : TEXCOORD0;
	float Light_S : LIGHT_S;


struct VS_INS_INPUT{

	float4 Pos : POSITION;
	float4 Nor : NORMAL;
	float2 Tex : TEXCOORD0;

	matrix instancePos : INSTANCEPOS;
	float Light_S : LIGHT_S;


	output.Pos = mul (input.Pos, input.instancePos);
    output.Pos = mul (output.Pos, View);
    output.Pos = mul (output.Pos, Projection);
    output.Tex = input.Tex;
	output.Light_S = input.Light_S;
	output.Nor = mul (input.Nor, input.instancePos);

    return output;

float4 PS_INS (PS_INS_INPUT input) : SV_Target{

	float4 diffuse = txDiffuse.Sample( samLinear, input.Tex ) * input.Light_S + KolorL;

	float3 PosD = float3 (0.25f, 0.5f, -1.0f);

	float3 LighD = float3 (0.5f, 0.5f, 0.5f);
	float3 LighA = float3 (0.2f, 0.2f, 0.2f);
	float3 FK;

	float3 NR = float3 (input.Nor.x, input.Nor.y, input.Nor.z);

	FK = diffuse * LighA;
	FK += saturate(dot(PosD, NR) * LighD * diffuse);

	return float4 (FK, diffuse.a);


Without FK += saturate(dot(PosD, NR) * LighD * diffuse);



With FK += saturate(dot(PosD, NR) * LighD * diffuse);



Why do I get someting like second photo? 


I'm guessing this is directional lighting being used like the sun? The reason why you're getting washed out area inside image two would because the position of the light is 1 unit above ground.

float3 PosD = float3(0.25f, 0.5f, -1.0f); //-- Light Position
float3 lightD = float3(0.5f, 0.5f, 0.5f) //-- Light Diffuse term
float3 lightA = float3(0.2f, 0.2f, 0.2f); //-- Light Ambient
float3 diffuseLight = diffuse.xyz * lightA; //-- Calculating diffuse map with the ambient color.
float intensity = saturate(dot(posD, input.normal)); //-- Clamp from 0 to 1 and get angle of light position to normal.
diffuseLight += saturate(lightD * intensity); //- Accumulate the diffuse light with the light intensity.

You could probably leave out the saturate from the diffuseLight accumulation - if it helps. I see you also changed the light position as well. Try to position it a bit heigher on Y Axis and see if there's any changes on how you like it.


Also the dot hlsl function returns a scalar 1 (float, int) - which could be the reason why you were having issues.



#5178234 Shader Resource View and Load()

Posted by SIC Games on 04 September 2014 - 11:20 PM

tex2D.MipLevels = 1;
tex2D.ArraySize = 1;
tex2D.Height = (height size of your texture.)
tex2D.Width = (width)
tex2D.Usage = D3D10_USAGE_DEFAULT;
tex2D.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
tex2D.CPUAccess = 0;
tex2D.SampleDesc.Count = 1;
tex2D.SampleDesc.Quality = 0;
tex2D.MiscFlags = 0;

srvD.Texture2D.MipLevels = 1;
srvD.Texture2D.MostDetailedMip = 0;
srvD.Format = tex2D.format;

I should've asked if you're trying to load a texture? If so then  you can use the D3DX10CreateShaderResourceViewFromFile


MSDN Reference of the function D3DX10CreateShaderResourceViewFromFile




It would load the texture and create a shader resource view which you can place inside your shader code.


Unless you're trying to do something different.

#5177598 What are these showing in my normal map (Forward Rendering)

Posted by SIC Games on 02 September 2014 - 12:37 AM

I've solved the issue - in BrazynerSoft Normalmapping tutorial he has it where you can compute the normals and tangents if needed to.


What I didn't notice is inside where the vertex data gets stored there's a XMFLOAT3 Tangent. If the compute normals aren't enabled - it sets the Tangent Data to black. Still resulting in proper display of the normal map without the messed up with edges that I had first post.


So, now there's no longer a weird shading issue due to proper filling of the input layout for the shader and the the vertex data.  It's really funny how the input layout for the shader has to match the exact same type of vertex data going in.


Thanks again for the support!

#5177566 What are these showing in my normal map (Forward Rendering)

Posted by SIC Games on 01 September 2014 - 09:28 PM

I hit the jack pot - I rendered Tangent data out Brayzsoft tutorial Normal Mapping and compared to mine plane.


Mine inside editor:




Brayznsoft Normal Map tutorial - Tangent Data rendered out


Brayzsoft-Normalmapsample (0-00-10-19).jpg


Now the question is since I set the compute normals off inside Brayzansoft normal map example - I have to look deeper into why my tangents aren't working.


Thanks Hodges for giving a helping hand but I know which direction now I have to head. Focus on how the data's being loaded from the mesh and also see if I can place visual cues in the geometry shader of the normals directions too.


Thanks Hodge..



#5177554 What are these showing in my normal map (Forward Rendering)

Posted by SIC Games on 01 September 2014 - 07:39 PM

This is the tangent rendered out without using color


Snapshot1 - Copy (3).jpg


The black and the abruptness of colors I would suspect to be a issue in the tangents. So possibly I would have to re-calculate the tangents by using the normals inside the mesh.


This is the tangent data calculated.




The same edges appear as top of this thread. So possibly recacluating the tangent data would do some good.



#5177548 What are these showing in my normal map (Forward Rendering)

Posted by SIC Games on 01 September 2014 - 07:24 PM

By discontinuuity what do you mean? Non-consistant?


This is the image of the normal as a color:


The hard edge is considered a discontinuity?


Normal map



input.normal as color

Snapshot1 - Copy (2).jpg


input.tangent as color


Snapshot1 - Copy.jpg


I'm sorry for uploading so many photos just trying to understand what you mean by discontinuity and how to debug something later in the future.



#5177543 What are these showing in my normal map (Forward Rendering)

Posted by SIC Games on 01 September 2014 - 06:56 PM

What I got was this :



Top view:




Left View



Bottom View



What colors am I looking for exactly?


I changed the PS code to be like you mentioned:

        input.normal = normalize(input.normal) * 0.5f + 0.5f;
	input.tangent = normalize(input.normal) * 0.5f + 0.5f;
	//input.tangent = normalize(input.tangent - dot(input.tangent, input.normal) * input.normal);

	float3 B = cross(input.normal,input.tangent);
	float3x3 texspace = float3x3(input.tangent,B,input.normal);
         input.normal = mul(normalmap,texspace);

#5177533 What are these showing in my normal map (Forward Rendering)

Posted by SIC Games on 01 September 2014 - 05:36 PM

When I output the normal map this shows up:




Would this be a normal issue inside the mesh? Funny how Brazynsoft checks to see if the parameter of cumpute normals is true or false. If not then it uses the normals from the mesh. I'm using the normals from the mesh.


The shader:

output.normal = mul(input.normal, (float3x3)worldMatrix); //-- worldMatrix is the model's world matrix.
output.tangent = mul(input.tangent, (float3x3)worldMatrix);


float3 normalmap = Textures[1].Sample(ss, input.texcoord);
normalmap = 2.0f * normalmap - 1.0f;

input.normal  = normalize(input.normal);
input.tangent = normalize(input.tangent - dot(input.tangent, input.normal) * input.normal);
float3 biTangent  = cross(input.tangent, input.normal);
float3x3 texSpace = float3x3(biTangent, input.Tangent, input.normal);

input.normal = normalize(mul(normalmap, texSpace));

Or possibly this could be a result of the normal map its self.

#5176601 Why are their bumps in my shadow mapping?

Posted by SIC Games on 28 August 2014 - 12:33 AM

I just started implemending Shadow Mapping in my engine and I see inside the editor there's bumps inside the shadow map. I'm wondering what they are?


The current set up I have is an orthographic Left Handed view for rendering depth. The depth stencil is rendered as DXGI_FORMAT_D24_UNORM_S8_UINT and is bounded both as depth stencil and shader resource. The texture format for the depth stencil is DXGI_FORMAT_R24G8_TYPELESS The shader resource view is formated as DXGI_FORMAT_R24_UNORM_X8_TYPELESS.


Is it a format issue?




If anyone needs to see sniplets of code I'll share.

#5176078 What you think of my Depth Pass AA?

Posted by SIC Games on 25 August 2014 - 04:00 PM

I'm wanting to implemend Nvidia's FXAA and TXAA inside my game - however, I figure I create my own AA. Perhaps, someone already has already came up with the type of AA and there's more work to do to enhance the blurring. I want your feedback and let me know what you think. It's rough demonstration not perfect quite yet.


The firest picture is when it's just using the 8x MSAA on high setting possible. The second image is the 8x MSAA and my Depth Pass AA implematation.


I'm still working on how to make it better. Was just fascinated on the descripton in Nvidia's website how FXAA works - this is when I started to think about trying out my own. I have a simple blur but I am thinking about making it box blur with two passes or possibly gaussian blur.

Attached Thumbnails

  • DepthPassAA-Off.PNG
  • DepthPassAA-On.PNG

#5173363 What happened to Rastertek?

Posted by SIC Games on 13 August 2014 - 09:49 AM

I need to always expand my skills so I may be converting rastertek tutorials everything into DirectX11.1 and openGL. When fully finished I'll send the link to anyone who will needed the tutorials. Sounds cool?

#5169965 Either I'm feeling burnt out or losing sight

Posted by SIC Games on 29 July 2014 - 12:22 AM

Thanks for the awesome feedback! I've been hitting pass those sluggish times where I want to take a coding vacation. Weirdly enough, the volumetric texturing had me do a lot more research than I ever did before! I think I actually learned a lot more than I had like two days. Back to the interconnecting of the engine - that's still undergoing it's way. Still working on the current issues. Today I cleaned up some code crude that I didn't need. I commeted the ones I can use later. I learned a hell alot more about memory allocation and provide better means. I kept on getting a stackoverflowexception than I figured out what I was doing wrong. I stopped that and sit back think why did that give me an exception.


A lot of the times it's just keeping the eye on the goal and never looking back. Hell, if my game doesn't sell nor work out as well I can always build an electronic equipment that uses 3D mapping like gdar - it sends radio waves through the grown when detecting hidden rooms or caves or some shat like that.


I wasn't thinking of Doom 3 as ideal goal - then again I think focusing on my own would be better than focusing on other people's engines.

#5169523 What happened to Rastertek?

Posted by SIC Games on 27 July 2014 - 10:26 AM

He better get that site back up and running again - that was weird! I checked and like you said everything was wiped. I'm going to cry now - there was no explaination just vanished like a ninja.

#5169522 MSAA in Deferred shading

Posted by SIC Games on 27 July 2014 - 10:25 AM

When you create your render target and depth stencil view - you must make sure the samples are the same and can be made for that format. In my deferred shading I use 8x MSAA. In your question how do you access the samples? I got the deferred shading from Rastertek and sadly it's down for now  :(


Maybe a sniplette will help or an basic idea:

ID3D11_Texture2D_Desc texDesc;

//... fill in the required texture2D for the render target you're creating. 
texDesc.format = DXGI_FORMAT_R32G32B32A32_FLOAT;
texDesc.Samples.Count = 8;
texDesc.Samples.Quality = 32;
... - Normally how you'll create the texture2D. 

... create new Texture2D Description for depth Stencil View - just same as above BUT. 

depthTexDesc.format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthTexDesc.Bindflags = D3D11_BIND_DEPTH_STENCIL;

-- Create the depth stencil  view with the newly created depth stencil 2D Texture.

If you want to test to see if that format supports or what quality that format supports you can use ID3D11Device::CheckMultiSampleQualityLevels upon directx device creation

#5169368 Either I'm feeling burnt out or losing sight

Posted by SIC Games on 26 July 2014 - 02:47 PM

Upon dissecting the HPL 1 Engine, Doom 3 Engine and looking back at my engine...As far as coding skills are consern I have a lot to learn! The whole entire framework is whacked. I am going back to read the Game Engine Architecture. It helped point out a lot about the design of an game engine. 


In addiition, a API or SDK are just tools laid out for the developer to build a game. A house wouldn't be built without tools, right? Game is the house as in tools are the game engine's api or sdk.


What I've noticed is the Doom 3 engine uses a lot of macros definations and HPL 1 Engine uses a lot of macros. I thought you want to stay away from macro definations as best as you could?


Why in the world reading through someone's elses code so confusing? HPL1 uses a lot of interfacing; a lot of polymorphisms and don't forget the macro definations.


Remember that callback question that I asked about? Yeah I found out how that one works - never looked at the HPL Engine source code closely like today.


A lot of the time I was searching within the project how they co-relate to eachother. Callback function is all the way over to another header file, that  gets used by a lowLevelSystem header file and then over the script header file.


It's like connect the dots - literally! Over here and over there and over there and over there!


Aren't any API or SDK suppose to make sense or do they literally have the whole "Connect The Dots"? Or do they purposly do that to prevent others from dissecting their code and making a better engine then theirs?


man: It's like here's a bunch of nails, screws, bolts, washer, a some wood and scrap metal - there you go! Have at it - now build a shed.

Builder: Where's the instructions?

man: There's no need for instructions just go with what you feel best!

Builder: Huh?!


How many revisions do a game engine undetake anyways? This is perhaps my fifth or so.  I'm just venting - don't mind me! TIme for a smoke.