3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: OH MY gosh  (Read 855 times)

« on: July 13, 2013, 12:38:00 AM »
I just Combined the motion Blur radial shader with the heat haze shade And I got it working!

Code: [Select]
////////////////////////////////////////////////////////////////////////////////////////////////////////////
MotionBlur With Heat Haze
////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*HLSLSTART Motion Radial Blur


//-------------------------------------------------------------------------------------------
//Editables
//-------------------------------------------------------------------------------------------
float ScreenWidth = 1280;
float ScreenHeight = 1024;
float BlurStart = 1.0f;
float BlurWidth = -0.15f;
float time = 0.0;
float2 screenLocation = float2(0.5,0.5);
float radii = 0.5;
float4 oCol = float4(0.5f,0,0,0); //slightly red

float _CX = 0.0f;
float _CY = 0.0f;

static float2 Center2 = { _CX, _CY };
float _CCX = 0.5f;
float _CCY = 0.5f;

static float2 Center = { _CCX+(_CX/20),_CCY+ (-_CY/20) };
//-------------------------------------------------------------------------------------------
//Textures
//-------------------------------------------------------------------------------------------

texture screenTexture;

sampler screenTextureSampler = sampler_state
{
  Texture = <screenTexture>;
  MipFilter = LINEAR;
  MinFilter = NONE;
  MagFilter = LINEAR;
  AddressU = CLAMP;
  AddressV = CLAMP;
  AddressW = CLAMP;
  AddressU = WRAP;
  AddressV = WRAP;
  AddressW = WRAP;
  AddressU = MIRROR;
  AddressV = MIRROR;
  AddressW = MIRROR;
};
//-------------------------------------------------------------------------------------------
//Pixel Shader
//-------------------------------------------------------------------------------------------


float4 DefaultRender( in float2 textureUV : TEXCOORD0 ) : COLOR
{
      //setup oval to render haze in
  float2 displace = screenLocation - float2(textureUV.x,textureUV.y/2);
float range = saturate(1 - (length(displace) / (abs(-sin(radii * 8) * radii))))+0.0000001f;

   //Alter the UV coordinates (position in the texture) for the current pixel,
   //to achieve some image deformation, based on the 'time' parameter set by
   //the regular script code.
   textureUV.x += range*sin(time+textureUV.x*600)*0.001f;
   textureUV.y += range*cos(time+textureUV.y*600)*0.002f;

   //Read the pixel from the texture, from the altered UV location
   float4 COLOR = tex2D(screenTextureSampler,textureUV);
   COLOR+=COLOR*range*oCol;

 
   textureUV = textureUV - Center;
   
   float4 color= -0.5;
   int nsamples = 30;
   
   for(int i=0; i<nsamples; i++) {
    float scale = BlurStart - BlurWidth*(i/(float) (nsamples-1));
    color += tex2D(screenTextureSampler, textureUV*scale + Center);//(Center2/150) );
    }
    color /= nsamples;
    return color;
 
}
//-------------------------------------------------------------------------------------------
//Technique
//-------------------------------------------------------------------------------------------
technique PostProcessing
{
    pass P0
    {       
        PixelShader = compile ps_3_0 DefaultRender();
    }
}


HLSLEND*/

//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

//The following is our regular script code which sets and manipulates the shader above

float carMinSpeed=0;
float carMaxSpeed=260;
float maxBlurFactor=-0.05f;
float Time = 0;
int movingObject = OBJ_22;

