Last active
April 28, 2021 08:10
-
-
Save abesmon/712540980a515841641fd1ff81ffdbdc to your computer and use it in GitHub Desktop.
Revisions
-
abesmon revised this gist
Feb 23, 2021 . No changes.There are no files selected for viewing
-
abesmon created this gist
Feb 23, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ uniform vec3 uLine; uniform vec4 uLiquidColor; uniform float uLineHeight; uniform float uFrenelPow; in Vert { vec3 objectPoint; vec3 normalForCam; } iVert; out vec4 fragColor; void main() { TDCheckDiscard(); vec4 color = vec4(0.0); float frenel = 1 - dot(vec3(0.0, 0.0, 1.0), iVert.normalForCam); if (iVert.objectPoint.y < uLine.z) { if (gl_FrontFacing) { if (uLine.z - iVert.objectPoint.y < uLineHeight) { vec3 ringColorHSV = TDRGBToHSV(uLiquidColor.rgb); ringColorHSV.y -= 0.5; ringColorHSV.z += 0.5; color = vec4(TDHSVToRGB(ringColorHSV), uLiquidColor.a); } else { vec3 mainColorHSV = TDRGBToHSV(uLiquidColor.rgb); mainColorHSV.z += pow(frenel, uFrenelPow); color = vec4(TDHSVToRGB(mainColorHSV), uLiquidColor.a); } } else { vec3 capColorHSV = TDRGBToHSV(uLiquidColor.rgb); capColorHSV.y -= 0.7; capColorHSV.z += 0.5; color = vec4(TDHSVToRGB(capColorHSV), uLiquidColor.a); } } TDAlphaTest(color.a); fragColor = TDOutputSwizzle(color); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ uniform vec3 uWobbleAngle; uniform float uGlassWidth; out Vert { vec3 objectPoint; vec3 normalForCam; } oVert; mat3 rotateZ(float _angle) { return mat3(cos(_angle),-sin(_angle), 0.0, sin(_angle),cos(_angle), 0.0, 0.0, 0.0, 1.0); } mat3 rotateX(float _angle) { return mat3(1.0, 0.0, 0.0, 0.0, cos(_angle), -sin(_angle), 0.0, sin(_angle), cos(_angle)); } void main() { vec3 scaledPoint = P - (N * uGlassWidth); oVert.objectPoint = scaledPoint; oVert.objectPoint = rotateZ(uWobbleAngle.z) * oVert.objectPoint; oVert.objectPoint = rotateX(uWobbleAngle.x) * oVert.objectPoint; oVert.normalForCam = uTDMats[TDCameraIndex()].camForNormals * N; vec4 worldSpacePos = TDDeform(scaledPoint); gl_Position = TDWorldToProj(worldSpacePos); }