Encoding Floats to RGBA and Blending causing artifacts
I am using float packing to encode a float value inside a RGBA texture because I don’t have access to float texture unfortunately. Here are the function I am using for encoding and decoding. inline...
View ArticleHow can I add sphere falloff to my specular lighting implementation?
I’m using point light in my game and tried to add specular lighting. It looks good but when standing close to wall player can clearly see where lights end. Image from front: Image when near wall: I...
View ArticleCompiling a shader with fxc results in invalid ps_5_0 output semantic 'COLOR0'
I’m attempting to compile a shader at the command prompt. What am I doing wrong that would make it generate this error? fxc /Od /Zi /T ps_5_0 /E "ps_main" /Fo "basic.pso" "basic.ps" Here is the pixel...
View ArticleHLSL – Binary operations
I’m trying to do binary operations with integers in the hlsl code. For example: int n = 10 & 15; Binary value of 10 = 1010 and Binary value of 15 = 1111. With this, n = 10, because (1010 &...
View ArticleIn XNA 4, how can I access SpriteBatch's transformMatrix in my shader?
I would like to use a custom effect with a regular XNA SpriteBatch. I have a 2D camera which computes a transform matrix, so I need my shader to take this into account. I have put a world matrix...
View ArticleVertex definitions and shaders [closed]
I noticed that from looking at other examples like say .. riemers tutorials he takes a buffer with a bunch of vector3′s in it and ties it to a shader which expects a float4 … why does this work in his...
View Article“_SRGB” suffix for BC texture format doesn't result in sRGB-to-linear...
I am working on a 3D engine as a hobby (Direct3D 11). Currently I am trying to implement sRGB -> linear -> sRGB color space conversions via texture formats with “_SRGB” suffix. So, my textures...
View ArticleWhat will happen if the argument of mix() or clamp() is above 1 or below 0?
There’s two magnificent intrisincs: mix() in GLSL and clamp() in HLSL, which are used to implement linear interpolation. Let’s say we have a variable: float v = ?; // where ? can be [-FLOAT_MAX,...
View ArticleBlending Lightmaps and Dynamic Texture Shadows in HLSL
I’m using Gile[s] as my lightmapper and my engine can execute HLSL scripts with DirectX 9. I would like to accomplish something like this for performance reasons. I was told that this technique can...
View ArticleTransparency using HLSL in XNA
I currently working on Depth Data on Kinect SDK v1.8 on XNA and I wanna show an Image Inside the Depth view of Human body. the image below is just an example of what I wanna do :...
View ArticleHow is this particular HLSL condition treated with respect to compile- or...
Let’s say I have this very simple pixel shader (cbuffers and other stuff omitted) float4 PS(VertexOut pin, uniform bool useLighting) : SV_Target { float4 retColor = gDiffuseMap.Sample( sampler0,...
View ArticleCan someone explain to me how setting shader parameters aren't a bottleneck?
I am trying to understand this. So I have a bunch of models that need to be rendered. Each model most likely has various “sub meshes” with their own diffuse, specular, etc textures. So for each of...
View ArticleGeometry shader: Dynamic output?
I’m currently using a geometry shader to generate grass blades out of single root points that are layed out in a grid. For each root point, I generate a grass blade with, right now, a constant number...
View ArticleVery subtle HLSL syntax change causes compliation error
The following HLSL works and compiles: texture2D renderTarget; float h; // declared here sampler GetRenderTarget = sampler_state { texture = <renderTarget>; }; float3 GetHsvFromRgb(float3 c) {...
View ArticleDirectX Compute shader (HLSL) makes texture black
Hello this is my first question on this forum When using compute shader in directx to change the color to blue the texture only gets black. I really don’t understand what the problem could be and I...
View ArticleEncoding Float to RG/RGBA and Blending
Encoding a float value inside a RG or RGBA texture is very interesting and useful but it is also become quite useless when you use blending as the result and the values might be altered because of face...
View ArticleHow to diagnose the problem when the input assembler and the vertex shader...
I’m porting some OpenGL code to Direct X 11. I ended up with nothing being drawn on the screen. I reverted to a simple program, which I am writing about here. I’m now trying to use the Graphics Tools...
View ArticleMulti-textured terrain XNA-monogame
I’m developing a TerrainEngine for my project and I have some issues with the multi-texturing part. I already tried some techniques but it doesn’t match with my TerrainEngine’s conception. My...
View ArticleMultisampled Nearest Filtering in PS 2.0 is it possible?
My game involves blocky, pixelated 3D textures. When using nearest neighbor filtering with a texture sampler, I get the desired result of nicely pixelated textures — with the caveat that hard lines...
View ArticleHow can I test if one point can “see” another point. (XNA)
I want to test if my enemy can see the player, however I want this to be pixel-perfect. I already have all of the solid objects drawing into a separate render state. It should be noted that every solid...
View Article