hlsl

Passing colors through a pixel shader in HLSL

ぃ、小莉子 提交于 2019-12-10 14:35:37
问题 I have have a pixel shader that should simply pass the input color through, but instead I am getting a constant result. I think my syntax might be the problem. Here is the shader: struct PixelShaderInput { float3 color : COLOR; }; struct PixelShaderOutput { float4 color : SV_TARGET0; }; PixelShaderOutput main(PixelShaderInput input) { PixelShaderOutput output; output.color.rgba = float4(input.color, 1.0f); // input.color is 0.5, 0.5, 0.5; output is black // output.color.rgba = float4(0.5f, 0

3D Buffers in HLSL?

穿精又带淫゛_ 提交于 2019-12-08 12:26:52
问题 I wanna send a series of integers to HLSL in the form of a 3D array using unity. I've been trying to do this for a couple of days now, but without any gain. I tried to pack the buffers into each other ( StructuredBuffer<StructuredBuffer<StructuredBuffer<int>>> ), but it simply won't work. And I need to make this thing resizable, so I can't use arrays in struct s. What should I do? EDIT: To clarify a bit more what I am trying to do here, this is a medical program. When you go make a scan of

Specifying the target layer of a 3D rendertarget in vertex shader? [HLSL]

亡梦爱人 提交于 2019-12-07 14:47:52
问题 When working in HLSL/Directx11 I see there are two methods for binding a 3D rendertarget: either you bind the entire target or you bind it while specifying a layer. If you bind the entire target how does one specify the layer in HLSL code to which the output color is applied? I have a suspicion this requires a geometry shader ... is that correct? Is there any other approach which would allow this to be done in the vertex shader or elsewhere? 回答1: If you bind your whole volume texture (or

Shader's function parameters performance

我怕爱的太早我们不能终老 提交于 2019-12-07 02:05:28
问题 I'm trying to understand how passing parameters is implemented in shader languages. I've read several articles and documentation, but still I have some doubts. In particular I'm trying to understand the differences with a C++ function call, with a particular emphasis on performances. There are slightly differences between HSLS,Cg and GLSL but I guess the underline implementation is quite similar. What I've understood so far: Unless otherwise specified a function parameter is always passed by

Unity 3d Sprite Shader (How do I limit Max Brightness to 1 with Multiple Lights Hitting)

杀马特。学长 韩版系。学妹 提交于 2019-12-06 08:43:30
I am creating a videogame in Unity. Every sprite is rendered with a Sprite Renderer with a Material that has the CornucopiaShader.shader. The problem I have is I want to limit the max brightness (or color) of the sprite to just be a normal image of the sprite regardless of the power of how many point lights are hitting it, the intensity of the lights, and also the ambient light in the unity scene. When the intensity of the lights hitting the sprite is below that max brightness level I want it to act like a normal lit sprite and be black if no lights are hitting it, and be half lit up if an

Shader - Simple SSS lighting issue

故事扮演 提交于 2019-12-06 06:29:31
I am trying to create a simple subsurface scattering effect using a shader but I am facing a small issue. Look at those screenshots. The three images represents three lighting states (above surface, really close to surface, subsurface) with various lighting colors (red and blue) and always the same subsurface color (red). As you might notice when the light is above the surface and really close to this surface its influence appears to minimize which is the expected behavior. But the problem is that is behaves the same for the subsurface part, this is normal according to my shader code but in my

Some simple XNA/HLSL questions

岁酱吖の 提交于 2019-12-05 16:10:15
问题 I've been getting into HLSL programming lately and I'm very curious as to HOW some of the things I'm doing actually work. For example, I've got this very simple shader here that shades any teal colored pixels to a red-ish color. sampler2D mySampler; float4 MyPixelShader(float2 texCoords : TEXCOORD0): COLOR { float4 Color; Color = tex2D(mySampler, texCoords.xy); if(Color.r == 0 && Color.g == 1.0 && Color.b == 1.0) { Color.r = 1.0; Color.g = 0.5; Color.b = 0.5; } return Color; } technique

Shader's function parameters performance

只谈情不闲聊 提交于 2019-12-05 08:09:11
I'm trying to understand how passing parameters is implemented in shader languages. I've read several articles and documentation, but still I have some doubts. In particular I'm trying to understand the differences with a C++ function call, with a particular emphasis on performances. There are slightly differences between HSLS,Cg and GLSL but I guess the underline implementation is quite similar. What I've understood so far: Unless otherwise specified a function parameter is always passed by value (is this true even for matrix?) Passing by value in this context hasn't the same implications as

How can I feed compute shader results into vertex shader w/o using a vertex buffer?

霸气de小男生 提交于 2019-12-05 02:43:28
问题 Before I go into details I want outline the problem: I use RWStructuredBuffers to store the output of my compute shaders (CS). Since vertex and pixel shaders can’t read from RWStructuredBuffers, I map a StructuredBuffer onto the same slot (u0/t0) and (u4/t4): cbuffer cbWorld : register (b1) { float4x4 worldViewProj; int dummy; } struct VS_IN { float4 pos : POSITION; float4 col : COLOR; }; struct PS_IN { float4 pos : SV_POSITION; float4 col : COLOR; }; RWStructuredBuffer<float4>

2D Tile Lighting

寵の児 提交于 2019-12-05 00:35:34
问题 I'm adding lighting to my XNA 2D tile based game. I found this article useful, but the way its done it does not support collision. What I'd like is a method to do the following Have always lit point Collision (If the light ray hits a block, then dim the next block by whatever amount until its dark to simulate shadows) I've been searching around for quite a while but no luck (I did find Catalin's tutorial, but it seemed a bit advanced for me, and didn't apply to tiles well due to redrawing the