Game Development Community

Simple shader not working for me

by Alex Huck · in Torque 3D Beginner · 07/31/2010 (1:39 pm) · 1 replies

Hi, I'm trying to implement a shader that samples from a filter kernel.
But I found I've run into a problem simply trying to sample values from a float3x3

Here is a HLSL program I used to debug my method of getting values:

#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"

uniform sampler2D prepassSampler    : register(S0);
uniform sampler2D backBufferSampler : register(S1);

float3x3 filterKernel =
{// 0  1  2   
    0, 0, 0, // 0
    0, 1, 0, // 1
    0, 0, 0  // 2
};

float4 main( PFXVertToPix IN ) : COLOR0
{
    float3 color = 0;

    color.r = filterKernel[1][1];
	 
    return float4(color.rgb, 1);
}

The shader itself works, if I hard code color.r to 1.0, it will turn the screen red.

But the above code where I sample what I believe to be the center of the filterKernel
(X offset by 1 and Y offset by 1) doesn't set red to 1.

No shader compile errors, it just renders an unmodified backbuffer.

Am I sampling the float3x3 the wrong way? How should I get the values? I searched google and it seems doing it like filterKernel[1][1] is the right way, but it doesn't seem to be getting results.