GTA4 Depth of Field and Motion Blur Fixed - final update v2

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: GTA4 Depth of Field and Motion Blur Fixed

You mean this part :
Yes.

In gta4 version temporary variables are not available in the enbeffect.fx shader, but you can try to declare vector with c199 register, i'm using it for other shaders as temporary variable, may be it will not be changed by any other variables. But shader initialized to not work in this mode, as i remember.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
*master*
Posts: 119
Joined: 05 Jan 2012, 22:34
Location: France

Re: GTA4 Depth of Field and Motion Blur Fixed

ENBSeries wrote: Yes.

In gta4 version temporary variables are not available in the enbeffect.fx shader, but you can try to declare vector with c199 register, i'm using it for other shaders as temporary variable, may be it will not be changed by any other variables. But shader initialized to not work in this mode, as i remember.
I see, thank you.
so if I add something like this on the .Fx :

Code: Select all

float4	_c199 : register(c199);
It'll do something temporary but not linked to the TempF1/2/3 stuff right? Is that possible to use one value from the .fx as a variable on the effect.txt for example? like #include something?
To explain you what I want to do is in the ADOF , there are 4 floats

Code: Select all

float4 vDofParams=float4(NearBlurDepth, FocalPlaneDepth, FarBlurDepth, MaxBlurAmount)
And I wanted the FarBlurDepth as a keyboard controlled value; like you know, these tech demos with sliders. Might be great for screenshots without having to look at the object in the middle of the screen. I think I'm going to do the same on Skyrim ENB as I think it is possible to add the TempF1 values to prepass.fx now?

Offline
User avatar
Posts: 79
Joined: 12 Jan 2012, 11:09

Re: GTA4 Depth of Field and Motion Blur Fixed

ENBSeries wrote:Why not to use dynamic flow for amount of samples? There are too much of them and most image area don't need so many samples.
It didn't work, I don't know what's wrong in the compiler.

such as :
this one works.

Code: Select all

//motion blur
   for (int iii=0; iii<7; iii++)
   {
      r6.x=r4.x * r3.w + r4.z; //v2
      r6.y=r4.y * r3.w + r4.w; //v2
      r7=tex2D(s6, r6.xy);
      r5.w=r7.x - _c85.x;
      if (r5.w<-0.3)
      {
         r5.w=_c1.y; //1.0
      } else r5.w=_c1.w; //0.0
      r6=tex2D(s2, r6.xy);
      r5.xyz=r6.xyz * r5.w + r5.xyz;
      r2.w=r2.w + r5.w;
      r3.w=r3.w + _c1.y; //1.0

     // this part
     if(r3.w != _c80.x) //gDirectionalMotionBlurLength.x
         return 0.0;
   }
but this one didn't (change to 20 samples)

Code: Select all

//motion blur
   for (int iii=0; iii<20; iii++)
   {
      r6.x=r4.x * r3.w + r4.z; //v2
      r6.y=r4.y * r3.w + r4.w; //v2
      r7=tex2D(s6, r6.xy);
      r5.w=r7.x - _c85.x;
      if (r5.w<-0.3)
      {
         r5.w=_c1.y; //1.0
      } else r5.w=_c1.w; //0.0
      r6=tex2D(s2, r6.xy);
      r5.xyz=r6.xyz * r5.w + r5.xyz;
      r2.w=r2.w + r5.w;
      r3.w=r3.w + _c1.y; //1.0

     // this part
     if(r3.w != _c80.x) //gDirectionalMotionBlurLength.x
         return 0.0;
   }
still not work...

Code: Select all

	float xxx=_c80.x;
	
	//motion blur
	for (int iii=0; iii<20; iii++)
	{
		r6.x=r4.x * r3.w + r4.z; //v2
		r6.y=r4.y * r3.w + r4.w; //v2
		r7=tex2D(s6, r6.xy);
		r5.w=r7.x - _c85.x;
		if (r5.w<-0.3)
		{
			r5.w=_c1.y; //1.0
		} else r5.w=_c1.w; //0.0
		r6=tex2D(s2, r6.xy);
		r5.xyz=r6.xyz * r5.w + r5.xyz;
		r2.w=r2.w + r5.w;
		r3.w=r3.w + _c1.y; //1.0
		if(r3.w != xxx)
			return 0.0;
		
	}

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: GTA4 Depth of Field and Motion Blur Fixed --- update

