void RasNormalMap::DoPerVertexLighting( VertexBuffer& workingVB, FaceList& workingFaces, RenderObject& obj ) { const VEC3& camPos = g_env.renderer->m_camera.GetPos().GetVec3(); MAT44 matInvWorld = obj.m_matWorld.Inverse(); for (size_t iVert=0; iVert<obj.m_verts.size(); ++iVert) { SVertex& vert = obj.m_verts[iVert]; // Get the matrix which transforms vector from object space to tangent space MAT44 matTBN; matTBN.SetRow(0, VEC4(vert.tangent, 0)); matTBN.SetRow(1, VEC4(vert.binormal, 0)); matTBN.SetRow(2, VEC4(vert.normal, 0)); // Calc light dir in object space const VEC3& lightDir = g_env.renderer->m_testLight.neg_dir; vert.lightDirTS = Common::Transform_Vec3_By_Mat44(lightDir, matInvWorld, false).GetVec3(); // Transform! vert.lightDirTS = Common::Transform_Vec3_By_Mat44(vert.lightDirTS, matTBN, false).GetVec3(); // Half-angle vector VEC3 eyeDir = Common::Sub_Vec3_By_Vec3(camPos, vert.pos.GetVec3()); eyeDir.Normalize(); Common::Add_Vec3_By_Vec3(vert.halfAngleTS, eyeDir, lightDir); vert.halfAngleTS.Normalize(); vert.halfAngleTS = Common::Transform_Vec3_By_Mat44(vert.halfAngleTS, matTBN, false).GetVec3(); } }
static void keyboardDown(unsigned char key, int x, int y) { Vec3f look_dir, up, right; switch (key) { case 'Q': case 'q': case 27: exit(0); break; case 'w': camera_state |= PCS_MOVING_FORWARD; break; case 'a': camera_state |= PCS_MOVING_LEFT; break; case 's': camera_state |= PCS_MOVING_BACKWARD; break; case 'd': camera_state |= PCS_MOVING_RIGHT; break; case 'p': printf("pos: %f %f %f\n", VEC3(camera.translation)); printf("orient %f %f %f %f\n", VEC4(camera.orientation)); break; } }
void TRenderGlow::init() { enabled = true; global_distance = 1.0f; distance_factors = VEC4(1, 2, 3, 4); weights.x = 1.f; weights.y = 1.f; weights.z = 1.f; weights.w = 1.f; bool is_ok = true; int nsteps = 2; int xres = CApp::get().getXRes(); int yres = CApp::get().getYRes(); static int g_blur_counter = 0; for (int i = 0; i < nsteps; ++i) { TBlurStep* s = new TBlurStep; char blur_name[64]; sprintf(blur_name, "Blur_%02d", g_blur_counter); g_blur_counter++; is_ok &= s->create(blur_name, xres, yres); assert(is_ok); steps.push_back(s); xres /= 2; yres /= 2; } nactive_steps = steps.size(); }
// --------------------- void TRenderDream::renderInMenu() { if (ImGui::DragFloat4("color influence", &shader_ctes_dream.color_influence.x, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("waves size", &shader_ctes_dream.dream_waves_size, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("waves speed", &shader_ctes_dream.dream_speed, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("waves intensity", &shader_ctes_dream.dream_wave_amplitude, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("distorsion strenght", &shader_ctes_dream.dream_distorsion_strenght, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("distorsion expansion", &shader_ctes_dream.dream_distorsion_expansion, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::SmallButton("Load defaults")) { shader_ctes_dream.color_influence = VEC4(0.2, 0.2, 0.3, 1); shader_ctes_dream.dream_speed = 1; shader_ctes_dream.dream_waves_size = 0.5; shader_ctes_dream.dream_wave_amplitude = 8; shader_ctes_dream.dream_distorsion_expansion = 0.85; shader_ctes_dream.dream_distorsion_strenght = 55; } TCompBasicFX::renderInMenu(); }
vec4 paint(s_res res, vec4 lastcol) { s_liret light; s_texmod mod; light.cam.pos = (res.dst - 0.1) * res.cam.ray + res.cam.pos; mod = get_texture(res.mat, light.cam.pos, res.normal); light.diffuse = VEC4(0); light.specular = VEC4(0); res.mat.color = mod.color; res.normal = mod.normal; res.mat.smoothness = mod.smoothness; res.mat.metallic = mod.metallic; REP(LINUM, light, iter_light, lights, light, res); return (max(mix(light.diffuse * mod.color, lastcol * res.mat.metallic + light.specular, mix((1 - abs(dot(res.cam.ray, res.normal))) * res.mat.smoothness, 1, res.mat.metallic)), AMBIENT * res.mat.color)); }
void Camera::_BuildViewMatrix() { m_matView = m_matRot.Transpose(); VEC4 trans; trans = Common::Transform_Vec4_By_Mat44(m_viewPt, m_matView); m_matView.SetTranslation(VEC4(-trans.x, -trans.y, -trans.z, 1)); m_matInvView = m_matView.Inverse(); }
void TRenderDream::init() { enabled = true; tech = Resources.get("dream_effect.tech")->as<CRenderTechnique>(); shader_ctes_dream.color_influence = VEC4(0.2, 0.2, 0.3, 1); shader_ctes_dream.dream_speed = 1; shader_ctes_dream.dream_waves_size = 0.5; shader_ctes_dream.dream_wave_amplitude = 8; shader_ctes_dream.dream_distorsion_expansion = 0.85; shader_ctes_dream.dream_distorsion_strenght = 55; shader_ctes_dream.uploadToGPU(); }
//------------------------------------------------------------------------------- void Water::_InitConstantBuffer() { HRESULT hr = S_OK; D3D11_BUFFER_DESC bd; ZeroMemory( &bd, sizeof(bd) ); bd.Usage = D3D11_USAGE_DEFAULT; bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; bd.CPUAccessFlags = 0; bd.ByteWidth = sizeof(cBufferVSFinal); V(m_pRenderSystem->GetDevice()->CreateBuffer( &bd, NULL, &m_pCB_VS )); m_constantBufVS.texScale = VEC2(25, 26); m_constantBufVS.bumpSpeed = VEC2(0.015f, 0.005f); m_constantBufVS.BumpScale = 0.2f; m_constantBufVS.waveFreq = 0.028f; m_constantBufVS.waveAmp = 1.8f; bd.ByteWidth = sizeof(cBufferPSFinal); V(m_pRenderSystem->GetDevice()->CreateBuffer( &bd, NULL, &m_pCB_PS )); m_constantBufPS.deepColor = VEC4(0.0f, 0.3f, 0.5f, 1.0f); m_constantBufPS.shallowColor = VEC4(0.0f, 1.0f, 1.0f, 1.0f); m_constantBufPS.reflectionColor = VEC4(0.95f, 1.0f, 1.0f, 1.0f); m_constantBufPS.reflectionAmount = 0.2f; m_constantBufPS.reflectionBlur = 0.0f; m_constantBufPS.waterAmount = 0.3f; m_constantBufPS.fresnelPower = 5.0f; m_constantBufPS.fresnelBias = 0.328f; m_constantBufPS.refractionAmount = 0.075f; bd.ByteWidth = sizeof(cBufferDepth); V(m_pRenderSystem->GetDevice()->CreateBuffer( &bd, NULL, &m_pCB_Depth )); m_constantBufDepth.waterPlaneHeight = m_waterPlane.d; m_constantBufDepth.depthLimit = 1.0f / 90.0f; }
VEC4 GetVec4Value( CXTPPropertyGridItemVec4* pItem, bool bReflect ) { // if(bReflect) // pItem->UpdateFromChild(); // // std::wstring strX = Utility::StringCutPrecision(pItem->GetStrX()); // std::wstring strY = Utility::StringCutPrecision(pItem->GetStrY()); // std::wstring strZ = Utility::StringCutPrecision(pItem->GetStrZ()); // std::wstring strW = Utility::StringCutPrecision(pItem->GetStrW()); // // float fX = Ogre::StringConverter::parseReal(Utility::UnicodeToEngine(strX)); // float fY = Ogre::StringConverter::parseReal(Utility::UnicodeToEngine(strY)); // float fZ = Ogre::StringConverter::parseReal(Utility::UnicodeToEngine(strZ)); // float fW = Ogre::StringConverter::parseReal(Utility::UnicodeToEngine(strW)); // // return std::move(Ogre::Quaternion(fX, fY, fZ, fW)); return VEC4(0,0,0,0); }
void ShootManager::renderAll() { PROFILE_FUNCTION("ShootManager: shootLaser"); //const CMesh * unit_sphere = Resources.get("meshes/fx/laser.mesh")->as<CMesh>(); //unit_sphere->activate(); //Shot new_shot = Shot(MAT44::Identity, 1); //shots.push_back(new_shot); for (Shot shot : shots) { //activateWorldMatrix(shot.transform); //unit_sphere->render(); drawLine(shot.origin, shot.end, VEC4(1, 0, 0, 1)); } //shots.clear(); }
int main(int argc, char **argv) { RANDOM_Initialize(); uint start = 0; uint end = 0; printf(" STARTING FRAME : "); fflush(stdin); scanf("%d", &start); printf(" ENDING FRAME : "); fflush(stdin); scanf("%d", &end); fflush(stdin); if (start == end || start > end) return 0; SURFACE* marble_d = NULL; SURFACE* marble_n = NULL; SURFACE* marble_s = NULL; ImportBMPFile("data/marble_d.bmp", &marble_d); ImportBMPFile("data/marble_n.bmp", &marble_n); ImportBMPFile("data/marble_s.bmp", &marble_s); printf("\n"); printf("INITIALIZING SCENE\n\n"); VEC4 CameraPosition = VEC4(1.2f, 0.8f, -2.4f, 1.0); MainCamera = new Camera; MainCamera->position = CameraPosition; MainCamera->dimensions = VEC2(ViewWidth, ViewWidth * 0.75f); MainCamera->focalLength = 16.0f; MainCamera->sampleSize = Samples; Entity* diamond1 = new Entity; Entities.add(diamond1); diamond1->initialize(); ImportOBJFile("data/topDiamond.obj", &diamond1->mesh); diamond1->material->specular = 0.4f; diamond1->material->overlay = COLOR(0.05f, 0.4f, 1.0f, 1.0); diamond1->material->reflection = 1.0f; diamond1->material->refIndex = 1.333f; Entity* diamond2 = new Entity; Entities.add(diamond2); diamond2->initialize(); ImportOBJFile("data/bottomDiamond.obj", &diamond2->mesh); diamond2->material->specular = 0.4f; diamond2->material->overlay = COLOR(0.2f, 1.0f, 0.9f, 1.0); diamond2->material->reflection = 1.0f; diamond2->material->refIndex = 1.333f; Entity* background = new Entity; Entities.add(background); background->initialize(); ImportOBJFile("data/box.obj", &background->mesh); background->material->overlay = COLOR(0.7f, 1.0f, 0.9f, 1.0); background->material->reflection = 1.0f; background->material->specular = 0.4f; Light* light1 = new Light(VEC4(0.8f, 0.2f, -2.4f, 0.0f), VEC3(0.001f, 0.04f, 0.12f), COLOR(1.0f, 1.0f, 1.0f, 1.0f)); Lights.add(light1); light1->shadowIntensity = 0.8f; printf("START RENDERING\n\n"); SURFACE* render = NULL; CreateSurface(&render, "", Width, Height, PIXELFORMAT_RGB); char* filename = new char[128]; uint t = (uint)time(0); for (uint i = start; i < end; i++) { printf("RENDERING FRAME : %03d ", i); ClearBitmap(render, 0x333333); memset(filename, 0, sizeof(char) * 128); sprintf(filename, "RaySequence04_720p/RayTrace.%03d.bmp", i); Theta = float(i) * TurnSpeed; MainCamera->position = VEC4( (CameraPosition.x * cos(Theta)) - (CameraPosition.z * sin(Theta)), CameraPosition.y, (CameraPosition.x * sin(Theta)) + (CameraPosition.z * cos(Theta)), 1.0f); #if 0 light1->position = VEC4( (light1->position.x * cos(-Theta)) - (light1->position.z * sin(-Theta)), light1->position.y, (light1->position.x * sin(-Theta)) + (light1->position.z * cos(-Theta)), 1.0f); #endif //MainCamera->castRays(render); MainCamera->castRays(render); ExportBMPFile(filename, render); printf("DONE\n"); } delete [] filename; FreeSurface(&render); printf("\n"); //printf("FINISHED RENDERING\n\n"); return 0; }
void Camera::SetPosition( const VEC3& pos ) { m_viewPt = VEC4(pos, 1); }
void CImGuiModule::update(float dt) { ImGui_ImplDX11_NewFrame(); ImGuiWindowFlags window_flags = 0; window_flags |= ImGuiWindowFlags_MenuBar; bool menu = true; #ifndef FINAL_BUILD if (controller->IsToogleDebugUIPressed()) show_imgui = !show_imgui; if (!show_imgui) return; ImGui::Begin("Debug UI", &menu, ImVec2(800, 512), -1.0f, window_flags); ImGui::PushItemWidth(-140); // Right align, keep 140 pixels for labels m_pLights_editor->update(dt); m_pMessages_editor->update(dt); //Engine Apps //--------------------------------------- if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("Apps")) { ImGui::MenuItem("Log (L)", NULL, Debug->getStatus()); ImGui::MenuItem("Commands (O)", NULL, Debug->GetCommandsConsoleState()); ImGui::MenuItem("Particle editor (F8)", NULL, g_particlesManager->GetParticleEditorState()); ImGui::MenuItem("Lights editor (F9)", NULL, m_pLights_editor->GetLightsEditorState()); ImGui::MenuItem("Messages editor (F10)", NULL, m_pMessages_editor->GetEditorState()); //Debug->OpenConsole(); ImGui::EndMenu(); } ImGui::EndMenuBar(); } //--------------------------------------- //Current Level IMGUI_SHOW_INT(CApp::get().GetLevelNumber()); //Language IMGUI_SHOW_STRING(lang_manager->GetLanguage()); //Difficulty IMGUI_SHOW_INT(GameController->GetDifficulty()); //Extra wait end frame if (ImGui::TreeNode("Physx Timing")) { float tmax_update = g_PhysxManager->GetTMaxUpdate(); ImGui::PushItemWidth(100); if (ImGui::DragFloat("tmax_update", &tmax_update, 0.01f)) { g_PhysxManager->SetTMaxUpdate(tmax_update); } ImGui::DragFloat("Wait end frame", CApp::get().GetWaitEnd()); if (ImGui::Checkbox("Multi simulate", g_PhysxManager->GetMultiSimulatePointer())) { dbg("Changed Multisimulate\n"); } ImGui::PopItemWidth(); ImGui::TreePop(); } //Last Input ImGui::Checkbox("Gamepad Mode", io->IsGamePadModePointer()); //Buttons game //--------------------------------------- if (GameController->GetGameState() == CGameController::RUNNING) { IMGUI_SHOW_INT(CGameController::RUNNING); if (ImGui::Button("PAUSE BUTTON")) GameController->SetGameState(CGameController::STOPPED); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 1, 0, 1)); if (ImGui::Button("RESUME BUTTON")) GameController->SetGameState(CGameController::RUNNING); ImGui::PopStyleColor(); } else if (GameController->GetGameState() == CGameController::STOPPED) { IMGUI_SHOW_INT(CGameController::STOPPED); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 1, 0, 1)); if (ImGui::Button("PAUSE BUTTON")) GameController->SetGameState(CGameController::STOPPED); ImGui::PopStyleColor(); ImGui::SameLine(); if (ImGui::Button("RESUME BUTTON")) GameController->SetGameState(CGameController::RUNNING); } ImGui::SameLine(); if (ImGui::Button("SKIP Cine.")) { logic_manager->throwUserEvent("cam:skip_cinematic();"); } //Select Level { ImGui::PushItemWidth(80); static int level_selected = 1; if (ImGui::InputInt("", &level_selected)) { if (level_selected > 4) level_selected = 0; if (level_selected < 0) level_selected = 4; } ImGui::SameLine(); auto name_scenes = CApp::get().GetNameScenes(); char logic_level[] = "level_X"; logic_level[6] = '0' + (unsigned char)(level_selected); ImGui::SameLine(); ImGui::Text("%s", name_scenes[logic_level].c_str()); ImGui::SameLine(); if (ImGui::Button("Load Level")) { char lua_code[256]; sprintf(lua_code, "p:stop_music(); p:setup_game(); LoadLevel(\"level_%d\")", level_selected); logic_manager->throwUserEvent(lua_code); } ImGui::PopItemWidth(); } if (ImGui::Button("SAVE GAME")) CApp::get().saveLevel(); if (ImGui::Button("LOAD GAME")) CApp::get().restartLevelNotify(); ImGui::Checkbox("Free camera (K)", GameController->GetFreeCameraPointer()); ImGui::Checkbox("Ui control", Gui->IsUiControlPointer()); //ImGui::Checkbox("Continous Collision Detection", &(g_PhysxManager->ccdActive)); if (ImGui::TreeNode("LUA Test")) { static char test_lua_txt[256] = "OnTest();"; ImGui::InputTextMultiline("Test Lua", test_lua_txt, 256); if (ImGui::Button("Execute")) { logic_manager->throwUserEvent(test_lua_txt); } ImGui::TreePop(); } if (ImGui::TreeNode("Gui create elements")) { static VEC3 pos_new_ui = VEC3(0.5f, 0.5f, 0.9f); static char gui_prebab_name[64] = "Fading_Letter"; static char gui_prebab_entity_name[64] = "TEST"; ImGui::DragFloat3("Pos", &pos_new_ui.x, 0.1f, -1.f, 2.f); ImGui::InputText("Prefab name", gui_prebab_name, 64); ImGui::InputText("Entity name", gui_prebab_entity_name, 64); if (ImGui::Button("Create")) { CHandle gui_elem = Gui->addGuiElement(std::string("ui/") + std::string(gui_prebab_name), pos_new_ui); GET_COMP(name, gui_elem, TCompName); name->setName(gui_prebab_entity_name); } ImGui::TreePop(); } if (ImGui::TreeNode("TestMessages")) { static char test_msg_txt[256] = "*MOUSE* *LMOUSE* *RMOUSE*\n*LB* *RB* *BACK* *START* *LSTICK* *RSTICK* *APAD* *BPAD* *XPAD* *YPAD*\n*SHIFT* *ENTER* *SPACE* *ESC* *WKEY* *AKEY* *SKEY* *DKEY*"; ImGui::InputTextMultiline("Test Message", test_msg_txt, 256); if (ImGui::Button("Create Message")) { std::string text = test_msg_txt; getHandleManager<TCompFadingMessage>()->each([text](TCompFadingMessage * mess) { TCompFadingMessage::ReloadInfo atts; atts.text = text; mess->reload(atts); } ); } ImGui::TreePop(); } if (ImGui::TreeNode("Free camera instructions")) { ImGui::Text("w/a/s/d - normal move\nq/e - up/down\nmouse wheel - speed up/down\n"); ImGui::TreePop(); } ImGui::Separator(); //--------------------------------------- #ifdef CALIBRATE_GAME if (ImGui::TreeNode("CALIBRATE")) { if (ImGui::TreeNode("Bomb sci")) { ImGui::Checkbox("Calibrate", &CThrowBomb::calibrate); IMGUI_DRAG_FLOAT(CThrowBomb::lmax_st, 0.01f, 0.1f, 10.f); IMGUI_DRAG_FLOAT(CThrowBomb::hmax_st, 0.01f, 0.1f, 10.f); IMGUI_DRAG_FLOAT(CThrowBomb::speed_st, 0.01f, 0.1f, 10.f); IMGUI_DRAG_FLOAT(CThrowBomb::radius_st, 0.01f, 0.1f, 10.f); ImGui::DragFloat3("offset start throw", &CThrowBomb::offset_init_throw.x, 0.01f, -1.f, 1.f); ImGui::TreePop(); } ImGui::TreePop(); } #endif //Profiling //--------------------------------------- #ifdef PROFILING_ENABLED //header for filtering instructions if (ImGui::TreeNode("PROFILING")) { static int nframes = 5; static float time_threshold = 5; ImGui::InputInt("NFrames", &nframes, 1, 5); ImGui::Separator(); if (ImGui::Button("Start Capture Profiling")) profiler->setNFramesToCapture(nframes); #ifndef PROFILING_JOHN ImGui::Separator(); ImGui::InputFloat("Time Threshold", &time_threshold, 1, 5); if (profiler->isAutoCapture()) { ImGui::Text("Waiting auto capture..."); } else { if (ImGui::Button("Auto Capture Profiling")) profiler->setAutoCapture(nframes, time_threshold); } #endif ImGui::TreePop(); } #endif //--------------------------------------- //Filter options //--------------------------------------- ImGui::Text("Filtering"); //header for filtering instructions if (ImGui::TreeNode("instructions filtering")) { ImGui::Text("Filter usage:\n" " \"\" display all lines\n" " \"xxx\" display lines containing \"xxx\"\n" " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n" " \"-xxx\" hide lines containing \"xxx\""); ImGui::TreePop(); } //end header instructions //static ImGuiTextFilter filter; filter.Draw(); //filter text draw //--------------------------------------- if (ImGui::CollapsingHeader("General Info")) { ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); } if (ImGui::CollapsingHeader("Resources")) { Resources.renderUIDebug(&filter); } if (ImGui::CollapsingHeader("Entities")) { getHandleManager<CEntity>()->onAll(&CEntity::renderInMenu); } if (ImGui::CollapsingHeader("PostProcess")) { render_fx->renderInMenu(); } if (ImGui::CollapsingHeader("SELECTED ENTITY")) { ImGui::Text("Application SELECTED ENTITY - TODO"); }if (ImGui::CollapsingHeader("Entity by Tag")) { ImGui::Text("Application ENTITY TAG - TODO"); tags_manager.renderInMenu(); } if (ImGui::CollapsingHeader("Game Options")) { ImGui::Checkbox("god mode", GameController->GetCheatGodmodePointer()); }if (ImGui::CollapsingHeader("Graficos")) { if (ImGui::TreeNode("polarize")) { //ImGui::SliderFloat("Polarize strength", &shader_ctes_globals.strenght_polarize, 0.0f, 2.0f); ImGui::TreePop(); } if (ImGui::TreeNode("Dream shader options")) { if (ImGui::DragFloat4("color influence", &shader_ctes_dream.color_influence.x, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("waves size", &shader_ctes_dream.dream_waves_size, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("waves speed", &shader_ctes_dream.dream_speed, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("waves intensity", &shader_ctes_dream.dream_wave_amplitude, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("distorsion strenght", &shader_ctes_dream.dream_distorsion_strenght, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::DragFloat("distorsion expansion", &shader_ctes_dream.dream_distorsion_expansion, 0.01f)) { shader_ctes_dream.uploadToGPU(); } if (ImGui::SmallButton("Load defaults")) { shader_ctes_dream.color_influence = VEC4(0.5, 0.5, 0.8, 1); shader_ctes_dream.dream_speed = 1; shader_ctes_dream.dream_waves_size = 0.5; shader_ctes_dream.dream_wave_amplitude = 8; shader_ctes_dream.dream_distorsion_expansion = 0.85; shader_ctes_dream.dream_distorsion_strenght = 55; } ImGui::TreePop(); } if (ImGui::TreeNode("Shadow options")) { if (ImGui::DragFloat("Environment diffuse factor", &shader_ctes_globals.env_factor, 0.01f)) { shader_ctes_globals.uploadToGPU(); } if (ImGui::DragFloat("Shadow intensity", &shader_ctes_globals.shadow_intensity, 0.01f)) { shader_ctes_globals.uploadToGPU(); } if (ImGui::TreeNode("ssao")) { if (ImGui::DragFloat("ssao intensity", &shader_ctes_blur.ssao_intensity)) { shader_ctes_blur.uploadToGPU(); } if (ImGui::DragFloat("ssao iterations", &shader_ctes_blur.ssao_iterations)) { shader_ctes_blur.uploadToGPU(); } ImGui::Separator(); if (ImGui::DragFloat("ssao intensity test", &shader_ctes_blur.ssao_test_intensity, 0.01f)) { shader_ctes_blur.uploadToGPU(); } if (ImGui::DragFloat("ssao bias test", &shader_ctes_blur.ssao_bias, 0.01f)) { shader_ctes_blur.uploadToGPU(); } if (ImGui::DragFloat("ssao scale test", &shader_ctes_blur.ssao_scale, 0.01f)) { shader_ctes_blur.uploadToGPU(); } if (ImGui::DragFloat("ssao rad test", &shader_ctes_blur.ssao_sample_rad, 0.01f)) { shader_ctes_blur.uploadToGPU(); } ImGui::TreePop(); } ImGui::TreePop(); } if (ImGui::TreeNode("Grafic options")) { ImGui::Checkbox("polarize effects(disabled)", GameController->GetFxPolarizePointer()); ImGui::Checkbox("glow effect(disabled)", GameController->GetFxGlowPointer()); if (ImGui::DragFloat("Specular force", &shader_ctes_hatching.specular_force)) { shader_ctes_hatching.uploadToGPU(); } static bool use_ramp = shader_ctes_globals.use_ramp; if (ImGui::Checkbox("use ramp", &use_ramp)) { shader_ctes_globals.use_ramp = use_ramp; } static bool use_ramp_color = shader_ctes_globals.use_ramp_color; if (ImGui::Checkbox("use ramp color", &use_ramp_color)) { shader_ctes_globals.use_ramp_color = use_ramp_color; } ImGui::TreePop(); } if (ImGui::TreeNode("Hatching test")) { ImGui::Text("Limit lines hatching (DISABLED, not working)"); if (ImGui::DragFloat("Rim strength", &shader_ctes_hatching.rim_strenght, 0.1f)) { shader_ctes_hatching.uploadToGPU(); } if (ImGui::DragFloat("Specular strength", &shader_ctes_hatching.specular_strenght, 0.1f)) { shader_ctes_hatching.uploadToGPU(); } if (ImGui::DragFloat("Diffuse strength", &shader_ctes_hatching.diffuse_strenght, 0.1f)) { shader_ctes_hatching.uploadToGPU(); } ImGui::Separator(); ImGui::Text("Lines hatching options"); if (ImGui::DragFloat("Size hatching lines", &shader_ctes_hatching.frequency_texture, 0.1f)) { shader_ctes_hatching.uploadToGPU(); } if (ImGui::DragFloat("Intensity transparency lines", &shader_ctes_hatching.intensity_sketch, 0.1f)) { shader_ctes_hatching.uploadToGPU(); } if (ImGui::DragFloat("Frequency change offset", &shader_ctes_hatching.frequency_offset, 0.1f)) { shader_ctes_hatching.uploadToGPU(); } ImGui::Separator(); ImGui::Text("Outline options"); ImGui::Text("Quantity lines: more low to more lines. Will do strange things"); if (ImGui::DragFloat("Quantity lines found", &shader_ctes_hatching.edge_lines_detection, 0.0001f, 0.0000000001f)) { shader_ctes_hatching.uploadToGPU(); } ImGui::TreePop(); } if (ImGui::TreeNode("Ramp shading options")) { ImGui::Text("Color influence from ramp, will work better with white lights, will mix lights"); bool color_ramp = false; if (shader_ctes_hatching.color_ramp == 0.0f) color_ramp = false; else color_ramp = true; if (ImGui::Checkbox("color from ramp", &color_ramp)) { if (color_ramp) { shader_ctes_hatching.color_ramp = 1.0f; shader_ctes_hatching.uploadToGPU(); } else { shader_ctes_hatching.color_ramp = 0.0f; shader_ctes_hatching.uploadToGPU(); } } ImGui::TreePop(); } }if (ImGui::CollapsingHeader("Culling")) { RenderManager.renderUICulling(SBB::readSala()); TCompSkeleton::renderUICulling(); ImGui::Checkbox("show culling collider", GameController->GetCullingRenderPointer()); } if (ImGui::CollapsingHeader("Particles")) { g_particlesManager->renderInMenu(); } ImGui::End(); #endif //TESTS DEBUG: //TestGameLog(); //testLines(); //bool open = true; //ShowExampleAppConsole(&open); //test console commands //Debug->update(); //update log m_pLights_editor->RenderInMenu(); m_pMessages_editor->RenderInMenu(); }
// --------------------- void TRenderGlow::renderInMenu() { ImGui::Checkbox("Enabled", &enabled); ImGui::DragInt("# Steps", &nactive_steps, 0.1f, 0, steps.size()); ImGui::InputFloat("Weights Center", &weights.x); ImGui::InputFloat("Weights 1st", &weights.y); ImGui::InputFloat("Weights 2nd", &weights.z); ImGui::InputFloat("Weights 3rd", &weights.w); if (ImGui::SmallButton("box")) { distance_factors = VEC4(1, 2, 3, 4); weights = VEC4(1, 1, 1, 1); } ImGui::SameLine(); if (ImGui::SmallButton("gauss")) { weights = VEC4(70, 56, 28, 8); distance_factors = VEC4(1, 2, 3, 4); } ImGui::SameLine(); if (ImGui::SmallButton("linear")) { // This is a 5 taps kernel (center + 2 taps on each side) // http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/ weights = VEC4(0.2270270270f, 0.3162162162f, 0.0702702703f, 0.f); distance_factors = VEC4(1.3846153846f, 3.2307692308f, 0.f, 0.f); } if (ImGui::SmallButton("Preset1")) { weights = VEC4(70, 56, 28, 8); distance_factors = VEC4(1, 2, 3, 4); global_distance = 2.7f; //nactive_steps = 3; } if (ImGui::SmallButton("Preset2")) { weights = VEC4(70, 56, 28, 8); distance_factors = VEC4(1, 2, 3, 4); global_distance = 2.0f; //nactive_steps = 2; } ImGui::DragFloat("global_distance", &global_distance, 0.1f, 0.1f, 8.0f); ImGui::InputFloat("Distance 2nd Tap", &distance_factors.x); ImGui::InputFloat("Distance 3rd Tap", &distance_factors.y); ImGui::InputFloat("Distance 4th Tap", &distance_factors.z); if (ImGui::SmallButton("Default Distances")) { distance_factors = VEC4(1, 2, 3, 4); } }
bool OgreMeshLoader::LoadImpl( const STRING& filename, bool bFlipUV ) { TiXmlDocument doc; if(!doc.LoadFile(filename.c_str())) { throw std::logic_error("Error, Can't load .mesh file! Please make sure it's xml format!"); return false; } m_objs.clear(); SR::RenderObject* obj = new SR::RenderObject; m_objs.push_back(obj); TiXmlElement* submeshNode = doc.FirstChildElement("mesh")->FirstChildElement("submeshes")->FirstChildElement("submesh"); //读取面信息 { TiXmlElement* facesNode = submeshNode->FirstChildElement("faces"); int nFace = 0; facesNode->Attribute("count", &nFace); obj->m_faces.resize(nFace); int idx = 0; TiXmlElement* faceNode = facesNode->FirstChildElement("face"); while (faceNode) { int v1, v2, v3; faceNode->Attribute("v1", &v1); faceNode->Attribute("v2", &v2); faceNode->Attribute("v3", &v3); SR::SFace face(v1, v2, v3); obj->m_faces[idx++] = std::move(face); faceNode = faceNode->NextSiblingElement("face"); } } //读取顶点数据 { TiXmlElement* geometryNode = submeshNode->FirstChildElement("geometry"); int nVert = 0; geometryNode->Attribute("vertexcount", &nVert); obj->m_verts.resize(nVert); TiXmlElement* vbNode = geometryNode->FirstChildElement("vertexbuffer"); //check what we have.. if(vbNode->Attribute("positions") != STRING("true")) { throw std::logic_error("Error, the .mesh file doesn't even have vertex position info!"); return false; } if(vbNode->Attribute("normals") != STRING("true")) { throw std::logic_error("Error, the .mesh file doesn't even have vertex normal info!"); return false; } int idx = 0; TiXmlElement* vertNode = vbNode->FirstChildElement("vertex"); while (vertNode) { //position TiXmlElement* posNode = vertNode->FirstChildElement("position"); double x, y, z; posNode->Attribute("x", &x); posNode->Attribute("y", &y); posNode->Attribute("z", &z); //normal TiXmlElement* normalNode = vertNode->FirstChildElement("normal"); double nx, ny, nz; normalNode->Attribute("x", &nx); normalNode->Attribute("y", &ny); normalNode->Attribute("z", &nz); //uv TiXmlElement* uvNode = vertNode->FirstChildElement("texcoord"); double texu, texv; if(uvNode) { uvNode->Attribute("u", &texu); uvNode->Attribute("v", &texv); if(bFlipUV) texv = 1 - texv; } SR::SVertex vert; vert.pos = VEC4(x, y, z, 1); vert.normal = VEC3(nx, ny, nz); vert.normal.Normalize(); if(uvNode) vert.uv = VEC2(texu, texv); obj->m_verts[idx++] = std::move(vert); vertNode = vertNode->NextSiblingElement("vertex"); } } return true; }