Please use english language
It is currently 26 Feb 2020, 10:34

All times are UTC





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 04 Dec 2013, 15:40 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
So I posted yesterday about some help with a shader. I figured that one out (at least getting it to compile). But I wasn't satisfied. There was a white "overlay" that I couldn't figure out how to get rid of. So I hit Google, and found another example. I got it to compile and apply in-game, but there's a problem. There is a totally white oval around the crosshair that follows it wherever you look. I have no idea what is causing this. Could someone that knows about HLSL shaders take a look at the shader and determine what is causing that white oval? I like the effect -- it still applies -- but there is that damned oval. Here's the sorta-working shader:

Code:
static const bool description < string help = "Makes bright lights bleed their light into their surroundings."; > = true;

iface float BloomIntensity
< string help = "Controls the intensity of the bloom texture."; >
   = 1.30;

iface float OriginalIntensity
< string help = "Controls the intensity of the original scene texture."; >
   = 1.00;
   
iface float BloomSaturation
< string help = "Saturation amount on bloom."; >
   = 1.00;
   
iface float OriginalSaturation
< string help = "Saturation amount on original scene."; >
   = 1.00;
   

sampler BloomSampler : register(s0);

texture2D obge_LastRendertarget0_EFFECTPASS;

sampler2D ColorMapSampler = sampler_state {
   texture = <obge_LastRendertarget0_EFFECTPASS>;
   AddressU  = CLAMP;
   AddressV  = CLAMP;
   MINFILTER = LINEAR;
   MAGFILTER = LINEAR;
   MIPFILTER = LINEAR;
};

struct VSOUT {
   float4 vertPos : POSITION;
   float2 UVCoord : TEXCOORD0;
};

struct VSIN {
   float4 vertPos : POSITION0;
   float2 UVCoord : TEXCOORD0;
};

VSOUT DummyVS(VSIN IN) {
   VSOUT OUT = (VSOUT)0.0f;   // initialize to zero, avoid complaints.
   OUT.vertPos = IN.vertPos;
   OUT.UVCoord = IN.UVCoord;
   return (OUT);
}

float4 AdjustSaturation(float4 Color, float Saturation) {
   float Grey = dot(Color.rgb, float3(0.3, 0.59, 0.11));
   return lerp(Grey, Color, Saturation);
}

float4 BloomShader(float2 Tex : TEXCOORD0) : COLOR0 {
   float4 bloomColor = tex2D(BloomSampler, Tex);
   float4 originalColor = tex2D(ColorMapSampler, Tex);
   bloomColor = AdjustSaturation(bloomColor, BloomSaturation) * BloomIntensity;
    originalColor = AdjustSaturation(originalColor, OriginalSaturation) * OriginalIntensity;
   originalColor *= (1 - saturate(bloomColor));
   return originalColor + bloomColor;
}

technique main <
   int group = EFFECTGROUP_POST;
   int fxclass = EFFECTCLASS_COLOR;
>

{
   pass p0 {
      VertexShader = compile vs_1_1 DummyVS();
      PixelShader  = compile ps_2_0 BloomShader();
   }
}


Anyone who helps gets a million dollars :)


Top
 Profile  
 
Tomoko
PostPosted: 04 Dec 2013, 21:19 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
I don't see math which may do this, so it's textures themselves contain some data. And i recommend to ask on OBGE forum (if it exist), because shader semantic is different, only hlsl standart is the same.
Btw, change vs_1_1 to vs_2_0, because AMD/ATI cards having issues when pixel and vertex shaders do not match.

_________________
i5-4690k, 16Gb RAM, GTX 1060 6Gb, X-Fi Titanium, Win7 x128
I am INFP, not the brutal, godamnit.


Top
 Profile  
 
PostPosted: 04 Dec 2013, 23:00 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
Thanks for the reply, Boris. It's weird, but just the very fact that you repsonded got my brain waves flowing. I took a look at your shader for Oblivion and noticed that vanilla bloom was under sampler s1. I had s0. So, I changed it to s1. BOOM! The solid white oval in the middle of the screen is gone. Trouble is, although the effect compiles without error, and there are no artifacts or graphical oddities, the effect is not applied to the scene. You looked it over and saw no glaring math errors or any problems with the core HLSL, so it must be the minor OBGE specific elements. I'll do some reading and see if I can't figure out what may be wrong. I don't think there is an OBGE forum. There's a wiki, but questions go to the Bethesda forums and I've never seen any shader stuff in there.

Well thanks, Boris. Your response somehow got me thinking.


Top
 Profile  
 
PostPosted: 06 Dec 2013, 16:58 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
I don't know. I got rid of the white oval and made some changes. Now I get a result, but it's not good. Now the screen is completely black. Here's the shader: (I really don't think it's any of the OBGE stuff. Somethings wrong with the HLSL stuff)

Code:
static const bool description < string help = "Makes bright lights bleed their light into their surroundings."; > = true;

iface float BloomIntensity
< string help = "Controls the intensity of the bloom texture."; >
   = 1.30;

iface float OriginalIntensity
< string help = "Controls the intensity of the original scene texture."; >
   = 1.00;
   
iface float BloomSaturation
< string help = "Saturation amount on bloom."; >
   = 1.00;
   
iface float OriginalSaturation
< string help = "Saturation amount on original scene."; >
   = 1.00;
   
texture2D ColorMap;
   
sampler2D BloomSampler : register(s1);

sampler2D ColorMapSampler = sampler_state {
   texture = <ColorMap>;
   AddressU  = CLAMP;
   AddressV  = CLAMP;
   MINFILTER = LINEAR;
   MAGFILTER = LINEAR;
   MIPFILTER = LINEAR;
};

struct VSOUT {
   float4 vertPos : POSITION;
   float2 UVCoord : TEXCOORD0;
};

struct VSIN {
   float4 vertPos : POSITION0;
   float2 UVCoord : TEXCOORD0;
};

VSOUT DummyVS(VSIN IN) {
   VSOUT OUT = (VSOUT)0.0f;   // initialize to zero, avoid complaints.
   OUT.vertPos = IN.vertPos;
   OUT.UVCoord = IN.UVCoord;
   return (OUT);
}

float4 AdjustSaturation(float4 Color, float Saturation) {
   float Grey = dot(Color, float4(0.3, 0.59, 0.11, 0.0));
   return lerp(Grey, Color, Saturation);
}

float4 BloomShader(float2 Tex : TEXCOORD0) : COLOR0 {
   float4 bloomColor = tex2D(BloomSampler, Tex);
   float4 originalColor = tex2D(ColorMapSampler, Tex);
   bloomColor = AdjustSaturation(bloomColor, BloomSaturation) * BloomIntensity;
    originalColor = AdjustSaturation(originalColor, OriginalSaturation) * OriginalIntensity;
   originalColor *= (1 - saturate(bloomColor));
   return originalColor + bloomColor;
}

technique main <
   int group = EFFECTGROUP_POST;
   int fxclass = EFFECTCLASS_COLOR;
>

{
   pass p0 {
      VertexShader = compile vs_1_1 DummyVS();
      PixelShader  = compile ps_2_0 BloomShader();
   }
}


It's a simple shader. Why won't it work?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group