hlsl

How would I write an HLSL bevel shader for Silverlight?

I know that Silverlight doesn't directly support the WPF bitmap effects, but I also know that Silverlight 3 supports HLSL shaders. Would it be relatively simple to write a bevel effect, ilke the one in WPF, and if so, can somebody recommend a good resource to learn how to do it? ...

Format of compiled directx9 shader files?

Is the format of compiled pixel and vertex shader object files as produced by fxc.exe documented anywhere either officially or unofficially? I'd like to be able to read the constant name to register assignments from the shader files. I know that the effects framework in D3DX can do this, but I need to avoid using D3DX as it may not be i...

HLSL tex2d sampler seemingly using inconsistent rounding; why?

Hello all, I have code that needs to render regions of my object differently depending on their location. I am trying to use a colour map to define these regions. The problem is when I sample from my colour map, I get collisions. Ie, two regions with different colours in the colourmap get the same value returned from the sampler. I've...

Offloading to HLSL/GPU without displaying?

As far as I know, certain mathematical functions like FFTs and perlin noise, etc. can be much faster when done on the GPU as a pixel shader. My question is, if I wanted to exploit this to calculate results and stream to bitmaps, could I do it without needing to actually display it in Silverlight or something? More specifically, I was th...

Is there any kind of HLSL or HYDRA Pixel Shader languages for JAVA?

Is there any kind of HLSL or HYDRA Pixel Shader languages vorking in toch with for JAVA? So I have an image. I want to use some Pixel Shader language to modify it as I do in Flash with HYDRA or HLSL with C# (in bouth cases I have precompiled shader). So how to use HYDRA or HLSL or any thing else for developing CROSSPLATFORM (win mac lin...

HLSL - How can I set sampler Min/Mag/Mip filters to disable all filtering/anti-aliasing?

I have a tex2D sampler I want to only return precisely those colours that are present on my texture. I am using Shader Model 3, so cannot use load. In the event of a texel overlapping multiple colours, I want it to pick one and have the whole texel be that colour. I think to do this I want to disable mipmapping, or at least trilinear...

Problem with compiling any HLSL effect

Hello. My code is: FileStream fs = new FileStream("ImageProcessing.fx", FileMode.Open,FileAccess.Read); CompiledEffect compiledEffect = Effect.CompileEffectFromFile(fs, null, null, CompilerOptions.None, TargetPlatform.Windows); fs.Close(); effect = new Effect(graphics.GraphicsDevice, compiledEffect.GetEffectCode...

HLSL, Program pixel shader with different Texture2D downscaling algorithms

I'm trying to port some image interpolation algorithms into HLSL code, for now i got: float2 texSize; float scale; int method; sampler TextureSampler : register(s0); float4 PixelShader(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0 { float2 newTexSize = texSize * scale; float4 tex2; if(texCoord[0] * texSize[0] > ...

Loading just a part of a texture in DirectX?

If I have a texture file how would I be able to load up only a part of it using a defined rect (top, left, bottom, right)? Is it technically possibly to only read in the parts I want to load while leaving the rest of the texture untouched? ...

Issues with HLSL and lighting

I am trying figure out whats going on with my HLSL code but I have no way of debugging it cause C++ gives off no errors. The application just closes when I run it. I am trying to add lighting to a 3d plane I made. below is my HLSL. The problem consist when my Pixel shader method returns the struct "outColor" . If I change the return valu...

HLSL How can one pass data between shaders / read existing colour value?

Hello all, I have 2 HLSL ps2.0 shaders. Simplified, they are: Shader 1 Reads texture Outputs colour value based on this texture Shader 2 Problem: Need to read in the colour from Shader 1 Outputs the final colour which is a function of the input colour (They need to be different shaders as I've reached the maximum vertex-shader ...

HLSL: Enforce Constant Register Limit at Compile Time

In HLSL, is there any way to limit the number of constant registers that the compiler uses? Specifically, if I have something like: float4 foobar[300]; In a vs_2_0 vertex shader, the compiler will merrily generate the effect with more than 256 constant registers. But a 2.0 vertex shader is only guaranteed to have access to 256 consta...

HLSL: Index to unaligned/packed floats

I have a vertex shader (2.0) doing some instancing - each vertex specifies an index into an array. If I have an array like this: float instanceData[100]; The compiler allocates it 100 constant registers. Each constant register is a float4, so it's allocating 4 times as much space as is needed. I need a way to make it allocate just 2...

Build config file into executable?

I am currently working on a little graphics demo (using DirectX) which is primarily based around an HLSL shader I am working on. Using the D3DX10CreateEffectFromFile I am loading (and compiling the shader) at runtime as I find it easier for tweaking. However, once I am done I'd like to do some combination of the following: Pre-compil...

How can I encode four unsigned bytes (0-255) to a float and back again using HLSL?

Hello! I am facing a task where one of my hlsl shaders require multiple texture lookups per pixel. My 2d textures are fixed to 256*256, so two bytes should be sufficient to address any given texel given this constraint. My idea is then to put two xy-coordinates in each float, giving me eight xy-coordinates in pixel space when packed in ...

Issues passing values to shader

I am having issues passing values to my shader. My application compiles fine, but my cube object won't shade. Below is majority of my code. Most of my code for communicating with my shader is in createObject method myGame.cpp #include "MyGame.h" #include "OneColorCube.h" /* This code sets a projection and shows a turning cube. What ha...

How do I send information to an HLSL effect in DirectX 10?

I'd like to send my view vector to an ID3D10Effect variable in order to calculate specular lighting. How do I send a vector or even just scalar values to the HLSL from the running DirectX program? I want to do something like render() { //do transformations D3DXMatrix view = camera->getViewMatrix(); basicEffect.setVariable(viewV...

SetMatrix() does not copy all values to HLSL

Hi, I want to use the contents of a vector of D3DXMatrices to my shader. m_pLightMatrices->SetMatrixArray(&currentLightMatrices[0].m[0][0],0,numLights); As we know the internals of a vector this poses no problems (as it is just a dynamic array). Now when I access this matrix in hlsl to fill up a struct I get this strange behavior: ...

Efficient pixel shader sum of all pixels

How can I efficiently calculate the sum of all pixels in an image, by using a HSLS pixel shader? I'm interested in Pixel Shader 2.0, that I could invoke as a WPF shader effect. ...

How could I implement a bleach bypass shader effect for WPF?

How could I implement a bleach bypass shader effect for WPF? I'm also interested in the possibility of implementing the first two Tehnicolor Film Processes, or any variety that would result in an old film look. ...