Posts

Showing posts with the label Shader

[UE4][VR] Projet Horla - First Showcase

Image
I'm currently working on a personnal VR project on Unreal Engine 4 . It runs on an Oculus Quest at 72 FPS (as required by Oculus). There is no post process here, I'm using my own lighting model based on an unlit model. Texture are in black and white and thresholded, lights are not Unreal lights but custom lights: I wrote a simple lighting subsystem managing my custom dynamic light sources. Lighting is basically just distance check in the pixel shaders (point lights only, spot light support soon, directional not needed as the game is indoor), shadows are faked. It's rather simple but I don't need to implement more complex/realistic solution, it runs fine on VR mobile hardware, so... let's go !

[UE4][Shader] Post process: tresholded black and white with sobel edge

Image
This is a post process material I've done on Unreal 4 on my free time. To make this rendering, this is what I did: Post process material must be rendered before tone mapping to get "hard edge" on light radius attenuation Original image is desaturated to black and white Color masking, here color close enough to red is excluded from desaturation Image tresholding to keep pixels of a luminance under a predefined step black, the others become white Outline effect Sobel operator used to detect edges Keep only hard enough edge using tresholding again Edges lit by a light are blacks, others are white

[Unity][AI][Shader] AI detecting player from vision using camera and shaders

Image
Introduction In a lot of video games, raycasting is often an efficient solution to detect the player from an AI. But the player is often partially occluded, and then a simple raycast is not enough. A solution could be to perform several raycasts on the player bounds, but this is quite limited and can be tricky depending on the gameplay. Also, we often just have to know if the player is visible or not, but sometimes we need to know how much of the vision space the player visibility takes. An idea that has been given to me is to use a shader to detect the player, the AI perform the detection in a similar way the human player do: having a rendered image and trying to detect the target reading the pixels. The subject I will explain today is a personal try, there is probably a better way to achieve this but I will try to explain a possible solution to achieve this. I will speak about Unity features I used to achieve this, but it is not Unity dependant, this idea is quite general and can...

[Unity][Shader] Night Vision

Image
A simple shader to make a night vision effect. Features - Screen colorization - Vignette effect - Noise - Scene diffuse (unlit) and scene color (lit) buffer are blended, allow to see in the complete dark while still having luminance difference on pixel affected by lights - Option to have pixels with high luminance tending toward white Screenshots Without effect With effect With/ Without (drag the cursor) Video Source Code [+] Shader Shader "Post Process/Shader_NightVision" { Properties { _MainTex ("Texture", 2D) = "white" {} _ColorTint("Color Tint", Color) = (1, 1, 1, 1) _VignetteRadius("Vignette Radius", Range(0, 2)) = 0.25 _VignetteSmoothness("Vignette Smoothness", Range(0, 2)) = 0.25 _LightSensitivity("Light Sensitivity", Range(1, 100)) = 1 _LightWhiteTreshold("Light White Treshold", Range(0, 1)) = 0.5 _LightWhitePower(...

[UE4] Materials collection #1

Image
Surface generation Surface generation depending on normal Z value Exemple using the surface generation material function: moss generation Exemple using the surface generation material function: sand generation  Water plane Simple water material (for small surface) Post process distorsion effect Post process effect using UV offset Post process "water on lens" effect Post process effect simulating water on camera lens

[Unity][Shader] Stylized Fog

Image
I wrote a simple shader for Unity to make a stylized fog like Fire Watch's fog. The idea is to get a pixel on the texture depending on the pixel depth, if the fog is near, a pixel on the left on the texture uv will be picked, if the fog is far, a pixel on the right on the texture uv will be picked. Features Choose between a linear fog and an exponential fog Choose between a simple color or a texture Screenshots Video Source Code Image Effect Version (Unity 2017 and older if not using Stack) [+] Shader Shader "Hidden/Shader_StylizedFog" { Properties { _MainTex("Texture", 2D) = "white" {} _FogColor("Fog Color", Color) = (1, 1, 1, 1) _UseStylizedFogTexture("Use Stylized Fog Texture", Int) = 0 _StylizedFogTexture("Stylized Fog Texture", 2D) = "white" {} _FogMinDistance("Fog Min Distance", Float) = 0 _FogMaxDistance("Fog Max Distance",...