Jump to content
  • Advertisement

ThorOdinson

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

100 Neutral

About ThorOdinson

  • Rank
    Newbie
  1. ThorOdinson

    Bloom HLSL Pixel shader help

    or can anyone suggest where i can find a good bloom example other than the DirectX SDK?
  2. hey i've been trying to get bloom to work, i've looked at the NVidia and directX examples trying to find out how to create the effect, i found .fx examples and tried to convert it to .ps but it doesn't seem to load any help or suggestion on how to get this code to work would greatly be appreciated /********************************************** PP_Bloom.psh Post-processing pixel shader that spins an area in a spiral ***********************************************/ //----------------------------------------------------------------------------- // Global variables //----------------------------------------------------------------------------- // Access to texture 0 (scene texture) sampler2D SceneTex; // UV coordinates of rectangle being processed float2 UVTopLeft; float2 UVBottomRight; //----------------------------------------------------------------------------- // Input / output structures //----------------------------------------------------------------------------- // Input to Pixel Shader struct PS_Input { float2 TexCoord0 : TEXCOORD0; // Texture coords of this pixel within source texture - the entire unprocessed scene float2 TexCoord1 : TEXCOORD1; // Texture coords of this pixel within processed area only (useful when using support texture - unused in this shader) }; // Output from Pixel Shader struct PS_Output { float4 Colour : COLOR0; }; //----------------------------------------------------------------------------- // Main function //----------------------------------------------------------------------------- float Luminance = 0.08f; static const float fMiddleGray = 0.18f; static const float fWhiteCutoff = 0.8f; float2 PixelOffsets[9] = { { -0.004, -0.004 }, { -0.003, -0.003 }, { -0.002, -0.002 }, { -0.001, -0.001 }, { 0.000, 0.000 }, { 0.001, 0.001 }, { 0.002, 0.002 }, { 0.003, 0.003 }, { 0.004, 0.004 }, }; static const float BlurWeights[9] = { 0.026995, 0.064759, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.064759, 0.026995, }; // Main pixel shader function void main( in PS_Input i, out PS_Output o ) { float3 pixel; float3 colour = 0; for(int i = 0; i < 9; i++) { pixel = tex2D( SceneTex, i.TexCoord0 + PixelOffsets * 5.0f) + 0.5f; pixel *= fMiddleGray / (Luminance + 0.001f); pixel *= (1.0f + (pixel / (fWhiteCutoff * fWhiteCutoff))); pixel -= 5.0f; pixel = max(pixel,0.0f); pixel /= (10.0f + pixel); colour += pixel * BlurWeights; } colour *= 1.5f o.Colour.rgb = (colour , 1.0f) + tex2D( SceneTex, i.TexCoord0); }
  3. ThorOdinson

    Gaussian Blur In HLSL for directX9

    after messing about with it apparently the changing of colour when moving the camera was becasue i was using only 7 gaussian weights i changed it to 9 so it works fine. all my coding was correct except that thanks everyone for all your help
  4. ThorOdinson

    Gaussian Blur In HLSL for directX9

    thanks i will try it later
  5. ThorOdinson

    Gaussian Blur In HLSL for directX9

    some how i have fixed it and its blurs unfortuantly when i move the camera it goes really bright when i move right and dark then negative colours when i move left. any help would be apprecieated
  6. ThorOdinson

    Gaussian Blur In HLSL for directX9

    think the problem is that the height and width of the texture are not passing through correctly
  7. ThorOdinson

    Gaussian Blur In HLSL for directX9

    Unfortuantly i am not doing it using fx and only doing it ps and it needs to be like my example is:( thanks though
  8. ThorOdinson

    Gaussian Blur In HLSL for directX9

    Can I use PIX in virtual studios 2010? because I've never used it. the shader runs its just that when I reduce the brightness it the scene is there its two copies of of the scene one stays still the other moves from left to right. also when I move left with the camera it gets brighter and then you move left it goes darker
  9. i have to create a shader that creates a blurring of the screen. I have searched the internet for information on Gaussian blur effect. eventually i want to make it into a two pass Gaussian blur. but i am having alot of problems just doing one pass. Currently i have the code for the pixel shader. // Access to texture 0 sampler2D Tex0; float TintColour; int TexHeight; int TexWidth; //----------------------------------------------------------------------------- // Input / output structures //----------------------------------------------------------------------------- // Input to Pixel Shader struct PS_Input { float2 TexCoord0 : TEXCOORD0; }; // Output from Pixel Shader struct PS_Output { float4 Colour : COLOR0; }; const int KernelSize = 7; float2 PixelKernel[7] = { { -3, 0 }, { -2, 0 }, { -1, 0 }, { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 }, }; const float BlurWeights[7] = { 0.064759, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.064759, }; //----------------------------------------------------------------------------- // Main function //----------------------------------------------------------------------------- // Main pixel shader function void main( in PS_Input i, out PS_Output o ) { float4 colour = 0; float2 TexSize = float2( 1.0 /TexHeight, 1.0 /TexWidth); for (int p = 0; p < 7; p++) { colour += tex2D( Tex0, i.TexCoord0 + (PixelKernel * TexSize)) * BlurWeights; } o.Colour.rgb = colour; o.Colour.a = 1.0f; } i Have tried every way to make the screen blur but for some reason its just constantly bright. Please can anyone shed some light onto the problem.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!