I'm new to pixel shaders, and I'm trying to apply an underwater-effect to my 3d scene. I can apply it to an image and animate it easily enough, but not to my ViewPort3D. The computer just hangs when calling BeginAnimation on the effect being applied to the Viewport3D. Is this something that cannot be done in WPF?
After a little digging I learned that pixel shaders are only applied to 2 dimensional types, like images. So what I would need is called a vertex shader, which for WPF, there are none.
Related
Lets say I have a simple WPF canvas where I draw a few buttons and shapes using xaml. I would like to render the canvas to a direct3d texture so I can have access to the pixels from within the GPU.
RenderTargetBitmap allows me to do software rendering. but this will be limiting in terms of performance as I will have to manually copy the pixels to where I want.
I also looked into using a custom shader effect on the canvas. but as far as I know it is impossible to write to a separate texture using direct3d 9.
So is it at all possible? if so how?
Is it possible to implement per-pixel-lighting in WPF 3d application (C#) by using their shader effects?
I have a basic 3d application running in WPF but it only shows Gouraud Shading, by interpolating shaded colour values between vertices to the inner of the polygons. I tried to implement a per-pixel lighting approach, like Phong, but I realize that I do not seem to have access to interpolated normals in the WPF pixel shader effects.
Is this the limitation of WPF, where one should better go with C++ and OpenGL/DirectX directly?
as far as I know, yes it is a WPF limitation...contrary to the OpenGL where you can do per-pixel shading, the WPF only allows you to work on a meshGeometry.
I think a way to go with it, would be to create textures that contains your shader effect, and then apply it per triangle.
This would take a longer amount of computation time, but should work.
Regards
I'm a beginner to OpenGL and I'd like a simple introduction to using textures. For my application, I have no need of geometry, just some texture manipulation. I want to be able to scale, rotate, and translate textures, blend textures together (mixing R,G,B components), and display textures on the screen. If you could also tell me how to draw a solid filled rectangle, that would be good.
I'm also fuzzy on shaders. Could I use GLSL to transform the color at every point on a texture by a formula?
Examples or explanations in C would be preferred.
You have asked a lot of questions...
If you want to play with textures and do some 2d effects here is a little pseudocode that could help:
render() {
glClear(...)
glUseProgram(shader_program);
bind_textures();
setup_shader_params();
draw_fullscreen_quad();
glUseProgram(0);
// rest of opengl...
}
read more on:
http://www.arcsynthesis.org/gltut/Basics/Tut01%20Following%20the%20Data.html
What's the best way to draw a fullscreen quad in OpenGL 3.2?
I am doing some game-related rendering with Silverlight, and when I attach a pixel shader to an image that has a (rotational) transformation, I am seeing a strange, fuzzy, pixelation effect.
Here is a screenshot of the problem. The image on the left has just a transformation. The image on the right has a transformation and a pixel shader.
(source: andrewrussell.net)
You can see this in action here on my blog (click the Silverlight control to add the pixel shader).
The pixel shader in question is the one from SilverSprite used to tint an image's colour. You can view its source code here.
The transformation I am applying is a MatrixTransform (with a hand-calculated translate, scale, rotate matrix). The problem appears when rotating the image.
The element that both the shader and the transform are being applied to is an Image that is added to a Canvas in code. The Image's ImageSource is a WriteableBitmap but the effect also happens with a BitmapImage.
My question is: what is causing this fuzzy pixelation? and what can be done to reduce or remove it?
After watching this presentation from PDC09, I have a much better idea of how the rendering system in Silverlight works. This problem isn't directly addressed by the presentation, but knowing the rendering order of things helps.
The order of the rendering steps relevant to my question is: An object's children (and/or itself) are rendered, that rendering passes through the Effect and then passes through the RenderTransform.
It appears that in any case where a RenderTransform is applied to an object where that object or its children have had an Effect applied (ie: a RenderTransform that comes after an Effect in the rendering tree), that RenderTransform is done in a "low quality" mode that produces this "fuzzyness".
The solution, then, is to move the Effect to after the RenderTransform. In my case this means putting the Image on its own Canvas, applying the RenderTransform to the Image, and the Effect to the Canvas.
I would like to display textures in different colors pretty much having this texture.
How do I do this in Silverlight?
Thanks!
alt text http://a.imageshack.us/img535/5255/leathertexture.png
Turn your texture into alpha textue. Exact steps will depend on your image manipulation software. After that simply place your texture on top of colored rectangle.
You could make pixel shader for even better result, but that would be an overkill in your case.