A very common form of doing transparency in where the the transparent pixel is blended on top of the background pixel. This works well for simulating fog, haze, etc. In this context you also store an alpha value $\alpha$ with the [[RGBA Color Model|rgb components]]. In this context, $\alpha: [0,1]$ where $\alpha=0$ means fully transparent and $\alpha=1$ means fully opaque. $\huge \begin{align} I&= \op{lerp}(I_{\text{dest}},I_{\text{src}},\alpha )\\ &= \alpha I_{\text{src}} + (1-\alpha)I_{\text{dest}} \\ \end{align}$ When implementing this, special care is needed to interpolate the different components differently. In order to achieve desired results, the rendering order of your objects matter. You first draw all opaque objects, you then draw all translucent objects *in sorted order from back-to-front* on top of the existing pixels. This is needed because the order of transparent objects changes the final interpolation. This form of interpolation requires the back-to-front order because [[Linear Interpolation]] is a [[Associative Property|non-associatitve]] [[Function]]. For a [[Deferred Shading]] implementation, the two passes would be: - [[Deferred Shading]] for all opaque Geometry - A [[Forward Shading]] pass for translucent geometry. For the [[Phong Lighting Model]] (or derivatives) you must interpolate the different components seperately. To interpolate based off of [[Refraction]], we use the following: $\huge I_{\text{refract}} = I_{i}k_{t} \max(\hat v \cdot \hat T,0)^{nt} $ Where variables are taken from the [[Phong Lighting Model]] and [[Refraction]]. $\huge \begin{align} I_{\text{total}} &= I_{\text{ambient}} + I_{\text{diffuse}} + \ba{ I_{\text{reflect}} \mid I_{\text{refract}}} \end{align}$ The notation $\ba{\cdot | \cdot}$ refers to picking the lefthand value when $(\hat m, \hat{\ell})\cdot( \hat{v} \cdot \hat{m}) > 0$ and the righthand when that value is gt;0$. The intuition for this picking is that when that value is above zero, this means that the view vector and light vector are on the same side, therefore you see reflection. When said value is negative then the view vector and light vector are on different sides, so you see the refracted ray. There is another way however to use a weighted sum of $I_{\text{reflect}}$ and $I_{\text{refract}}$ using [[Fresnel Reflection]]. $\huge \begin{align} \op{lerp}(I_{\text{reflect}}, I_{\text{refract}}, R) \\ \end{align}$ $\huge R = \frac{1}{2}(R_{s}+R_{p}) $