New answers tagged

1

You are sampling from the same location on the texture for every output, therefore the output is a single colour. See the documentation for SampleLevel A fix would look something like this: float2 uv = float2(dispatchThreadID.xy) / float2(textureWidthHeight); float4 test = gDiffuseMap.SampleLevel( samAnisotropic, uv, 0 );


0

Not 100% sure of what you are trying to draw where, but neither Z=0 nor Z=1 correspond to the location of the cube in world space. Both points, however, do define the ray shown below in red. You can run an intersection test between that ray and the cube's BoundingBox to determine the exact world coordinate of collision. "Depth", which you claim to not need, ...


6

I can't see anything fundamentally wrong with the shader, but here are a few things I find commonly done wrong with deferred shading that you might be doing. 1: Drawing full screen lights. The beauty of deferred shading is that you can pack your lights into geometry so that you only need to consider a part of the screen when drawing them (Like a cube with 2 ...


2

The primary thing that stands out is that your loop copy initializes the auto val loop variable with the elements as you iterate. Even though your type is reasonably small, there's a bunch of overhead in doing so and it's likely that you would gain some by going for auto& val. Of secondary concern is that you're using strings for non-textual things. ...


0

HLSL in Direc3D 11 has a feature called Class Instances, in which you can dynamically plug in what functionality should be used in a particular draw call. You keep the implementation in the shader file and query out the location via reflection. The instances are specified as an array to your SetShader call. The MSDN page that outlines this is Instances and ...


0

I have solved this same problem (need to render the same geometry with simpler shaders for shadow mapping) in 2 ways: Wrap shader code sections into #IFDEF directives, so that on compile time I could enable or disable them, thus constructing 2 shaders from single source. (I mostly use it to enable-disable effects on-the-fly) Copy-paste the shader code and ...


1

Picking is not generally performed by the GPU so the use of instancing shouldn't matter. Your CPU-side code presumably knew where the cubes where in order to put their transforms into the instance buffer. Hence it can do a ray-AABB test by transforming the picking ray into the space of the cube in the cube's local space. Happily, the local space for the ...


0

Computing vertex normals is a complex process as you need to have all incident faces available, and the ability to "split verts" when needed. This is not really something well suited to the Geometry Shader. Face normals do fit well with Geometry Shader because you only care about the primitive itself. Is there some reason you have to do this on the GPU? ...


0

That is my blur shader, it does a simple gaussian blur first in x direction. Then changing rendertarget to be the texture, and render in y direction to the final rendertarget. ////////////////////////// // OUTPUT struct VertexOut { float4 PosH : SV_POSITION; float2 Tex : TEXCOORD; }; ////////////////////////// // Screen Quad ...


2

There are different ways to do this. 1. Tessellation Do this with tessellation. That is exactly what tessellation was created for. You have to read a bit about it, but when you got it, thinks are going much easier. 2. Structured Buffer Instead of using the normal pipeline, you can bind the triangle mesh (vertices) as a structured buffer. Then you can ...



Top 50 recent answers are included