• Create Account

# Meltac

Member Since 29 Mar 2012
Offline Last Active Today, 07:16 AM

### [DX9] Execute pixel shader branch on every N-th frame

11 January 2014 - 07:56 AM

Goodday!

I have a post-process pixel shader being executed by the given game engine (X-Ray 1.0, but that's not topic here). I want to split the shader into two different branches where each of them is called alternatingly upon every second frame. The engine passes a timer value to the shader, but that's about all.

So is it possible to either measure the current FPS rate and calculate by the given timer value when one or the other branch has to be executed, or even to configure the shader somehow that it conditionally executes a specific function (or branch) only on every N-th frame?

### calculate world space position by view space and camera position

18 October 2013 - 01:14 AM

Hi!

I need help with some probably fairly math. In my DX9 pixel shader I've got

1. The screen space uv-position/coordinate of a certain pixel

2. The view space position of that pixel (sampled through position sampler state)

3. The world space position of the camera/eye

4. The direction of the camera/eye

Now I need formulas for to

1. Calculate the world space position of that given pixel

2. The opposite, i.e. calculate the screen space uv-coordinate of an other pixel whose world position I have.

How would I do those calculations in the HLSL pixel shader?

### Get DX10 Texture object from classic DX9 sampler

28 February 2013 - 08:25 AM

Hi all

In DX10/11 the sampler and texture objects have been separated, whereas in DX9 there was only one object for both.

Meaning, the Sample() and Gather() functions in HLSL require an object of type Texture which I do not have with a "classic" DX9 sampler2D object.

So is there a way to access the Texture object of a DX9 sampler2D object when compiling against DX10 / ps_4_0 or ps_5_0?

I'm talking pure HLSL here, so please no hints in C++ or C#.

### Speed up loop, texture lookup, and array processing in pixel shader / post process (HLS...

13 November 2012 - 07:20 AM

Hi everybody

There are many situations were I need to process an array / grid / matrix of pixels in a loop in a post process, mostly for calculating some mean or maximum value or a gradient of a certain set of adjacent pixels. Examples:

• Gaussian blur filter
• Calculating mean luminance of a specific area on the screen
• Getting pixel nearest to the viewer within a certain range
• Checking if at least one pixel of a 2-dimensional array (rectangle) of pixels meets a certain condition
• etc.

All these applications are typically processed in a 2-dimensional for-loop iterating through the x- and y-axis (rows and columns) of the specified grid, where each iteration makes at least one texture lookup. Therefor they cause heavy GPU load as soon as their dimensions exceed a certain limit, making FPS drop dramatically in many situations.

So, are there strategies to speedup execution times immensely to overcome this limitations? I've already tried these:

But that's way not enough to make my shaders run well. Are there any better approaches, or maybe some special DX10/11 instructions being of help here?

### Make rain splash effect (pixel shader only)

12 September 2012 - 02:43 AM

Hello guys

I've made a fake wet surface pixel shader (HLSL/SM5) which I want to animate with an effect of rain falling onto the totally wet ground.

The wet look is generated by manipulating the respective pixels' color and gloss and adding some reflected sky color. I'm distorting the effect with a slight sin wave in order to simulate a little flow / wave effect on the wet surface. That looks fine when it doesn't rain anymore but the ground is still wet.

Now I like add more distortion to generate a look of rain splashing onto/into my puddles on the ground. I already have nice little rain ripples, so that's not the issue.

The problem is rather that I'm not sure what distortion logic / mechanism / formula to apply to make the water distortion by the rain splashes look authentic. Just increasing the amplitude and/or frequency of my sin distortion doesn't look realistic. I guess the water surface distortion when rain falls into a puddle behaves different, not like wind blowing over the surface making waves (what could be achieved by sin distortion).

Any ideas how I would be able to produce a half-authentic looking effect here?

PARTNERS