void Renderer::DrawWater() { SetCurrentShader(reflectShader); SetShaderLight(*light); glUniform3fv(glGetUniformLocation(currentShader->GetProgram(), "cameraPos"), 1, (float*)&camera->GetPosition()); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "diffuseTex"), 0); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "cubeTex"), 2); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMap); float heightX = (RAW_WIDTH * HEIGHTMAP_X / 2.0f); float heightY = 256 * HEIGHTMAP_Y / 3.0f; float heightZ = (RAW_HEIGHT * HEIGHTMAP_Z /2.0f); modelMatrix = Matrix4::Translation(Vector3(heightX, heightY, heightZ)) * Matrix4::Scale(Vector3(heightX, 1, heightZ)) * Matrix4::Rotation(90, Vector3(1.0f, 0.0f, 0.0f)); textureMatrix = Matrix4::Scale(Vector3(10.0f,10.0f,10.0f)) * Matrix4::Rotation(waterRotate, Vector3(0.0f, 0.0f, 1.0f)); UpdateShaderMatrices(); quad->Draw(); glUseProgram(0); }
void Renderer::RenderScene(){ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glUseProgram(currentShader->GetProgram()); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "diffuseTex"), 0); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "bumpTex"), 1); glUniform3fv(glGetUniformLocation(currentShader->GetProgram(), "cameraPos"), 1,(float*)&camera->GetPosition()); UpdateShaderMatrices(); SetShaderLight(*light); heightMap->Draw(); glUseProgram(0); SwapBuffers(); }
void Renderer::DrawHeightMap() { SetCurrentShader(lightShader); SetShaderLight(*light); glUniform3fv(glGetUniformLocation(currentShader->GetProgram(), "cameraPos"), 1, (float*)&camera->GetPosition()); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "diffuseTex"), 0); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "bumpTex"), 1); modelMatrix.ToIdentity(); textureMatrix.ToIdentity(); UpdateShaderMatrices(); heightMap->Draw(); glUseProgram(0); }
void Renderer::DrawCombinedScene(){ SetCurrentShader(sceneShader); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "diffuseTex"), 0); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "bumpTex"), 1); glUniform1i(glGetUniformLocation(currentShader->GetProgram(), "shadowTex"), 2); glUniform3fv(glGetUniformLocation(currentShader->GetProgram(), "cameraPos"), 1, (float*)&camera->GetPosition()); SetShaderLight(*light); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, shadowTex); viewMatrix = camera->BuildViewMatrix(); UpdateShaderMatrices(); DrawFloor(); DrawMesh(); glUseProgram(0); }
void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool fullbright, const FColormap *cmap, bool isadditive) { PalEntry fogcolor; float fogdensity; if (Level->flags&LEVEL_HASFADETABLE) { fogdensity = 70; fogcolor = 0x808080; } else if (cmap != NULL && !fullbright) { fogcolor = cmap->FadeColor; fogdensity = GetFogDensity(lightlevel, fogcolor, cmap->FogDensity, cmap->BlendFactor); fogcolor.a = 0; } else { fogcolor = 0; fogdensity = 0; } // Make fog a little denser when inside a skybox if (screen->mPortalState->inskybox) fogdensity += fogdensity / 2; // no fog in enhanced vision modes! if (fogdensity == 0 || gl_fogmode == 0) { state.EnableFog(false); state.SetFog(0, 0); } else { if ((lightmode == ELightMode::Doom || (isSoftwareLighting() && cmap->BlendFactor > 0)) && fogcolor == 0) { float light = (float)CalcLightLevel(lightlevel, rellight, false, cmap->BlendFactor); SetShaderLight(state, light, lightlevel); } else { state.SetLightParms(1.f, 0.f); } // For additive rendering using the regular fog color here would mean applying it twice // so always use black if (isadditive) { fogcolor = 0; } state.EnableFog(true); state.SetFog(fogcolor, fogdensity); // Korshun: fullbright fog like in software renderer. if (isSoftwareLighting() && cmap->BlendFactor == 0 && Level->brightfog && fogdensity != 0 && fogcolor != 0) { state.SetSoftLightLevel(255); } } }