Refraction/Distortion?

Materials, textures, lighting, postfx
27 posts Page 3 of 3
Steve_Yorkshire
Posts: 207
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Sat Jan 28, 2017 3:49 pm
@
User avatar
irei1as
I tested this in basic lighting too and it seems to work fine - though as you say BL is pretty redundant these days.
I did notice screen-wrapping as well when adding it to a static object and moving it to the edge of the screen - but only on the "Y axis" (?), so 0 0 0 in worldspace. Horizontal seems okay for some reason ... :|

Not sure what to do about that though - though thankfully it's not going to affect what I want it for too much as it might help the player see invisible enemies when they approach.

One more thing I'd like to do, is to add a colour shade/tint/darken to it but don't know. I noticed you commented about modifying colour_exit:
//here you can modify colourexit if needed

return colour_exit;


I tried adding an rgba to colour_exit before the return and got the colouring - but lost all the transparency and wobble :(

Any hints for how I should be doing this? :?:
Steve_Yorkshire
Posts: 207
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Sun Jan 29, 2017 8:11 pm
Aha! Was doing it wrong - probably still doing it wrong but at least I have a result.

Image

To pixel shader:
//...
float4 colour_exit = tex2D(diffuseMap, screenpos);

//here you can modify colourexit if needed
float4 color;//new color value

//positive = more white, negative = more black
color = float4(-0.1, -0.1, -0.1, 1.0);//rgba

colour_exit = colour_exit.rgba + color;//add color to colour_exit rgba

return colour_exit;
}


There's probably a better way of doing use this using diffuseColor or something but I'm not sure how that works ...
Steve_Yorkshire
Posts: 207
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Sun Jan 29, 2017 8:33 pm
Hang on, maybe lerp is the better bet here:

//...
float4 colour_exit = tex2D(diffuseMap, screenpos);

//here you can modify colourexit if needed
float4 color;

color = float4(0.2, 0.2, 0.2, 1.0);//0.2 is dark

colour_exit = lerp(colour_exit, color, 0.3);//1.0 would be solid matt colour so 0.3 gives color and transparency

return colour_exit;
}


Code looks less hacky at least ...

Image
irei1as
Posts: 72
Joined: Fri Feb 27, 2015 5:13 pm
by irei1as » Mon Jan 30, 2017 5:04 pm
I'm still having problems using #prepass to get any results in my old computer.
But it just may be that it doesn't work in the old code I'm using and it's fixed in the new versions.
An example of how to use it will be helpful so I can be sure where I'm wrong. Thanks.


Changing colours is a bit complex. Let me share a few experiments of how I modified colour_exit:

Plain black and white with a colour multiplication:

Code: Select all

(...)
float bn_base = (colour_exit.x + colour_exit.y + colour_exit.z) / 3.0;

//red example, change rgb values as needed
float3 mult_colour = float3(1.0, 0.0, 0.0);

colour_exit = float4(mult_colour.x * bn_base, mult_colour.y * bn_base, mult_colour.y * bn_base, colour_exit.a);
return colour_exit;
}


The same but with luminance black and white:

Code: Select all

(...)
float bn_base = (0.2126 * colour_exit.x + 0.7152 * colour_exit.y + 0.0722 * colour_exit.z);

//red example, change rgb values as needed
float3 mult_colour = float3(1.0, 0.0, 0.0);

colour_exit = float4(mult_colour.x * bn_base, mult_colour.y * bn_base, mult_colour.y * bn_base, colour_exit.a);
return colour_exit;
}


Sepia tone (copy/paste from somewhere):

Code: Select all

(...)
float3 sepia;
sepia.r = dot(colour_exit.rgb, float3(0.393, 0.769, 0.189));
sepia.g = dot(colour_exit.rgb, float3(0.349, 0.686, 0.168));   
sepia.b = dot(colour_exit.rgb, float3(0.272, 0.534, 0.131));
colour_exit = float4(sepia.xyz, colour_exit.a);
return colour_exit;
}


Direct light multiply:

Code: Select all

(...)
//[0,1] range for darker and over 1 to make them more white.
//Note: return clamps the colour
float light_value = 0.5;

colour_exit = float4(colour_exit.xyz * light_value, colour_exit.a);
return colour_exit;
}
Steve_Yorkshire
Posts: 207
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Mon Jan 30, 2017 6:26 pm
@
User avatar
irei1as
ah thanks for that. Helps me understand more. Cheers. :D
Steve_Yorkshire
Posts: 207
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Tue Jan 31, 2017 1:46 am
@
User avatar
irei1as
Got it working on Torque 1.2 (7 years old?) version of T3D - works in basic. So if you're if having issues with old hardware maybe it's driver related?

Image
Duion
Posts: 833
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Tue Jan 31, 2017 3:12 am
The soldier is totally invisible, so that you almost cannot see him.
27 posts Page 3 of 3

Who is online

Users browsing this forum: No registered users and 2 guests