public SSMesh_SphereICO(int divisions, SSMainShaderProgram shaderPgm, SSTexture texture) { this.shaderPgm = shaderPgm; this.texture = texture; this._Create(divisions); }
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); } } } }
public SSScene(SSMainShaderProgram main = null, SSPssmShaderProgram pssm = null, SSInstanceShaderProgram instance = null, SSInstancePssmShaderProgram instancePssm = null) { renderConfig = new SSRenderConfig(main, pssm, instance, instancePssm); }
public SSScene(SSMainShaderProgram main = null, SSPssmShaderProgram pssm = null, SSInstanceShaderProgram instance = null, SSInstancePssmShaderProgram instancePssm = null, Dictionary <string, SSShaderProgram> otherShaders = null) { renderConfig = new SSRenderConfig(main, pssm, instance, instancePssm, otherShaders); }
protected void setDefaultShaderState(SSMainShaderProgram pgm) { if (pgm != null) { pgm.Activate(); pgm.UniObjectWorldTransform = this.worldMat; pgm.SetupTextures(); } }
public SSRenderConfig(SSMainShaderProgram main, SSPssmShaderProgram pssm, SSInstanceShaderProgram instance, SSInstancePssmShaderProgram instancePssm) { mainShader = main; pssmShader = pssm; instanceShader = instance; instancePssmShader = instancePssm; }
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); } }
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); } }
private void configureDrawShader(SSRenderConfig renderConfig, SSMainShaderProgram pgm) { if (pgm != null) { pgm.Activate(); pgm.UniPoissonSamplingEnabled = renderConfig.usePoissonSampling; if (renderConfig.usePoissonSampling) { pgm.UniNumPoissonSamples = renderConfig.numPoissonSamples; } } }
public SSRenderConfig(SSMainShaderProgram main, SSPssmShaderProgram pssm, SSInstanceShaderProgram instance, SSInstancePssmShaderProgram instancePssm, Dictionary<string, SSShaderProgram> other ) { mainShader = main; pssmShader = pssm; instanceShader = instance; instancePssmShader = instancePssm; otherShaders = other; }
public SSRenderConfig(SSMainShaderProgram main, SSPssmShaderProgram pssm, SSInstanceShaderProgram instance, SSInstancePssmShaderProgram instancePssm, Dictionary <string, SSShaderProgram> other ) { mainShader = main; pssmShader = pssm; instanceShader = instance; instancePssmShader = instancePssm; otherShaders = other; }
private void configureDrawShader(ref SSRenderConfig renderConfig, SSMainShaderProgram pgm, Matrix4[] vp) { if (pgm == null) { return; } pgm.Activate(); pgm.UniNumShadowMaps = 1; if (renderConfig.usePoissonSampling) { Vector2[] poissonScales = { new Vector2(1f) }; pgm.UniPoissonScaling = poissonScales; } pgm.UniShadowMapVPs = vp; }
protected void configureDrawShader(SSRenderConfig renderConfig, SSMainShaderProgram pgm) { if (pgm == null) { return; } pgm.Activate(); pgm.UniNumShadowMaps = c_numberOfSplits; if (renderConfig.usePoissonSampling) { pgm.UniPoissonScaling = m_poissonScaling; } pgm.UniShadowMapVPs = m_shadowViewProjBiasMatrices; pgm.UniPssmSplits = m_viewSplits; }
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); } }
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); } }
public SSScene(SSMainShaderProgram main = null, SSPssmShaderProgram pssm = null, SSInstanceShaderProgram instance = null, SSInstancePssmShaderProgram instancePssm = null) { renderConfig = new SSRenderConfig (main, pssm, instance, instancePssm); }
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); } }
private void _renderSetupGLSL(ref SSRenderConfig renderConfig, SSMeshOBJSubsetData subset) { // Step 1: setup GL rendering modes... GL.Enable(EnableCap.CullFace); // 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... GL.Color3(System.Drawing.Color.White); // clear the vertex color to white.. SSMainShaderProgram shaderPgm = renderConfig.BaseShader; 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(); GL.Disable(EnableCap.CullFace); // fixed function single-texture GL.Disable(EnableCap.Texture2D); if (subset.diffuseTexture != null) { GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, subset.diffuseTexture.TextureID); } } else { // activate GLSL shader shaderPgm.Activate(); // bind our texture-images to GL texture-units // http://adriangame.blogspot.com/2010/05/glsl-multitexture-checklist.html // these texture-unit assignments are hard-coded in the shader setup GL.ActiveTexture(TextureUnit.Texture0); if (subset.diffuseTexture != null) { GL.BindTexture(TextureTarget.Texture2D, subset.diffuseTexture.TextureID); shaderPgm.u_DiffTexEnabled = true; } else { GL.BindTexture(TextureTarget.Texture2D, 0); shaderPgm.u_DiffTexEnabled = false; } GL.ActiveTexture(TextureUnit.Texture1); if (subset.specularTexture != null) { GL.BindTexture(TextureTarget.Texture2D, subset.specularTexture.TextureID); shaderPgm.u_SpecTexEnabled = true; } else { GL.BindTexture(TextureTarget.Texture2D, 0); shaderPgm.u_SpecTexEnabled = false; } GL.ActiveTexture(TextureUnit.Texture2); if (subset.ambientTexture != null) { GL.BindTexture(TextureTarget.Texture2D, subset.ambientTexture.TextureID); shaderPgm.u_AmbTexEnabled = true; } else { GL.BindTexture(TextureTarget.Texture2D, 0); shaderPgm.u_AmbTexEnabled = false; } GL.ActiveTexture(TextureUnit.Texture3); if (subset.bumpTexture != null) { GL.BindTexture(TextureTarget.Texture2D, subset.bumpTexture.TextureID); shaderPgm.u_BumpTexEnabled = true; } else { GL.BindTexture(TextureTarget.Texture2D, 0); shaderPgm.u_BumpTexEnabled = false; } // reset to texture-unit 0 to be friendly.. GL.ActiveTexture(TextureUnit.Texture0); } }
/// <summary>Creates a 800x600 window with the specified title.</summary> public TestBenchBootstrap(string windowName) : base(#if false 800, 600, GraphicsMode.Default, // color format windowName, GameWindowFlags.Default, // windowed mode DisplayDevice.Default, // primary monitor 2, 2, // opengl version GraphicsContextFlags.Debug #endif) { // this can be used to force other culture settings for testing.. // System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL"); this.Title = windowName; VSync = VSyncMode.On; restoreClientWindowLocation(); Console.WriteLine("GL Version = {0}",GL.GetString(StringName.Version)); Console.WriteLine("GL Shader Version = {0}", GL.GetString(StringName.ShadingLanguageVersion)); // setup asset manager contexts // these help the asset manager find the "Asset" directy up above the bin/obj/Debug // output directories... SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("./Assets")); SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("../../Assets")); SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("../../../Assets")); SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("../../../../Assets")); mainShader = new SSMainShaderProgram(); // before mscene if (!mainShader.IsValid) { throw new Exception ("Failed to build the main shader"); } pssmShader = new SSPssmShaderProgram (); if (!pssmShader.IsValid) { pssmShader = null; } instancingShader = new SSInstanceShaderProgram (); if (!instancingShader.IsValid) { instancingShader = null; } else { instancingShader.debugLocations (); } instancingPssmShader = new SSInstancePssmShaderProgram (); if (!instancingPssmShader.IsValid) { instancingPssmShader = null; } setupInput (); setupScene (); setupCamera (); setupEnvironment (); setupHUD (); }
protected void configureDrawShader(SSRenderConfig renderConfig, SSMainShaderProgram pgm) { if (pgm == null) return; pgm.Activate(); pgm.UniNumShadowMaps = c_numberOfSplits; if (renderConfig.usePoissonSampling) { pgm.UniPoissonScaling = m_poissonScaling; } pgm.UniShadowMapVPs = m_shadowViewProjBiasMatrices; pgm.UniPssmSplits = m_viewSplits; }
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) { 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.diffuseTex ?? textureMaterial.ambientTex; GL.BindTexture(TextureTarget.Texture2D, tex.TextureID); } else { GL.BindTexture(TextureTarget.Texture2D, 0); } } }
private void configureDrawShader(ref SSRenderConfig renderConfig, SSMainShaderProgram pgm, Matrix4[] vp) { if (pgm == null) return; pgm.Activate (); pgm.UniNumShadowMaps = 1; if (renderConfig.usePoissonSampling) { Vector2[] poissonScales = { new Vector2 (1f) }; pgm.UniPoissonScaling = poissonScales; } pgm.UniShadowMapVPs = vp; }
public SSScene(SSMainShaderProgram main = null, SSPssmShaderProgram pssm = null, SSInstanceShaderProgram instance = null, SSInstancePssmShaderProgram instancePssm = null, Dictionary<string, SSShaderProgram> otherShaders = null) { renderConfig = new SSRenderConfig (main, pssm, instance, instancePssm, otherShaders); }