public Shader activateMaterialSelection(Material curMat) { int texunit = 0; int handle = curMat.selectionshader.handle; if (!curMat.selectionshader.loaded) { return(curMat.selectionshader); } GL.UseProgram(handle); curMat.activateTexture(Material.TexType.normalTexture, ref texunit, ref handle); return(curMat.selectionshader); }
public Shader activateMaterialSelection(Material curMat) { int texunit = 0; int handle = curMat.selectionshader.handle; if (!curMat.selectionshader.loaded) return curMat.selectionshader; GL.UseProgram(handle); curMat.activateTexture(Material.TexType.normalTexture, ref texunit, ref handle); return curMat.selectionshader; }
public Shader activateMaterial(ref Material curMat) { int texunit = 0; Shader shader = curMat.shader; int handle = shader.handle; Material.Propertys propertys = curMat.propertys; if (!shader.loaded) { return(shader); } GL.UseProgram(handle); curMat.activateTexture(Material.TexType.baseTexture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.base2Texture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.base3Texture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.definfoTexture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.reflectionTexture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.normalTexture, ref texunit, ref handle); shader.insertUniform(Shader.Uniform.fresnelExp, ref propertys.fresnelExp); shader.insertUniform(Shader.Uniform.fresnelStr, ref propertys.fresnelStr); activateWorldTexture(Material.WorldTexture.reflectionMap, ref texunit, handle); shader.insertUniform(Shader.Uniform.in_eyepos, ref Scene.eyePos); activateWorldTexture(Material.WorldTexture.lightMap, ref texunit, handle); int emit = 0; if (propertys.useEmit) { emit = 1; //curMat.activateTexture(Material.TexType.emitTexture, ref curMat, ref texunit, handle); shader.insertUniform(Shader.Uniform.in_emitcolor, ref propertys.emitMapTint); /* * int emitBasealpha = 0; * if (propertys.emitMapAlphaBaseTexture) * emitBasealpha = 1; * * int emitNormalalpha = 0; * if (propertys.emitMapAlphaNormalTexture) * emitNormalalpha = 1; * * shader.insertUniform(Shader.Uniform.emit_a_normal, ref emitNormalalpha); * shader.insertUniform(Shader.Uniform.emit_a_base, ref emitBasealpha); * shader.insertUniform(Shader.Uniform.in_emitcolor, ref propertys.emitMapTint); * * if (curMat.envMapTexture != 0) * { * GL.ActiveTexture(TextureUnit.Texture0 + texunit); * GL.BindTexture(TextureTarget.Texture2D, curMat.envMapTexture); * GL.Uniform1(GL.GetUniformLocation(handle, "envMapTexture"), texunit); * texunit++; * } * */ } shader.insertUniform(Shader.Uniform.use_emit, ref emit); /* * int transparency = 0; * if (propertys.useAlpha) * { * transparency = 1; * * shader.insertUniform(Shader.Uniform.ref_size, ref propertys.refStrength); * shader.insertUniform(Shader.Uniform.blur_size, ref propertys.blurStrength); * shader.insertUniform(Shader.Uniform.fresnel_str, ref propertys.fresnelStrength); * * GL.ActiveTexture(TextureUnit.Texture0 + texunit); * GL.BindTexture(TextureTarget.Texture2D, this.Scene.backdropTextures[0]); * GL.Uniform1(GL.GetUniformLocation(handle, "backColorTexture"), texunit); * texunit++; * * * GL.ActiveTexture(TextureUnit.Texture0 + texunit); * GL.BindTexture(TextureTarget.Texture2D, this.Scene.backdropTextures[1]); * GL.Uniform1(GL.GetUniformLocation(handle, "backDepthTexture"), texunit); * texunit++; * * } * shader.insertUniform(Shader.Uniform.use_alpha, ref transparency); */ if (propertys.noCull) { GL.Disable(EnableCap.CullFace); } else { GL.Enable(EnableCap.CullFace); } if (propertys.noDepthMask) { GL.DepthMask(false); } else { GL.DepthMask(true); } if (propertys.additive) { GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); } else { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } return(shader); }
public Shader activateMaterial(ref Material curMat) { int texunit = 0; Shader shader = curMat.shader; int handle = shader.handle; Material.Propertys propertys = curMat.propertys; if (!shader.loaded) return shader; GL.UseProgram(handle); curMat.activateTexture(Material.TexType.baseTexture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.base2Texture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.base3Texture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.definfoTexture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.reflectionTexture, ref texunit, ref handle); curMat.activateTexture(Material.TexType.normalTexture, ref texunit, ref handle); shader.insertUniform(Shader.Uniform.fresnelExp, ref propertys.fresnelExp); shader.insertUniform(Shader.Uniform.fresnelStr, ref propertys.fresnelStr); activateWorldTexture(Material.WorldTexture.reflectionMap, ref texunit, handle); shader.insertUniform(Shader.Uniform.in_eyepos, ref Scene.eyePos); activateWorldTexture(Material.WorldTexture.lightMap, ref texunit, handle); int emit = 0; if (propertys.useEmit) { emit = 1; //curMat.activateTexture(Material.TexType.emitTexture, ref curMat, ref texunit, handle); shader.insertUniform(Shader.Uniform.in_emitcolor, ref propertys.emitMapTint); /* int emitBasealpha = 0; if (propertys.emitMapAlphaBaseTexture) emitBasealpha = 1; int emitNormalalpha = 0; if (propertys.emitMapAlphaNormalTexture) emitNormalalpha = 1; shader.insertUniform(Shader.Uniform.emit_a_normal, ref emitNormalalpha); shader.insertUniform(Shader.Uniform.emit_a_base, ref emitBasealpha); shader.insertUniform(Shader.Uniform.in_emitcolor, ref propertys.emitMapTint); if (curMat.envMapTexture != 0) { GL.ActiveTexture(TextureUnit.Texture0 + texunit); GL.BindTexture(TextureTarget.Texture2D, curMat.envMapTexture); GL.Uniform1(GL.GetUniformLocation(handle, "envMapTexture"), texunit); texunit++; } * */ } shader.insertUniform(Shader.Uniform.use_emit, ref emit); /* int transparency = 0; if (propertys.useAlpha) { transparency = 1; shader.insertUniform(Shader.Uniform.ref_size, ref propertys.refStrength); shader.insertUniform(Shader.Uniform.blur_size, ref propertys.blurStrength); shader.insertUniform(Shader.Uniform.fresnel_str, ref propertys.fresnelStrength); GL.ActiveTexture(TextureUnit.Texture0 + texunit); GL.BindTexture(TextureTarget.Texture2D, this.Scene.backdropTextures[0]); GL.Uniform1(GL.GetUniformLocation(handle, "backColorTexture"), texunit); texunit++; GL.ActiveTexture(TextureUnit.Texture0 + texunit); GL.BindTexture(TextureTarget.Texture2D, this.Scene.backdropTextures[1]); GL.Uniform1(GL.GetUniformLocation(handle, "backDepthTexture"), texunit); texunit++; } shader.insertUniform(Shader.Uniform.use_alpha, ref transparency); */ if (propertys.noCull) { GL.Disable(EnableCap.CullFace); } else { GL.Enable(EnableCap.CullFace); } if (propertys.noDepthMask) { GL.DepthMask(false); } else { GL.DepthMask(true); } if (propertys.additive) { GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); } else { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } return shader; }