Example #1
0
ScatterSkyComponent::ScatterSkyComponent()
   : mEnabled(false),
	  mSkyCubeReady(false)
{
   //mName = "Scatter Sky";

   // Load Skybox Shader
   mShader.idx = bgfx::invalidHandle;
   Graphics::ShaderAsset* skyboxShaderAsset = Torque::Graphics.getShaderAsset("Sky:skyboxShader");
   if (skyboxShaderAsset)
   {
      mShader = skyboxShaderAsset->getProgram();
      mMatrixUniform = Torque::Graphics.getUniformMat4("u_mtx", 1);
   }

	// Load Scatter Sky Shader
	mGenerateSkyCubeShader.idx = bgfx::invalidHandle;
	Graphics::ShaderAsset* scatterSkyShaderAsset = Torque::Graphics.getShaderAsset("Sky:scatterSkyShader");
	if (scatterSkyShaderAsset)
	{
		mGenerateSkyCubeShader = scatterSkyShaderAsset->getProgram();
		mCubeParamsUniform = Torque::Graphics.getUniformMat4("u_cubeParams", 1);
      mSkyParams1Uniform = Torque::Graphics.getUniformMat4("u_skyParams1", 1);
      mSkyParams2Uniform = Torque::Graphics.getUniformMat4("u_skyParams2", 1);
      mSkyParams3Uniform = Torque::Graphics.getUniformMat4("u_skyParams3", 1);
      mSkyParams4Uniform = Torque::Graphics.getUniformMat4("u_skyParams4", 1);
      mSkyParams5Uniform = Torque::Graphics.getUniformMat4("u_skyParams5", 1);
	}

   mView    = NULL;
	mTexture = Torque::bgfx.createTextureCube(512, 1, bgfx::TextureFormat::RGBA16, BGFX_TEXTURE_RT, NULL);

   // Default Settings
   mIntensity                 = 2.0f;
   mSunBrightness             = 1000.0f;
   mSurfaceHeight             = 0.994f;
   mScatterStrength           = 0.028f;
   mMieBrightness             = 0.1f;
   mMieDistribution           = 0.63f;
   mMieCollectionPower        = 0.39f;
   mMieStrength               = 0.0264f;
   mRayleighBrightness        = 3.3f;
   mRayleighCollectionPower   = 0.81f;
   mRayleighStrength          = 0.139f;
   mStepCount                 = 6.0f;
   mAirColor.set(0.18867780436772762f, 0.4978442963618773f, 0.6616065586417131f);

	mGenerateSkyCube = true; 

   for (U32 side = 0; side < 6; ++side)
   {
      mTempSkyCubeView[side] = NULL;
      mTempSkyCubeBuffers[side].idx = bgfx::invalidHandle;
   }
}
Example #2
0
// Called when the plugin is loaded.
void create()
{
   // Load Shader
   Graphics::ShaderAsset* skyboxShaderAsset = Link.Graphics.getShaderAsset("Skybox:skyboxShader");
   if ( skyboxShaderAsset )
   {
      skyboxShader = skyboxShaderAsset->getProgram();
      skyboxMatrixUniform = Link.Graphics.getUniformMat4("u_mtx", 1);
   }

   // Register Console Functions
   Link.Con.addCommand("Skybox", "load", loadTexture, "", 2, 2);
   Link.Con.addCommand("Skybox", "enable", enableSkybox, "", 1, 1);
   Link.Con.addCommand("Skybox", "disable", disableSkybox, "", 1, 1);

   v_RenderLayer1 = Link.Graphics.getView("RenderLayer1", 2000);
}
Example #3
0
// Called when the plugin is loaded.
void create(PluginLink _link)
{
   Link = _link;

   // Load Shader
   Graphics::ShaderAsset* terrainShaderAsset = Link.Graphics.getShaderAsset("Terrain:terrainShader");
   if ( terrainShaderAsset )
      terrainShader = terrainShaderAsset->getProgram();

   // Register Console Functions
   Link.Con.addCommand("Terrain", "load", loadHeightMap, "", 2, 2);
   Link.Con.addCommand("Terrain", "enable", enableTerrain, "", 1, 1);
   Link.Con.addCommand("Terrain", "disable", disableTerrain, "", 1, 1);

   // Create a terrain builder
   terrainBuilder = new TerrainBuilder(_link);
}
Example #4
0
// Called when the plugin is loaded.
void create()
{
   // Load Shader
   Graphics::ShaderAsset* shaderAsset = Link.Graphics.getShaderAsset("PolyVox:renderShader");
   if (shaderAsset)
      mShader = shaderAsset->getProgram();

   // Generate polyvox sphere.
   createSphereInVolume(volData, 30);
   PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> surfaceMesh;
   PolyVox::CubicSurfaceExtractorWithNormals< PolyVox::SimpleVolume<U8> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &surfaceMesh);
   surfaceExtractor.execute();

   // Verts
   const std::vector<PolyVox::PositionMaterialNormal>& vecVertices = surfaceMesh.getVertices();
   mVerts = new PosUVNormalVertex[vecVertices.size()];
   for (U32 i = 0; i < vecVertices.size(); ++i)
   {
      mVerts[mVertCount].m_x = vecVertices[i].position.getX();
      mVerts[mVertCount].m_y = vecVertices[i].position.getY();
      mVerts[mVertCount].m_z = vecVertices[i].position.getZ();

      mVerts[mVertCount].m_u = 0.0f;
      mVerts[mVertCount].m_v = 0.0f;

      mVerts[mVertCount].m_normal_x = vecVertices[i].normal.getX();
      mVerts[mVertCount].m_normal_y = vecVertices[i].normal.getY();
      mVerts[mVertCount].m_normal_z = vecVertices[i].normal.getZ();
      mVertCount++;
   }

   // Indices
   const std::vector<U32>& vecIndices = surfaceMesh.getIndices();
   mIndices = new U32[vecIndices.size()];
   for (U32 i = 0; i < vecIndices.size(); ++i)
   {
      mIndices[mIndexCount] = vecIndices[mIndexCount];
      mIndexCount++;
   }

   refresh();
}