• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By fs1
      I have been trying to see how the ID3DInclude, and how its methods Open and Close work.
      I would like to add a custom path for the D3DCompile function to search for some of my includes.
      I have not found any working example. Could someone point me on how to implement these functions? I would like D3DCompile to look at a custom C:\Folder path for some of the include files.
      Thanks
    • By stale
      I'm continuing to learn more about terrain rendering, and so far I've managed to load in a heightmap and render it as a tessellated wireframe (following Frank Luna's DX11 book). However, I'm getting some really weird behavior where a large section of the wireframe is being rendered with a yellow color, even though my pixel shader is hard coded to output white. 

      The parts of the mesh that are discolored changes as well, as pictured below (mesh is being clipped by far plane).

      Here is my pixel shader. As mentioned, I simply hard code it to output white:
      float PS(DOUT pin) : SV_Target { return float4(1.0f, 1.0f, 1.0f, 1.0f); } I'm completely lost on what could be causing this, so any help in the right direction would be greatly appreciated. If I can help by providing more information please let me know.
    • By evelyn4you
      Hello,
      i try to implement voxel cone tracing in my game engine.
      I have read many publications about this, but some crucial portions are still not clear to me.
      At first step i try to emplement the easiest "poor mans" method
      a.  my test scene "Sponza Atrium" is voxelized completetly in a static voxel grid 128^3 ( structured buffer contains albedo)
      b. i dont care about "conservative rasterization" and dont use any sparse voxel access structure
      c. every voxel does have the same color for every side ( top, bottom, front .. )
      d.  one directional light injects light to the voxels ( another stuctured buffer )
      I will try to say what i think is correct ( please correct me )
      GI lighting a given vertecie  in a ideal method
      A.  we would shoot many ( e.g. 1000 ) rays in the half hemisphere which is oriented according to the normal of that vertecie
      B.  we would take into account every occluder ( which is very much work load) and sample the color from the hit point.
      C. according to the angle between ray and the vertecie normal we would weigth ( cosin ) the color and sum up all samples and devide by the count of rays
      Voxel GI lighting
      In priciple we want to do the same thing with our voxel structure.
      Even if we would know where the correct hit points of the vertecie are we would have the task to calculate the weighted sum of many voxels.
      Saving time for weighted summing up of colors of each voxel
      To save the time for weighted summing up of colors of each voxel we build bricks or clusters.
      Every 8 neigbour voxels make a "cluster voxel" of level 1, ( this is done recursively for many levels ).
      The color of a side of a "cluster voxel" is the average of the colors of the four containing voxels sides with the same orientation.

      After having done this we can sample the far away parts just by sampling the coresponding "cluster voxel with the coresponding level" and get the summed up color.
      Actually this process is done be mip mapping a texture that contains the colors of the voxels which places the color of the neighbouring voxels also near by in the texture.
      Cone tracing, howto ??
      Here my understanding is confus ?? How is the voxel structure efficiently traced.
      I simply cannot understand how the occlusion problem is fastly solved so that we know which single voxel or "cluster voxel" of which level we have to sample.
      Supposed,  i am in a dark room that is filled with many boxes of different kind of sizes an i have a pocket lamp e.g. with a pyramid formed light cone
      - i would see some single voxels near or far
      - i would also see many different kind of boxes "clustered voxels" of different sizes which are partly occluded
      How do i make a weighted sum of this ligting area ??
      e.g. if i want to sample a "clustered voxel level 4" i have to take into account how much per cent of the area of this "clustered voxel" is occluded.
      Please be patient with me, i really try to understand but maybe i need some more explanation than others
      best regards evelyn
       
       
    • By Endemoniada

      Hi guys, when I do picking followed by ray-plane intersection the results are all wrong. I am pretty sure my ray-plane intersection is correct so I'll just show the picking part. Please take a look:
       
      // get projection_matrix DirectX::XMFLOAT4X4 mat; DirectX::XMStoreFloat4x4(&mat, projection_matrix); float2 v; v.x = (((2.0f * (float)mouse_x) / (float)screen_width) - 1.0f) / mat._11; v.y = -(((2.0f * (float)mouse_y) / (float)screen_height) - 1.0f) / mat._22; // get inverse of view_matrix DirectX::XMMATRIX inv_view = DirectX::XMMatrixInverse(nullptr, view_matrix); DirectX::XMStoreFloat4x4(&mat, inv_view); // create ray origin (camera position) float3 ray_origin; ray_origin.x = mat._41; ray_origin.y = mat._42; ray_origin.z = mat._43; // create ray direction float3 ray_dir; ray_dir.x = v.x * mat._11 + v.y * mat._21 + mat._31; ray_dir.y = v.x * mat._12 + v.y * mat._22 + mat._32; ray_dir.z = v.x * mat._13 + v.y * mat._23 + mat._33;  
      That should give me a ray origin and direction in world space but when I do the ray-plane intersection the results are all wrong.
      If I click on the bottom half of the screen ray_dir.z becomes negative (more so as I click lower). I don't understand how that can be, shouldn't it always be pointing down the z-axis ?
      I had this working in the past but I can't find my old code
      Please help. Thank you.
    • By turanszkij
      Hi,
      I finally managed to get the DX11 emulating Vulkan device working but everything is flipped vertically now because Vulkan has a different clipping space. What are the best practices out there to keep these implementation consistent? I tried using a vertically flipped viewport, and while it works on Nvidia 1050, the Vulkan debug layer is throwing error messages that this is not supported in the spec so it might not work on others. There is also the possibility to flip the clip scpace position Y coordinate before writing out with vertex shader, but that requires changing and recompiling every shader. I could also bake it into the camera projection matrices, though I want to avoid that because then I need to track down for the whole engine where I upload matrices... Any chance of an easy extension or something? If not, I will probably go with changing the vertex shaders.
  • Advertisement
  • Advertisement
Sign in to follow this  

DX11 Injection LPV Geometry Shader

This topic is 818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,

this is my first time that i work with geometry shader and drawing without vertex and index buffer and since some of these errors makes some confusions, i thought it's better to ask my question in here.

this code is based on LPV sample that has been made by DX10 we have discussed here and i just tried to convert that into my DX11 project.

 

Here are my errors that I've got:

 

[SPOILER]

D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 1, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 2, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'NORMAL' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ EXECUTION ERROR #345: DEVICE_SHADER_LINKAGE_REGISTERMASK]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,3) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'NORMAL' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' has mismatched data types between the output stage and input stage. [ EXECUTION ERROR #344: DEVICE_SHADER_LINKAGE_COMPONENTTYPE]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ EXECUTION ERROR #345: DEVICE_SHADER_LINKAGE_REGISTERMASK]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' in each signature have different min precision levels, when they must bet identical.  [ EXECUTION ERROR #3146050: DEVICE_SHADER_LINKAGE_MINPRECISION]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ EXECUTION ERROR #345: DEVICE_SHADER_LINKAGE_REGISTERMASK]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' in each signature have different min precision levels, when they must bet identical.  [ EXECUTION ERROR #3146050: DEVICE_SHADER_LINKAGE_MINPRECISION]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,4) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,5) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,6) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,7) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,8) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,9) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,10) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,11) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,12) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,13) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,14) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,15) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,16) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,17) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,18) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,19) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]

[/SPOILER]

 

 

- first three warning shows that i didn't bind render targets to my progam, but i did it. you can see that in the codes below

- and the next three shows that my Vertex output isn't the same as geometry input, but it also the same, there should be other reason for this.

- for linkage error between geometry and pixel shader, i don't know why so many TEXCOORD sgnatures mentioned here since i've used only wo TEXCOORD in my program.

 

 

draw function in my DX program:

[SPOILER]

bool RenderInjection()
{
	d3d11DevCon->OMSetRenderTargets(3, Injection_RTV, RT_depthStencilView);

	//Refresh the Depth/Stencil view
	d3d11DevCon->ClearDepthStencilView(RT_depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

	d3d11DevCon->VSSetShader(injection_vertexShader, 0, 0);
	d3d11DevCon->GSSetShader(injection_geometryShader, 0, 0);
	d3d11DevCon->PSSetShader(injection_pixelShader, 0, 0);

	//Set the Viewport
	d3d11DevCon->RSSetViewports(1, &RT_viewport);

	d3d11DevCon->IASetInputLayout(NULL);
	d3d11DevCon->IASetVertexBuffers(NULL, 0, 0, 0, 0);
	d3d11DevCon->IASetIndexBuffer(NULL, DXGI_FORMAT_R32_UINT, 0);

	d3d11DevCon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	for (int i = 1; i < MRT_BUFFER_COUNT; i++)
		d3d11DevCon->VSSetShaderResources((i - 1), 1, &RT_shaderResourceView[i]);

	d3d11DevCon->PSSetShaderResources(0, 3, Injection_SRV);

	d3d11DevCon->Draw(RT_Width * RT_Width, 0);

	return true;
}

[/SPOILER]

 

my vertex shader:

[SPOILER]

float lpv_cellSize = 3.0f;
float3 lpv_minCorner = float3(-11.0f, -11.0f, -11.0f);
float3 lpv_size = float3(11.0f, 11.0f, 11.0f);


Texture2D<float4> PositionMap;
Texture2D<float4> NormalMap;
Texture2D<float4> FluxMap;

struct VS_INJECTION_INPUT {
	uint posIndex : SV_VertexID;
};

struct VS_INJECTION_OUTPUT {
	float4 cellIndex : SV_POSITION;
	float3 normal : NORMAL;
	float3 flux : TEXCOORD0;
};

VS_INJECTION_OUTPUT VS_gpuInjection(VS_INJECTION_INPUT input) {
	float2 RSMsize;
	PositionMap.GetDimensions(RSMsize.x, RSMsize.y);
	float3 rsmCoords = float3(input.posIndex % RSMsize.x, input.posIndex / RSMsize.x, 0);

	float3 posWorld = PositionMap.Load(rsmCoords);
	float3 normalWorld = NormalMap.Load(rsmCoords);
	float3 flux = FluxMap.Load(rsmCoords);

	VS_INJECTION_OUTPUT output;
	output.cellIndex = float4(int3((posWorld - lpv_minCorner) / lpv_cellSize + 0.5 * normalWorld), 1.0);

	output.normal = normalWorld;
	output.flux = flux;

	return output;
}

[/SPOILER]

 

geometry shader:

[SPOILER]

struct VS_INJECTION_OUTPUT {
	float4 cellIndex : SV_POSITION;
	float3 normal : NORMAL;
	float3 flux : TEXCOORD0;
};

struct GS_INJECTION_OUTPUT {
	float4 screenPos : SV_Position;
	float3 normal : NORMAL;
	uint depthIndex : TEXCOORD1;
	float3 flux : TEXCOORD2;
};

float lpv_cellSize;
float3 lpv_minCorner;
float3 lpv_size;

[maxvertexcount(1)]
void GS_gpuInjection(point VS_INJECTION_OUTPUT input[1], inout PointStream<GS_INJECTION_OUTPUT> OutputStream) {
	GS_INJECTION_OUTPUT output;

	output.depthIndex = input[0].cellIndex.z;
	output.screenPos.xy = (float2(input[0].cellIndex.xy) + 0.5) / lpv_size.xy * 2.0 - 1.0;
	// invert y direction because y points downwards in the viewport?
	output.screenPos.y = -output.screenPos.y;
	output.screenPos.zw = float2(0, 1);

	output.normal = input[0].normal;
	output.flux = input[0].flux;

	OutputStream.Append(output);
}

[/SPOILER]

 

pixel shader:

[SPOILER]

struct PS_INJECTION_OUTPUT {
	float4 redSH;
	float4 greenSH;
	float4 blueSH;
};

struct GS_INJECTION_OUTPUT {
	float4 screenPos : SV_Position;
	float3 normal : NORMAL;
	uint depthIndex : TEXCOORD1;
	float3 flux : TEXCOORD2;
};


#define SH_cosLobe_c0 0.886226925f /* sqrt(pi)/2 */
#define SH_cosLobe_c1 1.02332671f /* sqrt(pi/3) */
#define Pi 3.1415926f


// helper function
float4 SH_evaluateCosineLobe(float3 direction) {
	direction = normalize(direction);
	return float4(SH_cosLobe_c0, -SH_cosLobe_c1 * direction.y, SH_cosLobe_c1 * direction.z, -SH_cosLobe_c1 * direction.x);
}


PS_INJECTION_OUTPUT PS_gpuInjection(GS_INJECTION_OUTPUT input) : SV_TARGET
{
	PS_INJECTION_OUTPUT output;

	if (length(input.normal) < 0.01) {
		discard;
	}

	// the SHcoeffs model an intensity function
	// thus the integral over all intensities (over the sphere) should be the original flux
	// and that integral = Pi * totalFlux, so divide by Pi
	float4 SHcoeffs = SH_evaluateCosineLobe(input.normal) / Pi;

	output.redSH = SHcoeffs * input.flux.r;
	output.greenSH = SHcoeffs * input.flux.g;
	output.blueSH = SHcoeffs * input.flux.b;


	return output;
}

[/SPOILER]

 

 

PS: sorry i didn't want to simply copy and paste my code in here but i really didn't know how can i figure it out

Edited by Nathan Drake

Share this post


Link to post
Share on other sites
Advertisement

Use RenderDoc. It will provide a lot of help in debugging your problem.

 

Normally your errors means the structure definition between the VS & GS and the GS & PS do not match. It doesn't seem to be the case here, although I never worked with GS that involved points instead of tris.

This error can also happen if you later render something else, and you changed the VS & PS but forgot to take out the GS (very common mistake).

 

You're also getting errors that your pixel shader is using MRT and outputting to 3 RTs; but you never call OMSetRenderTargets with three different RTs. It looks like you're confusing PSSetShaderResources with OMSetRenderTargets.

 

And last but not least. Use RenderDoc. It's an invaluable tool which will help you understand what's going wrong.

Edited by Matias Goldberg

Share this post


Link to post
Share on other sites

Use RenderDoc. It will provide a lot of help in debugging your problem.

 

Normally your errors means the structure definition between the VS & GS and the GS & PS do not match. It doesn't seem to be the case here, although I never worked with GS that involved points instead of tris.

This error can also happen if you later render something else, and you changed the VS & PS but forgot to take out the GS (very common mistake).

 

You're also getting errors that your pixel shader is using MRT and outputting to 3 RTs; but you never call OMSetRenderTargets with three different RTs. It looks like you're confusing PSSetShaderResources with OMSetRenderTargets.

 

And last but not least. Use RenderDoc. It's an invaluable tool which will help you understand what's going wrong.

 

thank you for your guide

i've used OMSetRenderTargets at the first line of my function.

 

 

This error can also happen if you later render something else, and you changed the VS & PS but forgot to take out the GS (very common mistake).

 

this was an issue !

i also didn't set 3 global variables in my geometry shader thanks to RenderDoc

but still has some issue, i'll let you know if it doesn't solve.

 

thanks btw

 

Update : another issue was i didn't return back the primitive topology to TriangleList

this RenderDoc is very useful tool but i have to gain more experience of how to use it and which parts are more important to look at when i facing on any errors.

 

everything looks fine now, i have to go for propagation step and see the result !

Edited by Nathan Drake

Share this post


Link to post
Share on other sites

 

Use RenderDoc. It will provide a lot of help in debugging your problem.

 

Normally your errors means the structure definition between the VS & GS and the GS & PS do not match. It doesn't seem to be the case here, although I never worked with GS that involved points instead of tris.

This error can also happen if you later render something else, and you changed the VS & PS but forgot to take out the GS (very common mistake).

 

You're also getting errors that your pixel shader is using MRT and outputting to 3 RTs; but you never call OMSetRenderTargets with three different RTs. It looks like you're confusing PSSetShaderResources with OMSetRenderTargets.

 

And last but not least. Use RenderDoc. It's an invaluable tool which will help you understand what's going wrong.

 

thank you for your guide

i've used OMSetRenderTargets at the first line of my function.

 

 

This error can also happen if you later render something else, and you changed the VS & PS but forgot to take out the GS (very common mistake).

 

this was an issue !

i also didn't set 3 global variables in my geometry shader thanks to RenderDoc

but still has some issue, i'll let you know if it doesn't solve.

 

thanks btw

 

Update : another issue was i didn't return back the primitive topology to TriangleList

this RenderDoc is very useful tool but i have to gain more experience of how to use it and which parts are more important to look at when i facing on any errors.

 

everything looks fine now, i have to go for propagation step and see the result !

 

RenderDoc works pretty similar to a normal debugger for C++ code, except that in GPU land you have a few more things to worry about, like pipeline states and stuff like that. A very usefull overlay in the render target view is "Wireframe mesh" this will instantly show you where and whether a draw call hit the render target. Edit from there you usually start with debug pixel in that wire frame overlay so you can see what happens to it, this will also id most of the resources used so you can inspect them.

Edited by NightCreature83

Share this post


Link to post
Share on other sites

I have bound my render target view but it screams in output that RenderTarget view isn't bound.

 

[SPOILER]

bool InitializeInjectionShader()
{
	ID3D11RenderTargetView* Injection_RTV[Inj_Num];
	ID3D11ShaderResourceView* Injection_SRV[Inj_Num];
	ID3D11Texture2D* Injection_Texture[Inj_Num];
	bool hresult;

	std::vector<unsigned char> VSInjectionFile = ReadFile("Injection_VS.cso");
	d3d11Device->CreateVertexShader(VSInjectionFile.data(), VSInjectionFile.size(), NULL, &injection_vertexShader);

	std::vector<unsigned char> GSInjectionFile = ReadFile("Injection_GS.cso");
	d3d11Device->CreateGeometryShader(GSInjectionFile.data(), GSInjectionFile.size(), NULL, &injection_geometryShader);

	std::vector<unsigned char> PSInjectionFile = ReadFile("Injection_PS.cso");
	d3d11Device->CreatePixelShader(PSInjectionFile.data(), PSInjectionFile.size(), NULL, &injection_pixelShader);


	D3D11_TEXTURE2D_DESC texDesc;
	ZeroMemory(&texDesc, sizeof(texDesc));

	texDesc.Width = RT_Width;
	texDesc.Height = RT_Width;
	//texDesc.Depth = RT_Width;
	texDesc.MipLevels = 1;
	texDesc.ArraySize = 1;
	texDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	texDesc.SampleDesc.Count = 1;
	texDesc.Usage = D3D11_USAGE_DEFAULT;
	texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	texDesc.CPUAccessFlags = 0;
	texDesc.MiscFlags = 0;

	for (int i = 0; i < Inj_Num; i++)
	{
		hresult = d3d11Device->CreateTexture2D(&texDesc, NULL, &Injection_Texture[i]);
		if (FAILED(hresult))
			return false;

		hresult = (d3d11Device->CreateRenderTargetView(Injection_Texture[i], 0, &Injection_RTV[i]));
		if (FAILED(hresult))
			return false;

		hresult = (d3d11Device->CreateShaderResourceView(Injection_Texture[i], 0, &Injection_SRV[i]));
		if (FAILED(hresult))
			return false;
	}

	return true;
}


bool RenderInjection()
{
	//Refresh the Depth/Stencil view
	d3d11DevCon->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

	//float bgColor[4] = { (0.0f, 0.0f, 0.0f, 0.0f) };

	//for (int i = 0; i < MRT_BUFFER_COUNT; i++)
		//d3d11DevCon->ClearRenderTargetView(Injection_RTV[i], bgColor);

	d3d11DevCon->OMSetRenderTargets(3, Injection_RTV, depthStencilView);

	d3d11DevCon->VSSetShader(injection_vertexShader, 0, 0);
	d3d11DevCon->GSSetShader(injection_geometryShader, 0, 0);
	d3d11DevCon->PSSetShader(injection_pixelShader, 0, 0);

	//Set the Viewport
	d3d11DevCon->RSSetViewports(1, &RT_viewport);

	d3d11DevCon->IASetInputLayout(NULL);
	d3d11DevCon->IASetVertexBuffers(NULL, 0, 0, 0, 0);
	d3d11DevCon->IASetIndexBuffer(NULL, DXGI_FORMAT_R32_UINT, 0);

	d3d11DevCon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	for (int i = 1; i < MRT_BUFFER_COUNT; i++)
		d3d11DevCon->VSSetShaderResources((i - 1), 1, &RT_shaderResourceView[i]);

	d3d11DevCon->Draw(RT_Width * RT_Width, 0);

	ID3D11RenderTargetView* empty[3] = { NULL, NULL, NULL };
	d3d11DevCon->OMSetRenderTargets(3, empty, NULL);

	ID3D11ShaderResourceView* srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = { 0 };
	d3d11DevCon->PSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, srvs);

	return true;
}

[/SPOILER]

 

I can't even clear my render targets before bind them as render targets.

D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 1, but none is bound
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 2, but none is bound

I'd appreciate someone guide me smile.png

 

UPDATE: Please forget about this issue

i was declared render targets inside the initialize function again ! and my render targets was empty ph34r.png

thanks to iedoc wub.png 

Edited by Nathan Drake

Share this post


Link to post
Share on other sites

after lots of searches, finally i've figure it out that i have to use the projection matrix in order to make the AABB around my scene. (thanks to IYP)

but also instead of drawing without vertex and index buffer, i wanna send the vertex and index buffer of my model into the shader (to make everything more handy)

 

this is the function that i've wrote for calculating the AABB from the projection matrix into world matrix (my FovAngleY = 0.4f*3.14f)

XMVECTOR frustumVertices[8];
XMVECTOR frustumMin, frustumMax;

void GenerateFrustumVertices()
{
    frustumVertices[0] = XMVectorSet(Width / 2 , Height / 2 , screenNear, 1.0f);
    frustumVertices[1] = XMVectorSet(-Width / 2, Height / 2 , screenNear, 1.0f);
    frustumVertices[2] = XMVectorSet(Width / 2 , -Height / 2 , screenNear, 1.0f);
    frustumVertices[3] = XMVectorSet(-Width / 2 , -Height / 2 , screenNear, 1.0f);
    frustumVertices[4] = XMVectorSet(Width / 2 * screenFar / screenNear, Height / 2 * screenFar / screenNear, screenFar, 1.0f);
    frustumVertices[5] = XMVectorSet(-Width / 2 * screenFar / screenNear, Height / 2 * screenFar / screenNear, screenFar, 1.0f);
    frustumVertices[6] = XMVectorSet(Width / 2 * screenFar / screenNear, -Height / 2 * screenFar / screenNear, screenFar, 1.0f);
    frustumVertices[7] = XMVectorSet(-Width / 2 * screenFar / screenNear, -Height / 2 * screenFar / screenNear, screenFar, 1.0f);

        // get the value in world space by multiplying the inverse of the camera View matrix with our minimum and maximum vertices
	frustumMin = XMVector4Transform(frustumVertices[3], XMMatrixInverse(nullptr, camView));
	frustumMax = XMVector4Transform(frustumVertices[4], XMMatrixInverse(nullptr, camView));

}

and i've added the vertex layout, vertex and index buffers and set the value of the cbuffer:

 

[SPOILER]

bool RenderInjection()
{
	//Refresh the Depth/Stencil view
	d3d11DevCon->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

	GenerateFrustumVertices();


	injBufferPerFrame.min = XMFLOAT3(XMVectorGetX(frustumMin), XMVectorGetY(frustumMin), XMVectorGetZ(frustumMin));
	injBufferPerFrame.max = XMFLOAT3(XMVectorGetX(frustumMax), XMVectorGetY(frustumMax), XMVectorGetZ(frustumMax));
	injBufferPerFrame.flag1 = XMFLOAT2(0.0f, 0.0f);
	d3d11DevCon->UpdateSubresource(Inj_PerFrameBuffer, 0, NULL, &injBufferPerFrame, 0, 0);
	d3d11DevCon->VSSetConstantBuffers(1, 1, &Inj_PerFrameBuffer);
	d3d11DevCon->GSSetConstantBuffers(0, 1, &Inj_PerFrameBuffer);

	float bgColor[4] = { (0.0f, 0.0f, 0.0f, 0.0f) };

	for (int i = 0; i < Inj_Num; i++)
		d3d11DevCon->ClearRenderTargetView(Injection_RTV[i], bgColor);

	d3d11DevCon->OMSetRenderTargets(3, Injection_RTV, Injection_DSV);

	d3d11DevCon->VSSetShader(injection_vertexShader, 0, 0);
	d3d11DevCon->GSSetShader(injection_geometryShader, 0, 0);
	d3d11DevCon->PSSetShader(injection_pixelShader, 0, 0);

	//Set the vertex buffer
	stride = sizeof(Vertex);

	//Set the Viewport
	d3d11DevCon->RSSetViewports(1, &RT_viewport);


	// Set the vertex buffer to active in the input assembler so it can be rendered.
	d3d11DevCon->IASetVertexBuffers(0, 1, &squareVertBuffer, &stride, &offset);

	//Set the cubes index buffer
	d3d11DevCon->IASetIndexBuffer(squareIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
	
	d3d11DevCon->IASetInputLayout(injection_layout);

	d3d11DevCon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	for (int i = 1; i < MRT_BUFFER_COUNT; i++)
		d3d11DevCon->VSSetShaderResources((i - 1), 1, &RT_shaderResourceView[i]);

	
        d3d11DevCon->DrawIndexed(18, 0, 0);

	ID3D11RenderTargetView* empty[3] = { NULL, NULL, NULL };
	d3d11DevCon->OMSetRenderTargets(3, empty, NULL);

	ID3D11ShaderResourceView* srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = { 0 };
	d3d11DevCon->PSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, srvs);

	return true;
}

[/SPOILER]

 

and also instead of d3d11DevCon->Draw(RSM_Width*RSM_Width), i have used the index of my cube which is in the scene

 

but unfortunately nothing drawn (I expect to see distributed lights in the cube)

is there something missing to do ? because my injection render targets are empty.

 

these are my shaders if you wanna take a look:

 

[SPOILER]

 

////////////////Vertex Shader////////////////////

Texture2D PositionMap;
Texture2D NormalMap;
Texture2D FluxMap;

struct VS_INJECTION_INPUT {
	uint posIndex : POSITION;
	float2 inTexCoord : TEXCOORD;
	float3 normal : NORMAL;
};

struct VS_INJECTION_OUTPUT {
	float4 cellIndex : SV_POSITION;
	float3 normal : NORMAL;
	float3 flux : TEXCOORD0;
};

cbuffer frustum : register(b0)
{
	float3 lpv_minCorner;
	float3 lpv_size;
	float2 flag1;
};


#define lpv_cellSize 3.0f

VS_INJECTION_OUTPUT VS_gpuInjection(VS_INJECTION_INPUT input) {

	float2 RSMsize;
	PositionMap.GetDimensions(RSMsize.x, RSMsize.y);
	float3 rsmCoords = float3(input.posIndex % RSMsize.x, input.posIndex / RSMsize.x, 0);

	float3 posWorld = PositionMap.Load(rsmCoords);
	float3 normalWorld = NormalMap.Load(rsmCoords);
	float3 flux = FluxMap.Load(rsmCoords);

	VS_INJECTION_OUTPUT output;
	output.cellIndex = float4(int3((posWorld - lpv_minCorner) / lpv_cellSize + 0.5 * normalWorld), 1.0);

	output.normal = normalWorld;
	output.flux = flux;

	return output;
}

////////////////Geometry Shader///////////////////////

struct VS_INJECTION_OUTPUT {
	float4 cellIndex : SV_POSITION;
	float3 normal : NORMAL;
	float3 flux : TEXCOORD0;
};

struct GS_INJECTION_OUTPUT {
	float4 screenPos : SV_Position;
	float3 normal : NORMAL;
	uint depthIndex : TEXCOORD1;
	float3 flux : TEXCOORD2;
};

cbuffer frustum : register(b0)
{
	float3 lpv_minCorner;
	float3 lpv_size;
	float2 flag1;
};

#define lpv_cellSize 3.0f

[maxvertexcount(1)]
void GS_gpuInjection(point VS_INJECTION_OUTPUT input[1], inout PointStream<GS_INJECTION_OUTPUT> OutputStream) {
	GS_INJECTION_OUTPUT output;

	output.depthIndex = input[0].cellIndex.z;
	output.screenPos.xy = (float2(input[0].cellIndex.xy) + 0.5) / lpv_size.xy * 2.0 - 1.0;
	// invert y direction because y points downwards in the viewport?
	output.screenPos.y = -output.screenPos.y;
	output.screenPos.zw = float2(0, 1);

	output.normal = input[0].normal;
	output.flux = input[0].flux;

	OutputStream.Append(output);
}

//////////////////////Pixel Shader/////////////////////////

struct PS_INJECTION_OUTPUT {
	float4 redSH;
	float4 greenSH;
	float4 blueSH;
};

struct GS_INJECTION_OUTPUT {
	float4 screenPos : SV_Position;
	float3 normal : NORMAL;
	uint depthIndex : TEXCOORD1;
	float3 flux : TEXCOORD2;
};


#define SH_cosLobe_c0 0.886226925f /* sqrt(pi)/2 */
#define SH_cosLobe_c1 1.02332671f /* sqrt(pi/3) */
#define Pi 3.1415926f


// helper function
float4 SH_evaluateCosineLobe(float3 direction) {
	direction = normalize(direction);
	return float4(SH_cosLobe_c0, -SH_cosLobe_c1 * direction.y, SH_cosLobe_c1 * direction.z, -SH_cosLobe_c1 * direction.x);
}


PS_INJECTION_OUTPUT PS_gpuInjection(GS_INJECTION_OUTPUT input) : SV_TARGET
{
	PS_INJECTION_OUTPUT output;

	if (length(input.normal) < 0.01) {
		discard;
	}

	// the SHcoeffs model an intensity function
	// thus the integral over all intensities (over the sphere) should be the original flux
	// and that integral = Pi * totalFlux, so divide by Pi
	float4 SHcoeffs = SH_evaluateCosineLobe(input.normal) / Pi;

	output.redSH = SHcoeffs * input.flux.r;
	output.greenSH = SHcoeffs * input.flux.g;
	output.blueSH = SHcoeffs * input.flux.b;


	return output;
}

[/SPOILER]

Edited by Nathan Drake

Share this post


Link to post
Share on other sites

I'm not sure about the error messages you're getting, but I'll go ahead and say some things I've noticed although they won't fix those.

The reason people draw a pointlist rather than a quad to sample the RSM is that the sampling needs to be done in the vertex shader in LPV, and if you want the whole NxN RSM to be sampled you need NxN vertices, while a quad has 4. You need to sample in the vertex shader, because you need the VPL position information in the geometry shader to decide in which cell of the grid to write. As in the 2D render targets, you can use SV_Position to decide the x and y you're writing to, but to pick the z of the grid, you need to write your cell's z (the actual integral index, not normalized to [0, 1], treating the 3D texture like an array of 2D textures) to SV_RenderTargetArrayIndex in the geometry shader, you wouldn't need the geometry shader at all if you didn't need to write to SV_RenderTargetArrayIndex actually.

Edited by tuccio

Share this post


Link to post
Share on other sites

before writing that code, i've done the same as what this blog did

but unfortunately it's completely empty, and i don't know what to do sad.png

 

 

Update: i thought maybe I'm doing the injection calculation in a wrong way but the problem is i can't write anything on my injection render targets at all (i also don't have any debugging error).

 

these are my steps of rendering :

1. Render RSM to Texture

2. Render Injection

3. Render Scene to Texture

4. Render RSM from texture at the bottom of the window

5. Render Scene from Texture

 

this is my latest Initialize and Rendering function for the injection part but everything looks correct:

 

InitializeInjection:

[SPOILER]

bool InitializeInjectionShader()
{
	HRESULT hresult;

	//attributes: WCHAR* vsFilename, WCHAR* gsFilename, WCHAR* psFilename
	std::vector<unsigned char> VSInjectionFile = ReadFile("Injection_VS.cso");
	hr = d3d11Device->CreateVertexShader(VSInjectionFile.data(), VSInjectionFile.size(), NULL, &injection_vertexShader);
	if (FAILED(hr))
	{
		return false;
	}

	std::vector<unsigned char> GSInjectionFile = ReadFile("Injection_GS.cso");
	hr = d3d11Device->CreateGeometryShader(GSInjectionFile.data(), GSInjectionFile.size(), NULL, &injection_geometryShader);
	if (FAILED(hr))
	{
		return false;
	}

	std::vector<unsigned char> PSInjectionFile = ReadFile("Injection_PS.cso");
	hr = d3d11Device->CreatePixelShader(PSInjectionFile.data(), PSInjectionFile.size(), NULL, &injection_pixelShader);
	if (FAILED(hr))
	{
		return false;
	}

    D3D11_TEXTURE2D_DESC texDesc;
    D3D11_RENDER_TARGET_VIEW_DESC RTVDesc;
    D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc;

    ZeroMemory(&texDesc, sizeof(texDesc));

    texDesc.Width = RT_Width;
    texDesc.Height = RT_Height;
    //texDesc.Depth = RT_Width;
    texDesc.MipLevels = 1;
    texDesc.ArraySize = 1;
    texDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
    texDesc.SampleDesc.Count = 1;
    texDesc.Usage = D3D11_USAGE_DEFAULT;
    texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
    texDesc.CPUAccessFlags = 0;
    texDesc.MiscFlags = 0;

    // Setup the description of the render target view.
    RTVDesc.Format = texDesc.Format;
    RTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
    RTVDesc.Texture2D.MipSlice = 0;

    // Setup the description of the shader resource view.
    SRVDesc.Format = texDesc.Format;
    SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    SRVDesc.Texture2D.MostDetailedMip = 0;
    SRVDesc.Texture2D.MipLevels = 1;

    for (int i = 0; i < Inj_Num; i++)
    {
        hresult = d3d11Device->CreateTexture2D(&texDesc, NULL, &Injection_Texture[i]);
        if (FAILED(hresult))
            return false;

        hresult = (d3d11Device->CreateRenderTargetView(Injection_Texture[i], &RTVDesc, &Injection_RTV[i]));
        if (FAILED(hresult))
            return false;

        hresult = (d3d11Device->CreateShaderResourceView(Injection_Texture[i], &SRVDesc, &Injection_SRV[i]));
        if (FAILED(hresult))
            return false;
    }

	//Describe our Depth/Stencil Buffer
	D3D11_TEXTURE2D_DESC depthStencilDesc;

	depthStencilDesc.Width = RT_Width;
	depthStencilDesc.Height = RT_Height;
	depthStencilDesc.MipLevels = 1;
	depthStencilDesc.ArraySize = 1;
	depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
	depthStencilDesc.SampleDesc.Count = 1;
	depthStencilDesc.SampleDesc.Quality = 0;
	depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
	depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
	depthStencilDesc.CPUAccessFlags = 0;
	depthStencilDesc.MiscFlags = 0;

	//Create the Depth/Stencil View
	d3d11Device->CreateTexture2D(&depthStencilDesc, NULL, &Injection_DSB);
	d3d11Device->CreateDepthStencilView(Injection_DSB, NULL, &Injection_DSV);

	D3D11_BUFFER_DESC cbbd2;
	ZeroMemory(&cbbd2, sizeof(D3D11_BUFFER_DESC));

	cbbd2.Usage = D3D11_USAGE_DEFAULT;
	cbbd2.ByteWidth = sizeof(Inj_cbPerFrame);
	cbbd2.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	cbbd2.CPUAccessFlags = 0;
	cbbd2.MiscFlags = 0;

	hr = d3d11Device->CreateBuffer(&cbbd2, NULL, &Inj_PerFrameBuffer);
	if (FAILED(hr))
	{
		return false;
	}

	return true;
}

[/SPOILER]

 

RenderInjection Function:

[SPOILER]

bool RenderInjection()
{
	GenerateFrustumVertices();

	//injBufferPerFrame.min = XMFLOAT3(XMVectorGetX(frustumMin), XMVectorGetY(frustumMin), XMVectorGetZ(frustumMin));
	//injBufferPerFrame.max = XMFLOAT3(XMVectorGetX(frustumMax), XMVectorGetY(frustumMax), XMVectorGetZ(frustumMax));
	injBufferPerFrame.min = XMFLOAT3(-1.0f, -1.0f, -1.0f);
	injBufferPerFrame.max = XMFLOAT3(1.0f, 1.0f, 1.0f);
	
	injBufferPerFrame.flag1 = XMFLOAT2(0.0f, 0.0f);
	d3d11DevCon->UpdateSubresource(Inj_PerFrameBuffer, 0, NULL, &injBufferPerFrame, 0, 0);
	d3d11DevCon->VSSetConstantBuffers(1, 1, &Inj_PerFrameBuffer);
	d3d11DevCon->GSSetConstantBuffers(1, 1, &Inj_PerFrameBuffer);

	float bgColor[4] = { (0.0f, 0.0f, 0.0f, 0.0f) };

	d3d11DevCon->OMSetRenderTargets(3, Injection_RTV, Injection_DSV);

	for (int i = 0; i < Inj_Num; i++)
		d3d11DevCon->ClearRenderTargetView(Injection_RTV[i], bgColor);


	d3d11DevCon->VSSetShader(injection_vertexShader, 0, 0);
	d3d11DevCon->GSSetShader(injection_geometryShader, 0, 0);
	d3d11DevCon->PSSetShader(injection_pixelShader, 0, 0);

	//Set the Viewport
	d3d11DevCon->RSSetViewports(1, &RT_viewport);

	d3d11DevCon->IASetInputLayout(nullptr);

	d3d11DevCon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	for (int i = 1; i < MRT_BUFFER_COUNT; i++)
		d3d11DevCon->VSSetShaderResources((i - 1), 1, &RT_shaderResourceView[i]);

	d3d11DevCon->Draw(RT_Width*RT_Height, 0);

	ID3D11ShaderResourceView* srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = { 0 };
	d3d11DevCon->VSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, srvs);
	d3d11DevCon->GSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, srvs);
	d3d11DevCon->PSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, srvs);

	ID3D11RenderTargetView* empty[3] = { NULL, NULL, NULL };
	d3d11DevCon->OMSetRenderTargets(3, empty, NULL);

	d3d11DevCon->OMSetRenderTargets(1, &renderTargetView, depthStencilView);

	return true;
}

[/SPOILER]

Edited by Nathan Drake

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement