mvAmbientColor.rgb().assign(muAmbientColor.rgb().multiply(muAmbientIntensity.rgb())); enclose( muLightAttenuation[lightAttCount].index(1) .add(muLightAttenuation[lightAttCount].index(2)) .multiply(mgLightDistance) .add(muLightAttenuation[lightAttCount].index(3)) .multiply(mgLightDistance) .multiply(mgLightDistance)
RFloat spec = new RFloat("spec" + i); spec.assign(pow(nDotL, muShininess)); spec.assign(spec.multiply(attenuation).multiply(lightPower)); specular.assignAdd(spec); specMapColor.assignAdd(specColor); color.rgb().assignAdd(specular.multiply(muSpecularColor).multiply(specMapColor.rgb())); color.rgb().assignAdd(specular.multiply(muSpecularColor));
GL_POSITION.assign(muMVPMatrix.multiply(transfMatrix).multiply(mgPosition)); mvNormal.assign(normalize(muNormalMatrix.multiply(castMat3(transfMatrix)).multiply(mgNormal))); } else { GL_POSITION.assign(muMVPMatrix.multiply(mgPosition)); mvCubeTextureCoord.assign(castVec3(maPosition)); if (mHasSkyTexture) { mvCubeTextureCoord.x().assignMultiply(-1);
GL_POSITION.assign(muMVPMatrix.multiply(transfMatrix).multiply(mgPosition)); mvNormal.assign(normalize(muNormalMatrix.multiply(castMat3(transfMatrix)).multiply(mgNormal))); mvCubeTextureCoord.assign(castVec3(maPosition)); if(mHasSkyTexture) { mvCubeTextureCoord.x().assignMultiply(-1);
enclose(maBoneWeight1.x().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex1.x())))).add( enclose(maBoneWeight1.y().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex1.y())))).add( enclose(maBoneWeight1.z().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex1.z())))).add( enclose(maBoneWeight1.w().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex1.w())))) enclose(maBoneWeight2.x().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex2.x())))).add( enclose(maBoneWeight2.y().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex2.y())))).add( enclose(maBoneWeight2.z().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex2.z())))).add( enclose(maBoneWeight2.w().multiply(muBoneMatrix.elementAt(castInt(maBoneIndex2.w()))))
power.assign(lightPower.multiply(nDotL).multiply(attenuation)); intensity.assignAdd(power);
mvAmbientColor.rgb().assign(muAmbientColor.rgb().multiply(muAmbientIntensity.rgb())); enclose( muLightAttenuation[lightAttCount].index(1) .add(muLightAttenuation[lightAttCount].index(2)) .multiply(mgLightDistance) .add(muLightAttenuation[lightAttCount].index(3)) .multiply(mgLightDistance) .multiply(mgLightDistance)
RFloat spec = new RFloat("spec" + i); spec.assign(pow(nDotL, muShininess)); spec.assign(spec.multiply(attenuation).multiply(lightPower)); specular.assignAdd(spec); specMapColor.assignAdd(specColor); color.rgb().assignAdd(specular.multiply(muSpecularColor).multiply(specMapColor.rgb())); color.rgb().assignAdd(specular.multiply(muSpecularColor));
power.assign(lightPower.multiply(nDotL).multiply(attenuation)); color.rgb().assign(enclose(diffuse.multiply(color.rgb())).add(ambientColor)); ShaderVar gShadowValue = getGlobal(DefaultShaderVar.G_SHADOW_VALUE); color.rgb().assign( color.rgb().multiply(enclose(new RFloat("1.0").subtract(gShadowValue))));
@Override public void main() { // float far=gl_DepthRange.far; // float near=gl_DepthRange.near; // // vec4 eye_space_pos = gl_ModelViewMatrix * /*something*/ // vec4 clip_space_pos = gl_ProjectionMatrix * eye_space_pos; // // float ndc_depth = clip_space_pos.z / clip_space_pos.w; // // float depth = (((far-near) * ndc_depth) + near + far) / 2.0; // gl_FragDepth = depth; RVec4 color = (RVec4) getGlobal(DefaultShaderVar.G_COLOR); RFloat depth = new RFloat("depth"); depth.assign(1.0f); depth.assignSubtract(enclose(GL_FRAG_COORD.z().divide(GL_FRAG_COORD.w())).divide(muFarPlane)); //float z = 1.0 - (gl_FragCoord.z / gl_FragCoord.w) / u_far; //depth.assignSubtract(enclose(GL_FRAG_COORD.z().divide(GL_FRAG_COORD.w()))); //depth.assign(GL_FRAG_COORD.w().divide(far)); color.r().assign(depth); color.g().assign(depth); color.b().assign(depth); //float depth = 1.0 - (gl_FragCoord.z / gl_FragCoord.w) / 9.5; }
@Override public void main() { RVec4 lightDepthCol = new RVec4("lightDepthCol"); lightDepthCol.assign(texture2D(muShadowMapTexture, mvShadowTexCoord.xy())); ShaderVar gShadowValue = getGlobal(DefaultShaderVar.G_SHADOW_VALUE); ShaderVar gSpecularValue = getGlobal(DefaultShaderVar.G_SPECULAR_VALUE); RVec3 gNormal = (RVec3) getGlobal(DefaultShaderVar.G_NORMAL); RFloat shadowLightAngle = new RFloat("shadowLightAngle"); shadowLightAngle.assign(dot(gNormal, muShadowLightDir)); startif( new Condition(lightDepthCol.z(), Operator.LESS_THAN, mvShadowTexCoord.z().subtract(mcShadowBias)), new Condition(Operator.AND, shadowLightAngle, Operator.LESS_THAN_EQUALS, -.15f) ); { gShadowValue.assign(muShadowInfluence); gSpecularValue.assign(0.0f); } endif(); }
@Override public void main() { // -- vFogDensity = 0.0; mvFogDensity.assign(0); // -- if (uFogEnabled == true){ startif(new Condition(muFogEnabled, Operator.EQUALS, true)); { // -- vFogDensity = (gl_Position.z - uFogNear) / (uFogFar - uFogNear); mvFogDensity.assign( enclose(GL_POSITION.z().subtract(muFogNear)).divide( enclose(muFogFar.subtract(muFogNear)) ) ); // -- vFogDensity = clamp(vFogDensity, 0.0, 1.0); mvFogDensity.assign(clamp(mvFogDensity, 0, 1)); } endif(); }
@Override public void main() { RVec2 textureCoord = (RVec2)getGlobal(DefaultShaderVar.G_TEXTURE_COORD); RVec3 texNormal = new RVec3("texNormal"); RVec3 normal = (RVec3)getGlobal(DefaultShaderVar.G_NORMAL); for(int i=0; i<mTextures.size(); i++) { texNormal.assign(castVec3(texture2D(muTextures[i], textureCoord))); texNormal.assign(texNormal.rgb().multiply(2)); texNormal.assignSubtract(1); texNormal.assign(normalize(texNormal)); if(mTextures.get(i).getInfluence() != 1) texNormal.assignMultiply(mTextures.get(i).getInfluence()); normal.assign(normalize(texNormal.add(normal))); } }
/** * Assigns a value to a shader variable. Equivalent to GLSL's '=' operator. * * @param value */ public void assign(float value) { assign(Float.toString(value)); }
/** * Assigns and adds a value to a shader variable. Equivalent to GLSL's '+=' operator. * * @param value */ public void assignAdd(float value) { assignAdd(Float.toString(value)); }
/** * Assigns and Multiplies a value to a shader variable. Equivalent to GLSL's '*=' operator. * * @param value */ public void assignMultiply(ShaderVar value) { assignMultiply(value.getName()); }
/** * Assigns and subtracts a value to a shader variable. Equivalent to GLSL's '-=' operator. * * @param value */ public void assignSubtract(float value) { assignSubtract(Float.toString(value)); }