Example #1
0
        protected void setMaterialState(SSMainShaderProgram mainShader)
        {
            GL.Enable(EnableCap.ColorMaterial); // turn off per-vertex color
            GL.Color4(this.MainColor);

            // setup the base color values...
            GL.Material(MaterialFace.Front, MaterialParameter.Ambient, AmbientMatColor);
            GL.Material(MaterialFace.Front, MaterialParameter.Diffuse, DiffuseMatColor);
            GL.Material(MaterialFace.Front, MaterialParameter.Specular, SpecularMatColor);
            GL.Material(MaterialFace.Front, MaterialParameter.Emission, EmissionMatColor);
            GL.Material(MaterialFace.Front, MaterialParameter.Shininess, ShininessMatColor);

            if (textureMaterial != null)
            {
                if (mainShader != null)
                {
                    mainShader.SetupTextures(textureMaterial);
                }
                else
                {
                    GL.ActiveTexture(TextureUnit.Texture0);
                    GL.Enable(EnableCap.Texture2D);
                    if (textureMaterial.ambientTex != null || textureMaterial.diffuseTex != null)
                    {
                        // fall back onto the diffuse texture in the absence of ambient
                        SSTexture tex = textureMaterial.ambientTex ?? textureMaterial.diffuseTex;
                        GL.BindTexture(TextureTarget.Texture2D, tex.TextureID);
                    }
                    else
                    {
                        GL.BindTexture(TextureTarget.Texture2D, 0);
                    }
                }
            }
        }
Example #2
0
 protected void setDefaultShaderState(SSMainShaderProgram pgm)
 {
     if (pgm != null)
     {
         pgm.Activate();
         pgm.UniObjectWorldTransform = this.worldMat;
         pgm.SetupTextures();
     }
 }
Example #3
0
 protected void setDefaultShaderState(SSMainShaderProgram pgm)
 {
     if (pgm != null)
     {
         pgm.Activate();
         pgm.UniObjectWorldTransform = this.worldMat;
         pgm.UniReceivesShadow       = renderState.receivesShadows;
         pgm.UniSpriteOffsetAndSize(0f, 0f, 1f, 1f);
         pgm.SetupTextures(textureMaterial);
     }
 }
Example #4
0
 protected void setDefaultShaderState(SSMainShaderProgram pgm, SSRenderConfig config)
 {
     if (pgm != null)
     {
         pgm.Activate();
         pgm.UniObjectWorldTransform = this.worldMat;
         pgm.UniReceivesShadow       = renderState.receivesShadows;
         pgm.UniSpriteOffsetAndSize(0f, 0f, 1f, 1f);
         pgm.UniShowWireframes = (config.drawWireframeMode == WireframeMode.GLSL_SinglePass);
         pgm.SetupTextures(textureMaterial);
     }
 }
Example #5
0
        private void _renderSetupGLSL(SSRenderConfig renderConfig, SSMainShaderProgram shaderPgm, SSMeshOBJSubsetData subset)
        {
            // Step 1: setup GL rendering modes...

            // GL.Enable(EnableCap.Lighting);

            // GL.Enable(EnableCap.Blend);
            // GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);

            // Step 2: setup our material mode and paramaters...

            if (renderConfig.drawingShadowMap)
            {
                // assume SSObject.Render has setup our materials properly for the shadowmap Pass
                // TODO: find a better way to do this!
                return;
            }

            SSColorMaterial.applyColorMaterial(subset.colorMaterial);
            if (shaderPgm == null)
            {
                SSShaderProgram.DeactivateAll();

                // fixed function single-texture
                if (subset.textureMaterial.diffuseTex != null)
                {
                    GL.ActiveTexture(TextureUnit.Texture0);
                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, subset.textureMaterial.diffuseTex.TextureID);
                }
            }
            else
            {
                shaderPgm.Activate();
                shaderPgm.SetupTextures(subset.textureMaterial);
            }
        }
Example #6
0
        private void _renderSetupGLSL(SSRenderConfig renderConfig, SSMainShaderProgram shaderPgm, SSMeshOBJSubsetData subset)
        {
            // Step 1: setup GL rendering modes...

            // GL.Enable(EnableCap.Lighting);

            // GL.Enable(EnableCap.Blend);
            // GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);

            // Step 2: setup our material mode and paramaters...

            if (renderConfig.drawingShadowMap) {
                // assume SSObject.Render has setup our materials properly for the shadowmap Pass
                // TODO: find a better way to do this!
                return;
            }

             			if (shaderPgm == null) {
                SSShaderProgram.DeactivateAll ();

                // fixed function single-texture
                if (subset.TextureMaterial.diffuseTex != null) {
                    GL.ActiveTexture(TextureUnit.Texture0);
                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, subset.TextureMaterial.diffuseTex.TextureID);
                }
            } else {
                shaderPgm.Activate();
                shaderPgm.SetupTextures(subset.TextureMaterial);
            }
        }
Example #7
0
 protected void setDefaultShaderState(SSMainShaderProgram pgm)
 {
     if (pgm != null) {
         pgm.Activate();
         pgm.UniObjectWorldTransform = this.worldMat;
         pgm.UniReceivesShadow = renderState.receivesShadows;
         pgm.UniSpriteOffsetAndSize(0f, 0f, 1f, 1f);
         pgm.SetupTextures(textureMaterial);
     }
 }
Example #8
0
 protected void setDefaultShaderState(SSMainShaderProgram pgm, SSRenderConfig config)
 {
     if (pgm != null) {
         pgm.Activate();
         pgm.UniObjectWorldTransform = this.worldMat;
         pgm.UniReceivesShadow = renderState.receivesShadows;
         pgm.UniSpriteOffsetAndSize(0f, 0f, 1f, 1f);
         pgm.UniShowWireframes = (config.drawWireframeMode == WireframeMode.GLSL_SinglePass);
         pgm.UniLighted = renderState.lighted;
         pgm.SetupTextures(textureMaterial);
     }
 }