| 92 | TextureAssetRef smoke_texture; |
| 93 | |
| 94 | void DrawGPUParticleField(SceneGraph* scenegraph, const char* type) { |
| 95 | if (g_debug_runtime_disable_gpu_particle_field_draw) { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | static bool initialized = false; |
| 100 | |
| 101 | if (initialized == false) { |
| 102 | smoke_texture = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/smoke.tga"); |
| 103 | initialized = true; |
| 104 | } |
| 105 | |
| 106 | Graphics* graphics = Graphics::Instance(); |
| 107 | Shaders* shaders = Shaders::Instance(); |
| 108 | Camera* cam = ActiveCameras::Get(); |
| 109 | Textures* textures = Textures::Instance(); |
| 110 | mat4 proj_view_matrix = cam->GetProjMatrix() * cam->GetViewMatrix(); |
| 111 | CHECK_GL_ERROR(); |
| 112 | |
| 113 | GLState gl_state; |
| 114 | gl_state.blend = true; |
| 115 | gl_state.depth_test = true; |
| 116 | gl_state.depth_write = false; |
| 117 | gl_state.cull_face = false; |
| 118 | graphics->setGLState(gl_state); |
| 119 | graphics->setAdditiveBlend(false); |
| 120 | glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); |
| 121 | |
| 122 | int shader_id; |
| 123 | { |
| 124 | // Get shader id with flags |
| 125 | char shader_name[ParticleType::kMaxNameLen]; |
| 126 | if (g_particle_field_simple) { |
| 127 | FormatString(shader_name, ParticleType::kMaxNameLen, "envobject #GPU_PARTICLE_FIELD #GPU_PARTICLE_FIELD_SIMPLE %s %s", type, global_shader_suffix); |
| 128 | } else { |
| 129 | FormatString(shader_name, ParticleType::kMaxNameLen, "envobject #GPU_PARTICLE_FIELD %s %s", type, global_shader_suffix); |
| 130 | } |
| 131 | shader_id = shaders->returnProgram(shader_name); |
| 132 | } |
| 133 | shaders->setProgram(shader_id); |
| 134 | shaders->SetUniformMat4("mvp", proj_view_matrix); |
| 135 | shaders->SetUniformMat4("projection_matrix", cam->GetProjMatrix()); |
| 136 | shaders->SetUniformMat4("view_matrix", cam->GetViewMatrix()); |
| 137 | shaders->SetUniformFloat("time", game_timer.GetRenderTime()); |
| 138 | if (Engine::Instance()->paused) { |
| 139 | shaders->SetUniformFloat("time_scale", 0.05f); |
| 140 | } else { |
| 141 | shaders->SetUniformFloat("time_scale", game_timer.time_scale); |
| 142 | } |
| 143 | |
| 144 | shaders->SetUniformFloat("haze_mult", scenegraph->haze_mult); |
| 145 | |
| 146 | textures->bindTexture(smoke_texture->GetTextureRef()); |
| 147 | |
| 148 | { // Bind shadow matrices to shader |
| 149 | std::vector<mat4> shadow_matrix; |
| 150 | shadow_matrix.resize(4); |
| 151 | for (int i = 0; i < 4; ++i) { |
no test coverage detected