void Main()
{
   if (iInitializing())
   {
      iShaderSet(OBJ_0,"Heat Haze");
   }

   //Create some vectors to store location data in,
   Vector3 targetLocation;
   Vector3 screenLocation;
   Vector3 camLoc;

   //get fire and camera location
   iObjectLocation(OBJ_22,targetLocation);
   iObjectLocation(OBJ_0,camLoc); 

   //add some offset to fire location
   targetLocation.y += 2.5;

   //get corresponding screen location projected .
   i3DLocationToScreen(screenLocation,targetLocation,OBJ_0); //cam

   //interpolate loaction between 0.0f and 1.0f so we can send to shader
float x = iFloatInterpolate(screenLocation.x,-16.0f,16.0f,0.0f,1.0f,true);
float y = iFloatInterpolate(screenLocation.y,12.0f,-12.0f,0.0f,1.0f,true);

   //Measure distance to fire from camera.
   float radii=iVectorLength(targetLocation-camLoc);
 
//Increase haze radius as we approach  fire
   float range = 0.23-iFloatInterpolate(radii,0.0f,50.0f,0.01f,0.2299f,true);

   //Update shader
   iShaderFloatSet(OBJ_0,"time",Time);
   iShaderFloat2Set(OBJ_0,"screenLocation",x,y/2);
   iShaderFloatSet(OBJ_0,"radii",range);
   Time += 0.4;
      iShaderSet(OBJ_0,"Motion Radial Blur");

   float blur = iFloatInterpolate(iObjectKmh(movingObject),carMinSpeed,carMaxSpeed,0,maxBlurFactor,true);
   iShaderFloatSet(OBJ_0,"BlurWidth", blur);
}
It was really hard though
http://www.youtube.com/watch?v=ssPe8dKOL7Y&feature=c4-overview&list=UUr0boUODFnZmY-PWnSyMokg
« Last Edit: July 13, 2013, 03:37:59 AM by dogtorque »
I be trippin!
« Reply #1 on: July 13, 2013, 12:41:22 AM »
I was so shocked that I actually combined to shaders and got it working. I will make a video showing it
« Last Edit: July 13, 2013, 12:45:08 AM by dogtorque »
I be trippin!
« Reply #2 on: July 13, 2013, 12:59:18 AM »
.....
« Last Edit: July 13, 2013, 02:27:04 AM by dogtorque »
I be trippin!
« Reply #3 on: July 13, 2013, 02:59:53 AM »
nice*)))

at this day i combine

BLOOM + TOON MAPPING+BLUR+HEAT RAZE+God rays(but god i deleted because i dont like effect)


What special in this?)
Use 7.22
« Reply #4 on: July 13, 2013, 03:37:07 AM »
it's special because it is my first time combining shaders.
I be trippin!
« Reply #5 on: July 13, 2013, 04:33:53 AM »
ohhh! take my congratulatory!!


but last time i told you - combine bloom and toon and then you will get hdr!!)
Use 7.22
« Reply #6 on: July 13, 2013, 12:03:26 PM »
Nice work  ;D I always like to see someone have a breakthrough.  It feels good.  Enjoy that s*** xD  Now if only I could get my problem worked out...
« Reply #7 on: July 13, 2013, 01:56:28 PM »
ohhh! take my congratulatory!!


but last time i told you - combine bloom and toon and then you will get hdr!!)
which one toon mapping or the regular toon shader?
I be trippin!
« Reply #8 on: July 13, 2013, 02:23:27 PM »
Congrats!! i was trying to do the same but i failed a lot of times :D amazing job ;)
See my web:
« Reply #9 on: July 14, 2013, 02:05:31 AM »
toon mapping- make dark area really dark

bloom- make shine

Bloom + Toon = fake HDR

But its not all...for get effect like HDR i made one more action) its secret )))))))))))ok...when you make this..let me know
Use 7.22
« Reply #10 on: July 14, 2013, 08:24:58 PM »
I tryed it but It doesn't work for me.

P.S. today I accidentally cut my middle finger badly while doing my chores and had to get 8 stitch's and I'm still in shock so right now I'm shacking baddly allmost had a heart attack while there were giving me the shots to numb my finger so theey can stitch it so until this heals this will effecct how fast I can work on 3drad.
I be trippin!
« Reply #11 on: July 15, 2013, 12:02:30 AM »
Cool lol ;)
I'd suggest to be more careful!!

Good qork with the shaders btw :)
« Reply #12 on: July 15, 2013, 01:43:11 AM »
omg...Bad news...But good luck! I hope all be good!
Use 7.22
Pages: [1]