hlsl

HLSL branch avoidance

倾然丶 夕夏残阳落幕 提交于 2020-01-01 09:39:09
问题 I have a shader where I want to move half of the vertices in the vertex shader. I'm trying to decide the best way to do this from a performance standpoint, because we're dealing with well over 100,000 verts, so speed is critical. I've looked at 3 different methods: (pseudo-code, but enough to give you the idea. The <complex formula> I can't give out, but I can say that it involves a sin() function, as well as a function call (just returns a number, but still a function call), as well as a

FXC : error X3501: 'main': entrypoint not found

孤者浪人 提交于 2019-12-30 04:20:06
问题 I am following an example book called: Introduction to 3D Game Programming with DirectX 11 It is all written in VS2010. I would like to try using VS2013... It is an example project for Windows Desktop Program I have a program with the following in it (including some other files as part of common use): color.fx //*************************************************************************************** // color.fx by Frank Luna (C) 2011 All Rights Reserved. // // Transforms and colors geometry. /

How do I calculate pixel shader depth to render a circle drawn on a point sprite as a sphere that will intersect with other objects?

让人想犯罪 __ 提交于 2019-12-29 21:06:27
问题 I am writing a shader to render spheres on point sprites, by drawing shaded circles, and need to write a depth component as well as colour in order that spheres near each other will intersect correctly. I am using code similar to that written by Johna Holwerda: void PS_ShowDepth(VS_OUTPUT input, out float4 color: COLOR0,out float depth : DEPTH) { float dist = length (input.uv - float2 (0.5f, 0.5f)); //get the distance form the center of the point-sprite float alpha = saturate(sign (0.5f -

Storing two float values in a single float variable

徘徊边缘 提交于 2019-12-29 06:55:28
问题 I'd like to store two float values in a single 32 bit float variable. The encoding will happen in C# while the decoding is to be done in a HLSL shader. The best solution I've found so far is hard-wiring the offset of the decimal in the encoded values and storing them as integer and decimal of the "carrier" float: 123.456 -> 12.3 and 45.6 It can't handle negative values but that's ok. However I was wondering if there is a better way to do this. EDIT: A few more details about the task: I'm

Issue with progress bar shader in XNA

怎甘沉沦 提交于 2019-12-25 05:52:11
问题 I'm create a simple shader for drawing progress bar in XNA. Idea is simple: there are two textures and value and if X texture coord less then value use pixel from foreground texture, else use background texture. /* Variables */ texture BackgroundTexture; sampler2D BackgroundSampler = sampler_state { Texture = (BackgroundTexture); MagFilter = Point; MinFilter = Point; AddressU = Clamp; AddressV = Clamp; }; texture ForegroundTexture; sampler2D ForegroundSampler = sampler_state { Texture =

How do I discard pixels based on vertex color and turn that on or off in a MonoBehaviour?

白昼怎懂夜的黑 提交于 2019-12-24 19:05:32
问题 I've written a shader that uses a mesh's vertex colors and also has a function that clips all vertices that have an interpolated vertex color in the blue channel greater than 0.5 (discards all blue vertices). I'm trying to create a voice command that allows the user to call the function when they are ready. However, in Microsoft's Mixed Reality Toolkit Speech Input Handler, it only allows me to call functions from components (Mesh Renderer, Mesh Filter, Mesh Collider, etc.) of the GameObject

obtaining the tint color from a sprite batch, within a HLSL shader

淺唱寂寞╮ 提交于 2019-12-24 10:54:57
问题 How do I obtain the color tint from a sprite batch from within the HLSL shader? I'm working with xna. Also, what is the theory behind this? I would think that the tint color would just change the actual texture color before passing it to HLSL, but that does not seem to be the case. 回答1: You can look at the source code for the default SpriteBatch shader here. Look at SpriteEffect.fx for details. Specifically the tint colour is passed in COLOR0 to the vertex shader, which is then passed

HLSL Shader to Subtract Background Image

ⅰ亾dé卋堺 提交于 2019-12-24 03:58:08
问题 I am trying to get an HLSL Pixel Shader for Silverlight to work to subtract the background image from a video image. Can anyone suggest a more sophisticated algorithm than I am using because my algorithm isn't doing it correctly? float Tolerance : register(C1); SamplerState ImageSampler : register(S0); SamplerState BackgroundSampler : register(S1); struct VS_INPUT { float4 Position : POSITION; float4 Diffuse : COLOR0; float2 UV0 : TEXCOORD0; float2 UV1 : TEXCOORD1; }; struct VS_OUTPUT {

Can you look sample a texture in a vertex shader?

拟墨画扇 提交于 2019-12-24 02:13:10
问题 In shader model 3.0, I'm pretty sure this was a no but I want to ask this anyway, In shader model 5.0, can you sample a texture in a vertex shader? If I want to make large amounts of supplementary information available per-vertex, what are my options? Edit: Apparently it is possible to do a Vertex Texture Fetch, as done here, but when I try it in my hlsl shader model 5 program, I get the error error X4532: cannot map expression to vs_5_0 instruction set 回答1: Yes, sampling a texture from a

Drawing a SuperEllipse in HLSL

我是研究僧i 提交于 2019-12-23 20:13:06
问题 Update : answer on how to draw one using Superformula is at the end I need to draw a rounded rectangle such as this one, using a SuperEllipse. Drawing one when being able to plot wherever was easy : But in HLSL where you cannot, I got stuck on the condition for plotting or not a pixel : Here is the HLSL code : sampler2D input : register(s0); /// <summary>Explain the purpose of this variable.</summary> /// <minValue>0.0</minValue> /// <maxValue>10.0</maxValue> /// <defaultValue>4.0<