void xObjBound::Render(Event * sender) { if (Editor::Instance()->GetSelectedShapeSize() == 0) return ; if (Editor::Instance()->GetSelectedShapeSize() == 1 && Editor::Instance()->GetSelectedShape(0)->GetColMesh() != NULL && Editor::Instance()->GetSelectedShape(0)->GetColMesh()->GetPositions().Size() > 0 && Editor::Instance()->GetSelectedShape(0)->GetColMesh()->GetIndices().Size() > 0) { RenderColMesh(); return ; } Aabb box = Aabb::Invalid; for (int i = 0; i < Editor::Instance()->GetSelectedShapeSize(); ++i) { Shape * obj = Editor::Instance()->GetSelectedShape(i); box = box.Merge(obj->GetBound()); } Vec3 pos = box.GetCenter(); Vec3 scale = box.GetSize(); RenderSystem * render = RenderSystem::Instance(); ShaderParam * uColor = mTech->GetPixelShaderParamTable()->GetParam("gColor"); uColor->SetUnifom(1, 1, 0, 1); mRenderAABB->xform.MakeTransform(pos, Quat::Identity, scale); render->Render(mTech, mRenderAABB); }
void Moon::Render() { RenderSystem * render = RenderSystem::Instance(); Camera * cam = World::Instance()->MainCamera(); Vec3 moonPos = Environment::Instance()->GetEvParam()->MoonPos; Vec3 moonDir = Environment::Instance()->GetEvParam()->MoonDir; float moonLum = Environment::Instance()->GetEvParam()->MoonLum; float moonSize = Environment::Instance()->GetEvParam()->MoonSize; float moonPhase = Environment::Instance()->GetEvParam()->MoonPase; const char * moonTex = Environment::Instance()->GetGlobalParam()->MoonTexture.c_str(); _setTexture(moonTex); ShaderParam * uTransform = mTech->GetVertexShaderParamTable()->GetParam("gTransform"); ShaderParam * uMoonParam = mTech->GetPixelShaderParamTable()->GetParam("gMoonParam"); uTransform->SetUnifom(moonPos.x, moonPos.y, moonPos.z, moonSize); uMoonParam->SetUnifom(moonPhase, moonLum, 0, 0); SamplerState s0; Texture * t0 = mTexture.c_ptr(); render->SetTexture(0, s0, t0); render->Render(mTech, &mRender); }
void Shadow::_renderDepth(int layer) { RenderSystem * render = RenderSystem::Instance(); render->SetRenderTarget(0, mRT_Depth.c_ptr()); render->SetDepthStencil(mDepthStencil.c_ptr()); render->ClearBuffer(NULL, true, true, false, Color::White); const Array<Renderer *> & objs = mRenderQueue.GetSolidRender(); ShaderParam * uMatWVP = mTech_ShadowDepth->GetVertexShaderParamTable()->GetParam("matWVP"); ShaderParam * uMatWVPSkin = mTech_ShadowDepthSkin->GetVertexShaderParamTable()->GetParam("matWVP"); for (int j = 0; j < objs.Size(); ++j) { Renderer * rd = objs[j]; if (!IsVisible(rd->GetWorldAabb(), mCascadedMatrix[layer].mViewProj)) continue; bool skined = (rd->GetBlendMatrix(NULL) > 0); Mat4 form; rd->GetWorldTransform(&form); form *= mCascadedMatrix[layer].mViewProj; uMatWVP->SetMatrix(form); uMatWVPSkin->SetMatrix(form); if (!skined) render->Render(mTech_ShadowDepth, rd); else render->Render(mTech_ShadowDepthSkin, rd); } OnRenderDepth(this, &layer); }
void MirrorRenderLoop::DoRender(Camera * cam) { RenderSystem * render = RenderSystem::Instance(); RenderQueue * rq = mScheme->GetMirrorRenderQueue(); // --->render terrain if (Environment::Instance()->GetTerrain()) Environment::Instance()->GetTerrain()->RenderInMirror(); // ---> render sky if (Environment::Instance()->GetSky2()) Environment::Instance()->GetSky2()->RenderReflection(cam->GetMirrorPlane()); // ---> render sun /*if (Environment::Instance()->GetSun()) Environment::Instance()->GetSun()->Render();*/ // ---> render moons if (Environment::Instance()->GetMoon()) Environment::Instance()->GetMoon()->Render(); // ---> render cloud //if (Environment::Instance()->GetCloud()) //Environment::Instance()->GetCloud()->Render(false); // render solider { RenderSystem * render = RenderSystem::Instance(); const Array<Renderer *> & objs = rq->GetSolidRender(); for (int i = 0; i < objs.Size(); ++i) { Renderer * rd = objs[i]; bool skined = (rd->GetBlendMatrix(NULL) > 0); Technique * tech = rd->GetTechnique(eRenderTechType::RTT_Mirror); if (!tech) tech = mScheme->GetMainShaderProvider()->GetTechnique(eRenderTechType::RTT_Mirror, skined); render->Render(tech, rd); } } RenderEvent::OnMirrorRenderSolid1(cam); RenderEvent::OnMirrorRenderSolid2(cam); RenderEvent::OnMirrorRenderSolid3(cam); }
void UnderWaterBubble::Render() { _update(); _emit(); _geom(); Camera * cam = World::Instance()->MainCamera(); RenderSystem * render = RenderSystem::Instance(); SamplerState state; render->SetTexture(0, state, mTex_Bubble0.c_ptr()); render->Render(mTech, &mRender); }
void UnderWaterGodRay::_renderRay() { Camera * cam = World::Instance()->MainCamera(); RenderSystem * render = RenderSystem::Instance(); render->SetRenderTarget(0, mRenderTarget.c_ptr()); render->ClearBuffer(NULL, true, false, false); ShaderParam * uWorldMatrix = mTech_Ray->GetVertexShaderParamTable()->GetParam("matWorld"); uWorldMatrix->SetMatrix(mProjMatrix); render->Render(mTech_Ray, &mRender); mRenderTarget->Stretch(mTexture.c_ptr()); }
void SkinRenderer::Render(Event * _sender) { if (!mEnable) return ; RenderSystem * render = RenderSystem::Instance(); ShaderParam * gScale = mTech->GetVertexShaderParamTable()->GetParam("gScale"); ShaderParam * gBackUVScale = mTech->GetVertexShaderParamTable()->GetParam("gBackUVScale"); int viewW, viewH; App::Instance()->GetViewSize(viewW, viewH); int texW = 512, texH = 256; if (mSkinTexture != NULL) { texW = mSkinTexture->GetWidth(); texH = mSkinTexture->GetHeight(); } float xScale = texW / (float)viewW; float yScale = texH / (float)viewH; gScale->SetUnifom(xScale, yScale, 0, 0); int backW = mBackTexture->GetWidth(); int backH = mBackTexture->GetHeight(); xScale = backW / (float)texW; yScale = backH / (float)texH; gBackUVScale->SetUnifom(1 / xScale, 1 / yScale, 0, 0); SamplerState state; render->SetTexture(0, state, mBackTexture.c_ptr()); render->SetTexture(1, state, mSkinTexture.c_ptr()); render->Render(mTech, mRenderOp); }
void Render() { renderer->Render(); }
void Water::_renderUpWater(WaterBlock * block, Texture * depthTex, Texture * colorTex) { RenderSystem * render = RenderSystem::Instance(); Camera * cam = World::Instance()->MainCamera(); float time = Engine::Instance()->GetTime(); const Vec3 * worldCorner = cam->GetWorldCorner(); const Vec3 & camPos = cam->GetPosition(); Vec3 worldCornerLeftTop = worldCorner[4] - camPos; Vec3 worldCornerRightDir = worldCorner[5] - worldCorner[4]; Vec3 worldCornerDownDir = worldCorner[6] - worldCorner[4]; const Vec3 * viewCorner = cam->GetCorner(); Vec3 viewCornerLeftTop = viewCorner[4]; Vec3 viewCornerRightDir = viewCorner[5] - viewCorner[4]; Vec3 viewCornerDownDir = viewCorner[6] - viewCorner[4]; ShaderParam * uFresnelParam = mTech->GetPixelShaderParamTable()->GetParam("gFresnelParam"); ShaderParam * uCamPos = mTech->GetPixelShaderParamTable()->GetParam("gCameraPos"); ShaderParam * uWorldCornerLeftTop = mTech->GetPixelShaderParamTable()->GetParam("gWorldCornerLeftTop"); ShaderParam * uWorldCornerRightDir = mTech->GetPixelShaderParamTable()->GetParam("gWorldCornerRightDir"); ShaderParam * uWorldCornerDownDir = mTech->GetPixelShaderParamTable()->GetParam("gWorldCornerDownDir"); ShaderParam * uViewCornerLeftTop = mTech->GetPixelShaderParamTable()->GetParam("gViewCornerLeftTop"); ShaderParam * uViewCornerRightDir = mTech->GetPixelShaderParamTable()->GetParam("gViewCornerRightDir"); ShaderParam * uViewCornerDownDir = mTech->GetPixelShaderParamTable()->GetParam("gViewCornerDownDir"); ShaderParam * uDeepColor = mTech->GetPixelShaderParamTable()->GetParam("gDeepColor"); ShaderParam * uRefractionDist = mTech->GetPixelShaderParamTable()->GetParam("gRefractionDist"); ShaderParam * uSunDir = mTech->GetPixelShaderParamTable()->GetParam("gSunDir"); ShaderParam * uSunColor = mTech->GetPixelShaderParamTable()->GetParam("gSunColor"); ShaderParam * uSunLightParam = mTech->GetPixelShaderParamTable()->GetParam("gSunLightParam"); ShaderParam * uNoiseScale = mTech->GetPixelShaderParamTable()->GetParam("gNoiseScale"); ShaderParam * uNoiseUVParam = mTech->GetPixelShaderParamTable()->GetParam("gNoiseUVParam"); ShaderParam * uNormalUVParam = mTech->GetPixelShaderParamTable()->GetParam("gNormalUVParam"); ShaderParam * uNormalWeight = mTech->GetPixelShaderParamTable()->GetParam("gNormalWeight"); ShaderParam * uInvScreenSize = mTech->GetPixelShaderParamTable()->GetParam("gInvScreenSize"); ShaderParam * uFarClip = mTech->GetPixelShaderParamTable()->GetParam("gFarClip"); Vec3 sunDir = Environment::Instance()->GetEvParam()->SunDir; Color4 sunColor = Environment::Instance()->GetEvParam()->SunColor; Color4 deepColor = Environment::Instance()->GetEvParam()->WaterParam.deepColor; uCamPos->SetUnifom(camPos.x, camPos.y, camPos.z, 0); uWorldCornerLeftTop->SetUnifom(worldCornerLeftTop.x, worldCornerLeftTop.y, worldCornerLeftTop.z, 0); uWorldCornerRightDir->SetUnifom(worldCornerRightDir.x, worldCornerRightDir.y, worldCornerRightDir.z, 0); uWorldCornerDownDir->SetUnifom(worldCornerDownDir.x, worldCornerDownDir.y, worldCornerDownDir.z, 0); uViewCornerLeftTop->SetUnifom(viewCornerLeftTop.x, viewCornerLeftTop.y, viewCornerLeftTop.z, 0); uViewCornerRightDir->SetUnifom(viewCornerRightDir.x, viewCornerRightDir.y, viewCornerRightDir.z, 0); uViewCornerDownDir->SetUnifom(viewCornerDownDir.x, viewCornerDownDir.y, viewCornerDownDir.z, 0); uDeepColor->SetUnifom(deepColor.r, deepColor.g, deepColor.b, 1); uRefractionDist->SetUnifom(40, 0, 0, 0); uSunColor->SetUnifom(sunColor.r, sunColor.g, sunColor.b, 0); uSunDir->SetUnifom(-sunDir.x, -sunDir.y, -sunDir.z, 0); uSunLightParam->SetUnifom(0.8f, 200, 0, 0); float uvNoiseScroll = time * 0.02f; uNoiseUVParam->SetUnifom(0.01f, 0.01f, uvNoiseScroll, uvNoiseScroll); uNoiseScale->SetUnifom(0.03f, 0, 0 , 0); Vec4 uvNormalParam[4] = { Vec4 (0.02f, 0.02f, time * 0.03f, time * 0.03f), Vec4 (0.01f, 0.01f, time * 0.03f, time * 0.03f), Vec4 (0.015f, 0.015f, time * 0.03f, time * 0.03f), Vec4 (0.005f, 0.005f, time * 0.03f, time * 0.03f) }; uNormalUVParam->SetVector(uvNormalParam, 4); uNormalWeight->SetUnifom(0.08f, 0.1f, 0.06f, 0.1f); float screenW = (float)Engine::Instance()->GetDeviceProperty()->Width; float screenH = (float)Engine::Instance()->GetDeviceProperty()->Height; uInvScreenSize->SetUnifom(1 / screenW, 1 / screenW, 0, 0); uFarClip->SetUnifom(cam->GetFarClip(), 0, 0, 0); SamplerState state; render->SetTexture(0, state, mTex_Wave.c_ptr()); state.Address = TEXA_CLAMP; state.Filter = TEXF_POINT; render->SetTexture(1, state, depthTex); render->SetTexture(2, state, colorTex); render->SetTexture(3, state, mTex_Refl.c_ptr()); state.Filter = TEXF_LINEAR; render->SetTexture(4, state, mTex_Fresnel.c_ptr()); SamplerState state1; render->SetTexture(5, state1, mTex_Wave.c_ptr()); render->SetTexture(6, state1, mTex_Wave.c_ptr()); render->Render(mTech, block->mRenderOp); }