icelaglace
float4 _c199 : register(c199);
It'll do something temporary but not linked to the TempF1/2/3 stuff right? Is that possible to use one value from the .fx as a variable on the effect.txt for example? like #include something?
Correct for variable. And TempF1/2/3/4 are c199.xyzw actually in gta4 version, but as global pixel and vertex shader constants, so they could be replaced or the hlsl effect class itself may not allow such linking (i don't remember, constants or textures not allowed with saved states). Try anyway, just _oC0*=_c199.x; at the end of shader and tweak by 1+pageup to see if brightness affected.

gp65cj04
Multiple return paths are not supported by shader model 3, NVidia may support in some drivers this, but ATI should fail, they are very strict. You need to compute amount of samples for cycle (condition i<samplecount;), then use tex2Dlod there instead of tex2D.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
Posts: 79
Joined: 12 Jan 2012, 11:09

Re: GTA4 Depth of Field and Motion Blur Fixed --- update

compile success :

Code: Select all

	float motionBlurSamples=128.0;
              //motion blur
	while(r3.w < motionBlurSamples)
	{
		r6.x=r4.x * r3.w + r4.z; //v2
		r6.y=r4.y * r3.w + r4.w; //v2
		r7=tex2D(s6, r6.xy);
		r5.w=r7.x - _c85.x;
		if (r5.w<-0.3)
		{
			r5.w=_c1.y; //1.0
		} else r5.w=_c1.w; //0.0
		r6=tex2D(s2, r6.xy);
		r5.xyz=r6.xyz * r5.w + r5.xyz;
		r2.w=r2.w + r5.w;
		r3.w=r3.w + _c1.y; //1.0
	}
compile fail

Code: Select all

	float motionBlurSamples=128.0 * _c80.x;
              //motion blur
	while(r3.w < motionBlurSamples)
	{
		r6.x=r4.x * r3.w + r4.z; //v2
		r6.y=r4.y * r3.w + r4.w; //v2
		r7=tex2D(s6, r6.xy);
		r5.w=r7.x - _c85.x;
		if (r5.w<-0.3)
		{
			r5.w=_c1.y; //1.0
		} else r5.w=_c1.w; //0.0
		r6=tex2D(s2, r6.xy);
		r5.xyz=r6.xyz * r5.w + r5.xyz;
		r2.w=r2.w + r5.w;
		r3.w=r3.w + _c1.y; //1.0
	}
change to tex2Dlod still compile fail.

Code: Select all

	float motionBlurSamples=128.0 * _c80.x;
              //motion blur
	while(r3.w < motionBlurSamples)
	{
		r6.x=r4.x * r3.w + r4.z; //v2
		r6.y=r4.y * r3.w + r4.w; //v2
		r7=tex2Dlod(s6, r6.xy);
		r5.w=r7.x - _c85.x;
		if (r5.w<-0.3)
		{
			r5.w=_c1.y; //1.0
		} else r5.w=_c1.w; //0.0
		r6=tex2Dlod(s2, r6.xy);
		r5.xyz=r6.xyz * r5.w + r5.xyz;
		r2.w=r2.w + r5.w;
		r3.w=r3.w + _c1.y; //1.0
	}
compile fail

Code: Select all

	float motionBlurSamples=128.0;
              //motion blur
	while(r3.w < motionBlurSamples)
	{
		r6.x=r4.x * r3.w + r4.z; //v2
		r6.y=r4.y * r3.w + r4.w; //v2
		r7=tex2Dlod(s6, r6.xy);
		r5.w=r7.x - _c85.x;
		if (r5.w<-0.3)
		{
			r5.w=_c1.y; //1.0
		} else r5.w=_c1.w; //0.0
		r6=tex2Dlod(s2, r6.xy);
		r5.xyz=r6.xyz * r5.w + r5.xyz;
		r2.w=r2.w + r5.w;
		r3.w=r3.w + _c1.y; //1.0
	}
Does any conditions or loops with global varaible (_c80.x) lead to compile fail? :roll:

Thanks.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: GTA4 Depth of Field and Motion Blur Fixed --- update

wrong line:
r6=tex2Dlod(s2, r6.xy);
it must be
float4 tempuvzw;
tempuvzw.xy=r6.xy;
tempuvzw.z=0.0;//unused;
tempuvzw.w=0.0;//texture mipmap lod level, must be 0 for shaders i did, because not mipmapped textures
r6=tex2Dlod(s2, tempuvzw);
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
Posts: 79
Joined: 12 Jan 2012, 11:09

Re: GTA4 Depth of Field and Motion Blur Fixed --- update

ENBSeries wrote:wrong line:
r6=tex2Dlod(s2, r6.xy);
it must be
float4 tempuvzw;
tempuvzw.xy=r6.xy;
tempuvzw.z=0.0;//unused;
tempuvzw.w=0.0;//texture mipmap lod level, must be 0 for shaders i did, because not mipmapped textures
r6=tex2Dlod(s2, tempuvzw);
It works!! Thanks a lot!! :D

Offline
User avatar
*master*
Posts: 119
Joined: 05 Jan 2012, 22:34
Location: France

Re: GTA4 Depth of Field and Motion Blur Fixed --- update-082

EXCELLENT!
I have to test that now. Very well done gp65cj04, you seemed very motivated for this.
And thank you Boris for your help <3

Offline
User avatar
Posts: 79
Joined: 12 Jan 2012, 11:09

Re: GTA4 Depth of Field and Motion Blur Fixed --- update-082

icelaglace wrote:EXCELLENT!
I have to test that now. Very well done gp65cj04, you seemed very motivated for this.
And thank you Boris for your help <3
I get some free time this days. ;)

Offline
User avatar
*master*
Posts: 119
Joined: 05 Jan 2012, 22:34
Location: France

Re: GTA4 Depth of Field and Motion Blur Fixed --- update-082

Haha, summer holidays hmm? :)

Anyway I just tried your code; it seems to work fine! amazing.
But is there a way to "trigger" it faster? I mean my character motion blur is like 3 taps only; not smooth at all, compared to the car one which is very smooth.
Maybe visualsettings.dat? or is there something I can change on the code?
Just wondering :D

Thank you very much again mate.
Post Reply