After some big refactoring made in Gine, I started to play with shaders.
It's not my first time of course, but I'm trying to standarize fx file loading and usage. Another time - make it user friendly.
My first goal was to make a very simple greyscale post-processing effect. Now it looks like that:
Supersimple pixel shader goes like:
Notice the usage of a gTransition float. Yeah! I made smoot transitions as well and I must say it looks exactly as it should ;)
The next step was to blur the background at a pause stage:
The thing was tricky - Gaussian blur needs two passes to work in an optimal way. So after adding a backbuffer render target view, I had to add another and swap them in meantime. Geez, it's so unnecessarily complicated at that level.
I'm happy that main rendering loop looks like that:
And when you want to enable or disable the effect:
Showing posts with label shader. Show all posts
Showing posts with label shader. Show all posts
Sunday, September 22, 2013
Monday, March 18, 2013
Instancing and a bit of shader play
I sat down and started to refactor my code for serious. FPS rate was still silly low, but the code looked ok. I've implement instancing and saw that it accelerated draw function by 4-5 times, also frustum culling lowers the drawing time at average 4 times. It was really ok, but still...
Consider following shader code:
What will happen in 28 and 29th line?
I'm setting a value for gRenderedPointLights to 7, so it will be logical if this loop unrolls and just copy its code 7 times with different i values.
HLSL attributes are very sensitive. I don't know why, but in that case the loop unrolled circa 50 times, removing the [unroll] attribute solves the problem. Now rendering time jumped like +100FPS.
Victory...
Consider following shader code:
What will happen in 28 and 29th line?
I'm setting a value for gRenderedPointLights to 7, so it will be logical if this loop unrolls and just copy its code 7 times with different i values.
HLSL attributes are very sensitive. I don't know why, but in that case the loop unrolled circa 50 times, removing the [unroll] attribute solves the problem. Now rendering time jumped like +100FPS.
Victory...
Labels:
attribute,
fps,
frustum culling,
hlsl,
instancing,
rendering,
shader,
unroll
Subscribe to:
Posts (Atom)