cull/clip distance example

 

http://www.gamedev.net/topic/578866-d3d10-how-to-increase-maxcount-of-sv_clipdistance/

The D3D#_CLIP_OR_CULL_DISTANCE_* values are #defines in the d3d11.h header file. For distance count the value is 8 and for element count the value is 2. This means you can have any number of clip or cull values provide that their sum is 8 or less and that they must be fit into 2 vec4 registers.
 
In D3D10+ you have to code the math yourself in the shader to put the vertex through the plane equation and then store the resulting distance value in one of the registers. Values greater than or equal to zero should not be clipped/culled. The values you provide will be interpolated so that each pixel is clipped appropriately.
 
Here is an example, using just cull distance.
 

cbuffer ClipPlanes

{

        float4 planes[6];

};

 

struct VS_OUT

{

        float4 pos : SV_Position;

        float4 clips[2] : SV_CullDistance;

};

 

VS_OUT vsmain( float4 pos : SV_Position )

{

        VS_OUT vsout = (VS_OUT)0;

        vsout.pos = pos;

 

        for( uint i = 0; i < planes.Length; ++i )

        {

                ((float[8])vsout.clips)[i] = dot( planes[i].xyz, pos.xyz  ) - planes[i].w;

        }

 

        return vsout;

}

时间: 2024-09-23 20:09:30

cull/clip distance example的相关文章

A trip through the Graphics Pipeline 2011_10_Geometry Shaders

Welcome back. Last time, we dove into bottom end of the pixel pipeline. This time, we’ll switch back to the middle of the pipeline to look at what is probably the most visible addition that came with D3D10: Geometry Shaders. But first, some more word

Robot Operating System (ROS)学习笔记2---使用smartcar进行仿真

搭建环境:XMWare  Ubuntu14.04  ROS(indigo) 转载自古月居  转载连接:http://www.guyuehome.com/248 一.模型完善 文件夹urdf下,创建gazebo.urdf.xacro.smartcar.urdf.xacro.smartcar_body.urdf.xacro三个文件 1.机器人主体smartcar_body.urdf.xacro文件 1 <?xml version="1.0"?> 2 <robot name

ros下单目相机校正

1. 安装相应的驱动与程序包. 图像相应包   http://wiki.ros.org/camera_calibration          在gitbub下载image_pipeline :      https://github.com/ros-perception/image_pipeline 安装相应的驱动 1)uvc_camera          ktossell/camera_umd                   sudo apt-get install ros-indig

D3D HLSL 一段代码注释

// FixedFuncEMU.fx// Copyright (c) 2005 Microsoft Corporation. All rights reserved.// struct VSSceneIn{ float3 pos : POSITION; //position of the particle float3 norm : NORMAL; //velocity of the particle float2 tex : TEXTURE0; //tex coords}; struct VS

461.求两个数字转成二进制后的“汉明距离” Hamming Distance

public class Solution { public int HammingDistance(int x, int y) { int distance = 0; string sX = Convert.ToString(x, 2); string sY = Convert.ToString(y, 2); int maxLength = Math.Max(sX.Length, sY.Length); //填充0,使两个字符串右对齐 sX = sX.PadLeft(maxLength, '0

LeetCode 72 Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: a) Insert a character b) Delete a character c) Repla

numpy.clip(a, a_min, a_max, out=None)(values &lt; a_min are replaced with a_min, and those &gt; a_max with a_max.)

numpy.clip(a, a_min, a_max, out=None) Clip (limit) the values in an array. Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and value

461. Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note:0 ≤ x, y < 2^31. Example: Input: x = 1, y = 4 Output: 2 Explanation:

搬土距离(Earth Mover&#39;s Distance)

搬土距离(The Earth Mover's Distance,EMD)最早由Y. Rubner在1999年的文章<A Metric for Distributions with Applications to Image Databases>中提出,它是归一化的从一个分布变为另一个分布的最小代价,因此可用于表征两个分布之间的距离. 例如,对于图像而言,它可以看做是由色调.饱和度.亮度三个分量组成,每个分量的直方图就是一个分布.不同的图像对应的直方图不同,因此图像之间的距离可以用直方图的距离表