TA Log 09262021

C# It’s a good practice to save game setting data to binary files. To save: FileStream dataStream = new FileStream( dataPath, FileMode.Create); BinaryFormatter converter = new BinaryFormatter(); converter.Serialize(dataStream, toSave); dataStream.Close(); To open/load: FileStream dataStream = new FileStream(dataPath, FileMode.Open); BinaryFormatter converter = new BinaryFormatter(); DataClass data = converter.Deserialize(dataStream) as DataClass; We can use it outside game too. For example, dynamic bone’s parameter settings will lost once the model is updated, because people usually replace the whole prefab....

September 26, 2021 · Kyle Fang

TA Log 09222021

RGB to Grayscale dot(color.rgb, float3(0.298999995, 0.587000012, 0.114)); It’s a convenient way to write rather than multiply and add up every channel. Tangent, Normal, Bitangent Tangent is the U of the UV for both OpenGL and DirectX. Left to right, 0.0 to 1.0. The binormal is the V of the UV. OpenGL is bottom to top, and DirectX is top to bottom. Unity is +Y, OpenGL standard. Unreal is -Y, DirectX standard....

September 22, 2021 · Kyle Fang

TA Log 09062021

Shader Animation The usual method of making shader animation is to use time parameter and sin wave function. It’s fast and easy to make simple periodical animation, such as water wave and flashing color. However, to have more complex periodical animation, we need to shape sin wave function with min(), max(), abs(), and the sin function it self. It might requires a lot of works to shape it. I figured out a simpler way to input the animation parameters: texture....

September 6, 2021 · Kyle Fang

TA Log 08302021

Collections UV distortion: https://twitter.com/Fakirgnome/status/1120421374571495426 Easy PS techniques to create distance field texture: https://twitter.com/Ed_dV/status/1415156393959518209 easing demonstration: https://easings.net/ URP SurfaceInput.hlsl Declartion: BaseMap BumpMap / NormalMap EmissionMap Helpers: Alpha() sample albedo and alpha sample normal sample emission There’s a problem in URP’s hlsl files. They are all tight together to build the URP shader, not SRP. This reminds me that URP is an example of SRP. It’s better to have my own helper library....

August 30, 2021 · Kyle Fang

TA Log 08162021

Fog Linear Fog c = fog coordinates, S, E = start and end $$f = \frac{E - c}{ E - S}$$ Exponential Fog d = fog density $$f = \frac{1}{2^{cd}} = 2^{-cd}$$ Exponential Squared Fog $$f = \frac{1}{2^{cd^2}} = 2^{- (cd)^2}$$

August 16, 2021 · Kyle Fang