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

All times are UTC





Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: HLSL Coding Question
PostPosted: 06 Feb 2016, 16:22 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
This is some HSV code I am trying to port to Oblivion Reloaded. It originally came from a Skyrim ENB, but I'd like to run it in Oblivion.

This is an excerpt, but I'm getting an error:

Code:
LINE 1: float4 color = tex2D(renderSampler, IN.UVCoord);
   LINE 2: float3 hsvcolor = RGBtoHSV( color.xyz );
   LINE 3: hsvcolor.x = fColorHueMod + ( fColorHueMult * pow( hsvcolor.x, fColorHuePow ) );
   LINE 4: hsvcolor.y = fColorSaturationMod + ( fColorSaturationMult * pow( hsvcolor.y, fColorSaturationPow ) );
   LINE 5: hsvcolor.z = fColorIntensityMod + ( fColorIntensityMult * pow( hsvcolor.z, fColorIntensityPow ) );
   LINE 6: hsvcolor.y = ColorEqualizerMod( hsvcolor.x ) + ( ColorEqualizerMult( hsvcolor.x ) * pow( hsvcolor.y, ColorEqualizerPow( hsvcolor.x ) ) );
   LINE 7: hsvcolor.yz = max( hsvcolor.yz, 0.0 );
   LINE 8: color.xyz = HSVtoRGB( hsvcolor );

   LINE 9: return color;


The error I get from the compiler is "warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them" for lines 4, 5 and 6 (Obviously, the "LINE: x" is not in the code, I just wanted to clarify where the error comes from. The effect compiles though. I just would like to get rid of the error. Any help would be greatly appreciated. What I posted is not all of the code. If you need to see the whole thing just let me know and I will post it.


Top
 Profile  
 
Tomoko
 Post subject: Re: HLSL Coding Question
PostPosted: 06 Feb 2016, 23:50 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
Warning is not error and you may ignore this one, because it's not even mentioning potential bug.

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


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 07 Feb 2016, 04:08 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
Thanks. I tested it in-game and all seems to be working fine. So a warning isn't the same as an error, I suppose.


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 07 Feb 2016, 04:48 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
In my practice, important warnings were only vector truncation, because sometime they are "silently" reporting bugs in the code made after many changes of progression. For example:
Code:
float3 colorfactor=( color.x + color.y + color.z );
result.xyz *= colorfactor.x;

vs
Code:
float colorfactor=( color.r + color.g + color.b );
result.xyz *= colorfactor;

Such changes may occur and you may forgot about them (don't think it's just me having this issue frequently) and keep using variable which is not fit output. In some cases this works without bugs, like in following one:
Code:
float3 colorfactor=( color.x + color.y + color.z );
result.x *= colorfactor;//here colorfactor.x will be used

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


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 07 Feb 2016, 14:54 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
Good info. Can I ask you something else? I have the following code:

Code:
#define FogColor float3( 0.00, 0.00, 2.55 )

float3 colorInput = tex2D(renderSampler, IN.UVCoord).rgb;
   float3 color = colorInput.rgb;
   color = saturate(color - Defog * FogColor);
   color *= pow(2.0f, Exposure);
   color = pow(color, Gamma);
   float3 lumCoeff = float3(0.2126, 0.7152, 0.0722);
   float lum = dot(lumCoeff, color.rgb);
   float3 blend = lum.rrr;
   float L = saturate( 10.0 * (lum - 0.45) );
   float3 result1 = 2.0f * color.rgb * blend;
   float3 result2 = 1.0f - 2.0f * (1.0f - blend) * (1.0f - color.rgb);
   float3 newColor = lerp(result1, result2, L);
   float3 A2 = Bleach * color.rgb;
   float3 mixRGB = A2 * newColor;   
   color.rgb += ((1.0f - A2) * mixRGB);
   float3 middlegray = dot(color, (1.0 / 3.0));
   float3 diffcolor = color - middlegray;
   colorInput.rgb = (color + diffcolor * Saturation)/(1 + (diffcolor * Saturation));

   return float4(colorInput, 1);


How can I break that float3 for fog color into three separate floats? One float for the red factor, one for the green factor and 1 for the blue factor.


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 07 Feb 2016, 23:23 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
A Google search revealed something called BreakOutFloat3Components or DebugFloat3Values. Any tips on how to use those in a script?


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 07 Feb 2016, 23:48 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
Replace it with editable variable
Code:
float3   FogColor <
   string UIName="FogColor";
   string UIWidget="vector";//or color
> = {0.00, 0.00, 2.55};

instead of this
Code:
#define FogColor float3( 0.00, 0.00, 2.55 )

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


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 08 Feb 2016, 19:45 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
Hey, thanks. But I think what I'm going to do, because this is for Oblivion Reloaded--it needs to be editable via a plugin--is this:

Code:
float FogColorRed
float FogColorBlue
float FogColorGreen
float3 FogColor {FogColorRed, FogColorBlue, FogColorGreen}


and plug it in like so:

Code:
color = saturate(color - Defog * FogColor.rgb);


That should work, right??


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 09 Feb 2016, 00:55 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
Don't think it's possible without programming different version of plugin.

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


Top
 Profile  
 
 Post subject: Re: HLSL Coding Question
PostPosted: 09 Feb 2016, 01:26 
Offline

Joined: 22 Jan 2013, 01:10
Posts: 40
No, it worked. I just had to declare 3 different variables and define it in the shader. The three variables are editable via the plugin.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 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