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...

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...

Passing Boost uBLAS matrices to OpenGL shader

I'm writing an OpenGL program where I compute my own matrices and pass them to shaders. I want to use Boost's uBLAS library for the matrices, but I have little idea how to get a uBLAS matrix into OpenGL's shader uniform functions. matrix<GLfloat, column_major> projection(4, 4); // Fill matrix ... GLuint projectionU = glGetUniformLocat...

[WPF or other 3D tech] Light Map projection

Hi, What i'm trying to do is making a "light projector" with visible ray(like with fog) also called volumetric light; and which project a image (bitmap) ; Because i would like to keep this project connected with a wpf application ( to get brush, position, rotation from data), i've choose to use WPF 3D But it seem that WPF can't hand...

iPhone shader profiling

I'm using a series of shaders to perform realtime image processing on the iPhone (3GS/4/iPad). The fps isn't what I'd like it to be. Are there any tools that I can use to help me work out what the bottlenecks are? ...

Restrict the area that a WPF shader effect gets applied to

How can I restrict the area that a WPF shader effect gets applied to, in a similar manner to the way the obsolete BitmapEffectInput.AreaToApplyEffect used to work for BitmapEffects? Is there an equivalent property for shader effects, or do I have to add it myself within each and every shader effect that I'm writing? ...

question about switching shader programs (ES 2)

Hello guys, I'm trying to write a rather simple opengl es 2 program. I have two different shaders, one renders a solid color rectangle to the screen, the other one renders a texture mapped rectangle. I want to first draw the solid color rectangle, and then on top of it, draw the texture mapped rectangle. glUseProgram(program1); ...

Lookup table/palette shader on the iPhone

I have a fragment shader with the following: const lowp float colors[8] = float[8]( // line 12 0,0,0,1, 1,0,0,1 ); but it fails to compile: ERROR: 0:12: 'array of float' : array type not supported here in glsl < 120 ERROR: 0:12: 'array of float' : constructor not supported for type ERROR: 0:15: 'array of float' : no matchin...

What are the possible reasons for textures not appearing in GLSL?

I was learning about how to use textures with GLSL (in LWJGL) to create a simple fragment shader that blurs a texture. The first attempt (for testing purposes) was a very simple shader which just takes the original color values: uniform sampler2D rectTexture; void main(){ vec4 color = texture2D(rectTexture, gl_FragCoord.st); gl_Fra...

How can I repeat a 3x9 texture in OpenGL's GLSL?

I have a texture with a 3x9 repeating section. I don't want to store the tesselated 1920x1080 image that I have for the texture, I'd much rather generate it in code so that it can be applied correctly at other resolutions. Any ideas on how I can do this? The original texture is here: http://img684.imageshack.us/img684/6282/matte1.png I ...

Setting a Texture in a shader's constant buffer in D3D10

Ok I have a shader compiled up under D3D10. I am obtaining a shader reflection to get details of all the constants/globals in the shader. However I'm a little confused on something ... how do I set a texture to a constant buffer? I assume I don't just Map the constant buffer and copy the ID3D10Texture pointer into it ... I assume I us...

Learning OpenGL ES 2.0, Coming From 2D

My new job has me moving from a 2D graphics environment (old job) to a 3D environment using OpenGL ES 2.0. I'm looking for hints, book suggestions, awesome tutorials, and possible test environments or OpenGL ES 2.0 emulators to help me make the jump. I have basic familiarity with OpenGL ES 1.X's fixed function pipeline, but I'm complete...

How can I combine texture and color in COLLADA diffuse element?

I need to composite texture with alpha channel, and a color, and put the result into COLLADA's diffuse element. How can I do this in profile_COMMON? ...

How do you perform OpenGL ES 2.0 shader matrix multiplication?

I'm trying to transform vertices with a shader program, but i can't understand the results. I prepared a projection, a view(trans), and model(trans) matrices: First i have a vertex shader function of: viewproj * position. In a Objective-C program i start with identity multiplicated by a translation and projection matrices and then unifo...

C++ & DirectX - setting shader

Hello! Does someone know a fast way to invoke shader processing via DirectX? Right now I'm setting shaders using D3DXCreateEffectFromFile calls, which create shaders in runtime (once per each shader) from *.fx files. Rendering part for every object (every patch in my case - see further) then means something like: // -----------------...

in GLSL under OpenGL ES 2, how can I write a shader that operates on the previous output

I need a shader that starts with a given texture, then each frame of animation operates on the previous output of the shader plus other input. How do I organize the framebuffers so that each frame has access to the output of the previous frame without having to move the buffer back and forth from the CPU? ...

Photoshop PhotoFilter pixel Math

Has anyone used the photo filter in Photoshop? Edit > Adjustments > Photo Filter... It produces a really nice image tint that I've been unable to reproduce with blending modes. Has anyone got any idea of the pixel maths behind this filter? - So I can build a shader based on it. It seems to basically be a luminosity preserving colour ti...

OpenGL 4.x learning resources

I know there are some question about learning OpenGL. The difference is that I want to learn OpenGL 4.0 Core profile (no immediate functions). Preferably with good portion of SL knowledge. And I do not wont to start form previous OpenGLs. Nor I want to read NeHe. And I do have math and bit of 3d knowledge to understand OpenGL 4.0 I p...

Restricting Pixel shader on particular area of image

Hello, Is there any way to restrict Pixel shader on particular area of image. BR ...