Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-------------------------------------------------------------.
- / Config Settings /
- '-----------------------------------------------------------*/
- //Adjust these values as you like:
- #define lineStrength 3 //How thick the borders are
- #define lineStrengthGradient 0 //Makes borders thicker (or thinner if negative) the closer they are
- #define polygonAmount 6 //Amount of detail (higher = less detail)
- #define bleedThrough 0.0 //Makes the world visible in transparency, 0-1
- //Color templates
- #define red float3(1.0, 0, 0)
- #define blue float3(0, 0, 1.0)
- #define green float3(0, 1.0, 0)
- #define magenta float3(1.0, 0, 1.0)
- #define cyan float3(0, 1.0, 1.0)
- #define yellow float3(1.0, 1.0, 0)
- #define white float3(1.0, 1.0, 1.0)
- #define black float3(0.0, 0.0, 0.0)
- #define hex(x) float3(x>>16, (x>>8)&0xFF, x&0xFF) //Use hex(0xFFFFFF) to use hexadecimal color codes
- #define rgb(r, g, b) float3(r/255.0, g/255.0, b/255.0) //Use rgb(255, 255, 255) to use standard 0-255 rgb color codes
- #define borderColor black //Base border color
- #define borderEndColor white //Defines the color for borders far away
- #define borderGradient 0 //Defines at which distance the end color is reached (higher=closer)
- #define backgroundColor white //Works the same as the above, but for background colors
- #define backgroundEndColor black
- #define backgroundGradient 0
- #define noiseIntensity 0.0 //Intensity of the noise, 0-1
- /*-----------------------------------------------------------.
- / Shader Code /
- '-----------------------------------------------------------*/
- float3 CustomPass(float4 position : SV_Position, float2 texcoord : TEXCOORD0) : SV_Target
- {
- float depth = tex2D(depthSampler, texcoord).x;
- depth = (2.0 * Depth_z_near) / ( -(Depth_z_far - Depth_z_near) * depth + (Depth_z_far + Depth_z_near) );
- float pixelWidth = float(lineStrength) / BUFFER_WIDTH;
- float pixelHeight = float(lineStrength) / BUFFER_HEIGHT;
- if (lineStrengthGradient > 0)
- {
- pixelWidth *= (1-depth) * lineStrengthGradient;
- pixelHeight *= (1-depth) * lineStrengthGradient;
- }
- else if (lineStrengthGradient < 0)
- {
- pixelWidth *= (depth) * abs(float(lineStrengthGradient));
- pixelHeight *= (depth) * abs(float(lineStrengthGradient));
- }
- //Calculate depth
- float surrounddepth = 0;
- surrounddepth += tex2D(depthSampler, float2(texcoord.x + pixelWidth, texcoord.y)).x;
- surrounddepth += tex2D(depthSampler, float2(texcoord.x - pixelWidth, texcoord.y)).x;
- surrounddepth += tex2D(depthSampler, float2(texcoord.x, texcoord.y + pixelHeight)).x;
- surrounddepth += tex2D(depthSampler, float2(texcoord.x, texcoord.y - pixelHeight)).x;
- surrounddepth = surrounddepth / 4.0;
- surrounddepth = (2.0 * Depth_z_near) / ( -(Depth_z_far - Depth_z_near) * surrounddepth + (Depth_z_far + Depth_z_near) );
- //Calculate noise
- float t = (timer * 0.0022337);
- float seed = dot(texcoord, float2(12.9898, 78.233));
- float noise = frac(sin(seed) * 43758.5453 + t);
- float noiseColor = frac(cos(seed) * 53758.5453 - t);
- float3 finalColor;
- if (surrounddepth > depth * (1.0 + 0.00005 * polygonAmount))
- { //Pixel is part of a border
- float gradient = surrounddepth * borderGradient;
- finalColor = lerp(borderColor, borderEndColor, gradient > 1 ? 1 : gradient);
- }
- else
- { //Pixel is part of the background
- float gradient = surrounddepth * backgroundGradient;
- finalColor = lerp(backgroundColor, backgroundEndColor, gradient > 1 ? 1 : gradient);
- finalColor = finalColor * (1-bleedThrough) + tex2D(s0, texcoord).rgb*bleedThrough;
- finalColor = lerp(finalColor, noiseColor, noise*noiseIntensity);
- }
- return finalColor;
- }
Advertisement
Add Comment
Please, Sign In to add comment