Jump to content

  • Log In with Google      Sign In   
  • Create Account

lwm

Member Since 29 Sep 2011
Offline Last Active Yesterday, 08:36 AM

Posts I've Made

In Topic: Best way to handle multiple lights

05 May 2016 - 01:57 PM

2 -Upload an array of lights into a single shader, and do a single draw of the mesh looping over the lights each frame


A modern variation on this would be tiled forward rendering or "Forward+", where you iterate over a list of lights per screen tile instead of per mesh.


In Topic: Is it C# Territory?

05 May 2016 - 01:39 PM

- Save time by going with C#

- Use saved time for pushing compute-heavy algorithms to GPU instead

 

This is exactly what is happening at my job currently (MRI scanner). Most of the user-facing code is moving from C++ to C#. More and more of the high-performance code is moving from C++ to CUDA and the likes.


In Topic: structs, semantics, vs_input and vs_output questions

17 February 2016 - 12:56 PM

From DirectX's point of view, the vertex and pixel shaders are completely independent. The only information DX uses to send data from one pipeline stage to the next are the semantics. Whatever your vertex shader writes to the variable with the TEXCOORD0 semantic will be linearly interpolated across the triangle by the rasterizer and sent to the pixel shader input variable with the same semantic.

 

Most people [citation needed] will simply reuse the code for the struct for both the VS output and PS input however.


In Topic: structs, semantics, vs_input and vs_output questions

17 February 2016 - 02:52 AM

The input and output structs don't have to be identical. The input semantics specify the fields you want to read from the vertex buffers per vertex. Most of the time, there is a field that represents the positions of a vertex, but this is not required. The input can also be a subset of the fields in your model's vertices or even empty if you only need system-generated values.

 

The output specifies the fields that are sent to the rasterizer. Here you are actually required to provide a field with the position semantic, so that the rasterizer knows what the triangles you want to draw look like. You can also output additional values from the vertex shader. For example, you might want to calculate the output-vertices' texture coordinates from the input-vertices' position.

 

Assume that you want to draw a terrain mesh, deform it using a height map and generate a color for each vertex based on its height:

struct VS_INPUT 
{
	float3 positionModelSpace : POSITION;
	float2 textureCoordinate : TEXCOORD0;
};

struct VS_OUTPUT 
{
	float4 positionProjSpace : POSITION;
	float4 color : COLOR0;
};

float4x4 gWorldMatrix;
float4x4 gViewMatrix;
float4x4 gProjectionMatrix;

VS_OUTPUT vs_main ( VS_INPUT Input )
{
	VS_OUTPUT Output;
	
	float4 positionWorldSpace = mul(Input.positionModelSpace, gWorldMatrix);
	
	float height = get_height_from_texture(Input.textureCoordinate);
	positionWorldSpace.y += height;
	
	Output.color = get_color_from_height(height);

	float4 positionViewSpace = mul(positionWorldSpace, gViewMatrix);
	Output.positionProjSpace = mul(positionViewSpace, gProjectionMatrix);

	return Output;
}

In Topic: 3D Grass and Depth Problem

27 January 2016 - 12:05 PM

You can do this by setting the Depth-Stencil-State to

DepthEnable = true

DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO


PARTNERS