Commit 6032ab25 authored by David Llewellyn-Jones's avatar David Llewellyn-Jones

Shader discards transparent pixels

parent 11489254
#version 120
//uniform vec3 vPosition, vScale;
//uniform float fTime;
uniform float fTime;
//varying vec4 vDiffuse, vGlobal, vAmbient;
//varying vec3 vDir, vHalfVector;
//varying float fDist;
//varying vec3 vFuncParams;
varying vec3 vFuncParams;
//varying mat3 vNormalMatrix;
///*REPLACE:controlvars*//*END*/
//float DifferentialX (float x, float y, float t);
//float DifferentialY (float x, float y, float t);
//vec4 Colour (float x, float y, float z, float t);
vec4 Colour (float x, float y, float z, float t);
//uniform sampler2D tAudio;
//float audio (float x);
......@@ -22,7 +22,7 @@ void main () {
// float fNDotL;
// float fNDotHV;
// vec4 vColour;
// vec4 vColourRaw;
vec4 vColourRaw;
// float fAttenuation;
// vec3 vNormalBidir;
// vec3 vTangentX;
......@@ -49,10 +49,14 @@ void main () {
// vNormalBidir = -vNormal;
// }
// // Calculate the material colour
// vColourRaw = Colour (vFuncParams.x, vFuncParams.y, vFuncParams.z, fTime);
// Calculate the material colour
vColourRaw = Colour (vFuncParams.x, vFuncParams.y, vFuncParams.z, fTime);
// vColour = vGlobal * vColourRaw;
if (vColourRaw.a <= 0.0) {
discard;
}
// // Calculate dot product between normal and light direction
// fNDotL = max (dot (vNormalBidir, normalize (vDir)), 0.0);
......@@ -91,14 +95,11 @@ void main () {
// return z;
//}
//vec4 Colour (float x, float y, float z, float t) {
// vec4 c;
vec4 Colour (float x, float y, float z, float t) {
vec4 c;
// c.r = /*REPLACE:red*/1.0f/*END*/;
// c.g = /*REPLACE:green*/1.0f/*END*/;
// c.b = /*REPLACE:blue*/1.0f/*END*/;
// c.a = /*REPLACE:alpha*/1.0f/*END*/;
//
// return c;
//}
c.a = /*REPLACE:alpha*/1.0f/*END*/;
return c;
}
......@@ -70,6 +70,10 @@ void main () {
vColourRaw = Colour (vFuncParams.x, vFuncParams.y, vFuncParams.z, fTime);
vColour = vGlobal * vColourRaw;
if (vColourRaw.a <= 0.0) {
discard;
}
// Calculate dot product between normal and light direction
fNDotL = max (dot (vNormalBidir, normalize (vDir)), 0.0);
......
#version 120
//uniform vec3 vPosition, vScale;
//uniform float fTime;
uniform float fTime;
//varying vec4 vDiffuse, vGlobal, vAmbient;
//varying vec3 vDir, vHalfVector;
//varying float fDist;
//varying vec3 vFuncParams;
varying vec3 vFuncParams;
//varying mat3 vNormalMatrix;
//uniform sampler2D tTexture;
//uniform sampler2D tBumpMap;
......@@ -22,14 +22,14 @@
//vec3 FunctionD2 (float a, float t);
//float DifferentialA (float a, float p, float t);
//float DifferentialP (float a, float p, float t);
//vec4 Colour (float a, float p, float r, float t);
vec4 Colour (float a, float p, float r, float t);
void main () {
// vec3 vHalf;
// float fNDotL;
// float fNDotHV;
// vec4 vColour;
// vec4 vColourRaw;
vec4 vColourRaw;
// vec4 vTexColour;
// float fAttenuation;
// vec3 vNormalBidir;
......@@ -116,9 +116,13 @@ void main () {
// }
// // Calculate the material colour
// vColourRaw = Colour (vFuncParams.x, vFuncParams.y, vFuncParams.z, fTime);
vColourRaw = Colour (vFuncParams.x, vFuncParams.y, vFuncParams.z, fTime);
// vColour = vGlobal * vColourRaw;
if (vColourRaw.a <= 0.0) {
discard;
}
// // Calculate dot product between normal and light direction
// fNDotL = max (dot (vNormalBidir, normalize (vDir)), 0.0);
......@@ -146,16 +150,13 @@ void main () {
gl_FragColor = vec4 (1.0, 1.0, 1.0, 1.0);
}
//vec4 Colour (float a, float p, float r, float t) {
// vec4 c;
vec4 Colour (float a, float p, float r, float t) {
vec4 c;
// c.r = /*REPLACE:red*/1.0f/*END*/;
// c.g = /*REPLACE:green*/1.0f/*END*/;
// c.b = /*REPLACE:blue*/1.0f/*END*/;
// c.a = /*REPLACE:alpha*/1.0f/*END*/;
//
// return c;
//}
c.a = /*REPLACE:alpha*/1.0f/*END*/;
return c;
}
//float FunctionR (float a, float p, float t) {
// float r;
......
......@@ -5,7 +5,7 @@ uniform float fTime;
//varying vec4 vDiffuse, vGlobal, vAmbient;
//varying vec3 vDir, vHalfVector;
//varying float fDist;
//varying vec3 vFuncParams;
varying vec3 vFuncParams;
//varying mat3 vNormalMatrix;
//varying vec4 vShadowPos;
//uniform mat4 mLightTransform;
......@@ -63,9 +63,9 @@ void main() {
vVertex.x = ((vPos.x + (fR * vOffset.x)) / vScale.x) - vPosition.x;
vVertex.y = ((vPos.y + (fR * vOffset.y)) / vScale.y) - vPosition.y;
vVertex.z = ((vPos.z + (fR * vOffset.z)) / vScale.z) - vPosition.z;
// vFuncParams.x = fA;
// vFuncParams.y = fP;
// vFuncParams.z = fR;
vFuncParams.x = fA;
vFuncParams.y = fP;
vFuncParams.z = fR;
// // There appears to be a bug accessing gl_NormalMatrix from the fragment shader
// // We therefore pass it across using a varying variable
......
......@@ -130,6 +130,10 @@ void main () {
vColourRaw = Colour (vFuncParams.x, vFuncParams.y, vFuncParams.z, fTime);
vColour = vGlobal * vColourRaw;
if (vColourRaw.a <= 0.0) {
discard;
}
// Calculate dot product between normal and light direction
fNDotL = max (dot (vNormalBidir, normalize (vDir)), 0.0);
......
......@@ -596,7 +596,8 @@ char * CartesianGenerateFragmentShaderShadow (FuncPersist * psFuncData) {
//CartesianPersist * psCartesianData = psFuncData->Func.psCartesianData;
if (psFuncData->szShaderShadowFragmentSource) {
szShader = CopyText (psFuncData->szShaderShadowFragmentSource);
//szShader = CopyText (psFuncData->szShaderShadowFragmentSource);
szShader = ReplaceTextCopy (psFuncData->szShaderShadowFragmentSource, "alpha", psFuncData->szShaderAlpha->str);
}
else {
szShader = NULL;
......
......@@ -1149,7 +1149,8 @@ char * CurveGenerateFragmentShaderShadow (FuncPersist * psFuncData) {
//CurvePersist * psCurveData = psFuncData->Func.psCurveData;
if (psFuncData->szShaderShadowFragmentSource) {
szShader = CopyText (psFuncData->szShaderShadowFragmentSource);
//szShader = CopyText (psFuncData->szShaderShadowFragmentSource);
szShader = ReplaceTextCopy (psFuncData->szShaderShadowFragmentSource, "alpha", psFuncData->szShaderAlpha->str);
}
else {
szShader = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment