Hot answers tagged hlsl
Do they even serve any purpose at all? Yes for the user and developer of the shader, semantics conveys information about the intended use of a parameter. So you will know that POSITION is intended to be used as vertex position, NORMAL as vertex normal etc. Think of this as in-code documentation (not strictly the same though). Do semantics carry any ...
patchsize appears to describe the number of control points per patch, and seems to be largely ignored (as unnecessary) by the actual compiler. It's possible that at one point it was used as an optimization hint, but doesn't seem to have much practical use. All real-world examples I can find eschew the attribute. The fact that it appears to only be referred ...
You need to write: return float4(1.0f, 0.0f, 0.0f, 1.0f); The float4 is necessary to construct a vector. The way you've written it currently, the compiler is interpreting it as the comma operator. The result is that you only return the last element (the alpha component), which then gets replicated to all four components of the result.
As per Microsoft's reference: http://msdn.microsoft.com/en-us/library/bb313968(v=xnagamestudio.31).aspx dynamic does not exist as a valid attribute. In this case, the compiler should have emitted a warning, stating that the attribute was unrecognized.
I think phong smoothing is the easiest to implement and it is the most lightweight algorithm for this (as far as I know), though it may produce lower quality results. Implementing it is as easy as copy-pasting this code and applying it in your domain shader (that is if you already have tessellation working): struct ConstantOutputType //This is what the ...
Normally branches dependent on uniforms get handled by the driver. It is possible that a directX layer handles this even before the driver but it is not documented and pure speculation. I have noted using AMD drivers that changing a uniform to the point of that one branch will start to be taken, the first time this happens I can get a severe lockup of the ...
Just set DiffuseLightDirection to a constant unit vector. Don't try to add it to the object's position as you're doing now. This vector represents the direction the light is coming from, not the position of anything. So if it's constant, all the objects will be lit from the same direction.
Set the GraphicsDevice.Viewport property to a new Viewport struct with the values you want. Set X and Y offset, set Width and Height. All these values are in units of pixels, so the size of the target texture doesn't matter. Here is a simple code example. It uses separate cameras to accomplish different perspectives per viewport, but you don't need ...
Only top voted, non community-wiki answers of a minimum length are eligible