forked from mirror/openmw-tes3mp
fixed some textures, started with sky
This commit is contained in:
parent
71c865e2e9
commit
a095572205
13 changed files with 244 additions and 21 deletions
|
@ -270,12 +270,10 @@ void RenderingManager::setWaterHeight(const float height)
|
|||
|
||||
void RenderingManager::skyEnable ()
|
||||
{
|
||||
/*
|
||||
if(mSkyManager)
|
||||
mSkyManager->enable();
|
||||
|
||||
mOcclusionQuery->setSunNode(mSkyManager->getSunNode());
|
||||
*/
|
||||
}
|
||||
|
||||
void RenderingManager::skyDisable ()
|
||||
|
|
|
@ -416,7 +416,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
|||
void SkyManager::create()
|
||||
{
|
||||
/// \todo preload all the textures and meshes that are used for sky rendering
|
||||
/*
|
||||
|
||||
// Create overlay used for thunderstorm
|
||||
MaterialPtr material = MaterialManager::getSingleton().create( "ThunderMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
|
||||
Pass* pass = material->getTechnique(0)->getPass(0);
|
||||
|
@ -517,6 +517,7 @@ void SkyManager::create()
|
|||
stars_fp->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
||||
stars_fp->getDefaultParameters()->setNamedAutoConstant("diffuse", GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
|
||||
|
||||
/*
|
||||
for (unsigned int i=0; i<night1_ent->getNumSubEntities(); ++i)
|
||||
{
|
||||
MaterialPtr mp = night1_ent->getSubEntity(i)->getMaterial();
|
||||
|
@ -531,6 +532,7 @@ void SkyManager::create()
|
|||
mp->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
||||
mStarsMaterials[i] = mp;
|
||||
}
|
||||
*/
|
||||
|
||||
// Atmosphere (day)
|
||||
mesh = NifOgre::NIFLoader::load("meshes\\sky_atmosphere.nif");
|
||||
|
@ -543,8 +545,9 @@ void SkyManager::create()
|
|||
atmosphere_ent->setVisibilityFlags(RV_Sky);
|
||||
mAtmosphereDay = mRootNode->createChildSceneNode();
|
||||
mAtmosphereDay->attachObject(atmosphere_ent);
|
||||
mAtmosphereMaterial = atmosphere_ent->getSubEntity(0)->getMaterial();
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
||||
atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere");
|
||||
//mAtmosphereMaterial = atmosphere_ent->getSubEntity(0)->getMaterial();
|
||||
//mAtmosphereMaterial->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
||||
|
||||
// Atmosphere shader
|
||||
HighLevelGpuProgramPtr vshader = mgr.createProgram("Atmosphere_VP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
|
@ -570,7 +573,7 @@ void SkyManager::create()
|
|||
vshader->load();
|
||||
|
||||
vshader->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setVertexProgram(vshader->getName());
|
||||
//mAtmosphereMaterial->getTechnique(0)->getPass(0)->setVertexProgram(vshader->getName());
|
||||
|
||||
HighLevelGpuProgramPtr fshader = mgr.createProgram("Atmosphere_FP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
"cg", GPT_FRAGMENT_PROGRAM);
|
||||
|
@ -598,7 +601,7 @@ void SkyManager::create()
|
|||
fshader->load();
|
||||
|
||||
fshader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(fshader->getName());
|
||||
// mAtmosphereMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(fshader->getName());
|
||||
|
||||
// Clouds
|
||||
NifOgre::NIFLoader::load("meshes\\sky_clouds_01.nif");
|
||||
|
@ -607,8 +610,9 @@ void SkyManager::create()
|
|||
clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5);
|
||||
SceneNode* clouds_node = mRootNode->createChildSceneNode();
|
||||
clouds_node->attachObject(clouds_ent);
|
||||
mCloudMaterial = clouds_ent->getSubEntity(0)->getMaterial();
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
||||
//mCloudMaterial = clouds_ent->getSubEntity(0)->getMaterial();
|
||||
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds");
|
||||
//mCloudMaterial->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
||||
clouds_ent->setCastShadows(false);
|
||||
|
||||
// Clouds vertex shader
|
||||
|
@ -635,7 +639,7 @@ void SkyManager::create()
|
|||
vshader2->setSource(outStream3.str());
|
||||
vshader2->load();
|
||||
vshader2->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->setVertexProgram(vshader2->getName());
|
||||
//mCloudMaterial->getTechnique(0)->getPass(0)->setVertexProgram(vshader2->getName());
|
||||
|
||||
// Clouds fragment shader
|
||||
mCloudFragmentShader = mgr.createProgram("Clouds_FP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
|
@ -670,17 +674,19 @@ void SkyManager::create()
|
|||
mCloudFragmentShader->setSource(outStream2.str());
|
||||
mCloudFragmentShader->load();
|
||||
mCloudFragmentShader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(mCloudFragmentShader->getName());
|
||||
//mCloudMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(mCloudFragmentShader->getName());
|
||||
setCloudsOpacity(0.75);
|
||||
|
||||
ModVertexAlpha(clouds_ent, 1);
|
||||
|
||||
// I'm not sure if the materials are being used by any other objects
|
||||
// Make a unique "modifiable" copy of the materials to be sure
|
||||
mCloudMaterial = mCloudMaterial->clone("Clouds");
|
||||
clouds_ent->getSubEntity(0)->setMaterial(mCloudMaterial);
|
||||
mAtmosphereMaterial = mAtmosphereMaterial->clone("Atmosphere");
|
||||
atmosphere_ent->getSubEntity(0)->setMaterial(mAtmosphereMaterial);
|
||||
//mCloudMaterial = mCloudMaterial->clone("Clouds");
|
||||
//clouds_ent->getSubEntity(0)->setMaterial(mCloudMaterial);
|
||||
//mAtmosphereMaterial = mAtmosphereMaterial->clone("Atmosphere");
|
||||
//atmosphere_ent->getSubEntity(0)->setMaterial(mAtmosphereMaterial);
|
||||
|
||||
/*
|
||||
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1.0, 1.0, 1.0);
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setDiffuse(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -694,9 +700,9 @@ void SkyManager::create()
|
|||
mCloudMaterial->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("textures\\tx_sky_cloudy.dds");
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("");
|
||||
*/
|
||||
|
||||
mCreated = true;
|
||||
*/
|
||||
}
|
||||
|
||||
SkyManager::~SkyManager()
|
||||
|
@ -724,7 +730,7 @@ void SkyManager::update(float duration)
|
|||
if (!mEnabled) return;
|
||||
|
||||
// UV Scroll the clouds
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f);
|
||||
//mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f);
|
||||
|
||||
/// \todo improve this
|
||||
mMasser->setPhase( static_cast<Moon::Phase>( (int) ((mDay % 32)/4.f)) );
|
||||
|
@ -791,12 +797,14 @@ void SkyManager::setMoonColour (bool red)
|
|||
void SkyManager::setCloudsOpacity(float opacity)
|
||||
{
|
||||
if (!mCreated) return;
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("opacity", Real(opacity));
|
||||
//mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("opacity", Real(opacity));
|
||||
}
|
||||
|
||||
void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
||||
{
|
||||
if (!mCreated) return;
|
||||
|
||||
/*
|
||||
if (mClouds != weather.mCloudTexture)
|
||||
{
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("textures\\"+weather.mCloudTexture);
|
||||
|
@ -857,6 +865,7 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
|||
mStarsOpacity = weather.mNightFade;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
float strength;
|
||||
float timeofday_angle = std::abs(mSunGlare->getPosition().z/mSunGlare->getPosition().length());
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <OgreRoot.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <extern/shiny/Main/Factory.hpp>
|
||||
|
||||
|
|
2
extern/shiny
vendored
2
extern/shiny
vendored
|
@ -1 +1 @@
|
|||
Subproject commit ccaaefa59c0500cf790a1f3114c8b5593489afeb
|
||||
Subproject commit 1d689a23fa685ab680351219c32953a3bed7ac0c
|
|
@ -0,0 +1,38 @@
|
|||
#include "core.h"
|
||||
|
||||
#define MRT @shPropertyBool(mrt_output)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
shUniform(float4 materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
shUniform(float4 materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColor(0) = float4(1,1,1,materialDiffuse.a) * float4(materialEmissive.xyz, 1) * shSample(diffuseMap, UV);
|
||||
|
||||
#if MRT
|
||||
shOutputColor(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,15 @@
|
|||
shader_set atmosphere_vertex
|
||||
{
|
||||
source atmosphere.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set atmosphere_fragment
|
||||
{
|
||||
source atmosphere.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#include "core.h"
|
||||
|
||||
#define MRT @shPropertyBool(mrt_output)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
shUniform(float4 materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
shUniform(float4 materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColor(0) = float4(1,1,1,materialDiffuse.a) * float4(materialEmissive.xyz, 1) * shSample(diffuseMap, UV);
|
||||
|
||||
#if MRT
|
||||
shOutputColor(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,15 @@
|
|||
shader_set clouds_vertex
|
||||
{
|
||||
source clouds.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set clouds_fragment
|
||||
{
|
||||
source clouds.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
|
@ -39,7 +39,7 @@ material openmw_objects_base
|
|||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
texture $diffuseMap
|
||||
direct_texture $diffuseMap
|
||||
create_in_ffp true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,9 @@
|
|||
shInput(float, depthPassthrough)
|
||||
#endif
|
||||
|
||||
#if MRT
|
||||
shUniform(float far) @shAutoConstant(far, far_clip_distance)
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
shInput(float3, normalPassthrough)
|
||||
|
@ -109,12 +111,16 @@
|
|||
diffuse += materialDiffuse.xyz * lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0);
|
||||
|
||||
@shEndForeach
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
ambient *= colorPassthrough.xyz;
|
||||
#endif
|
||||
|
||||
shOutputColor(0).xyz *= (ambient + diffuse + materialEmissive.xyz);
|
||||
#endif
|
||||
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
#if HAS_VERTEXCOLOR && !LIGHTING
|
||||
shOutputColor(0).xyz *= colorPassthrough.xyz;
|
||||
#endif
|
||||
|
||||
|
@ -123,6 +129,9 @@
|
|||
shOutputColor(0).xyz = shLerp (shOutputColor(0).xyz, fogColor, fogValue);
|
||||
#endif
|
||||
|
||||
// prevent negative color output (for example with negative lights)
|
||||
shOutputColor(0).xyz = max(shOutputColor(0).xyz, float3(0,0,0));
|
||||
|
||||
#if MRT
|
||||
shOutputColor(1) = float4(depthPassthrough / far,1,1,1);
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
material openmw_moon
|
||||
{
|
||||
mrt_output true
|
||||
pass
|
||||
{
|
||||
vertex_program moon_vertex
|
||||
fragment_program moon_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
shader_properties
|
||||
{
|
||||
mrt_output $mrt_output
|
||||
}
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
texture $diffuseMap
|
||||
|
@ -15,10 +23,21 @@ material openmw_moon
|
|||
|
||||
material openmw_clouds
|
||||
{
|
||||
mrt_output true
|
||||
pass
|
||||
{
|
||||
vertex_program clouds_vertex
|
||||
fragment_program clouds_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
|
||||
shader_properties
|
||||
{
|
||||
mrt_output $mrt_output
|
||||
}
|
||||
|
||||
// second diffuse map is used for weather transitions
|
||||
texture_unit diffuseMap1
|
||||
|
@ -36,19 +55,38 @@ material openmw_clouds
|
|||
|
||||
material openmw_atmosphere
|
||||
{
|
||||
mrt_output true
|
||||
pass
|
||||
{
|
||||
vertex_program atmosphere_vertex
|
||||
fragment_program atmosphere_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
|
||||
shader_properties
|
||||
{
|
||||
mrt_output $mrt_output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_stars
|
||||
{
|
||||
mrt_output true
|
||||
pass
|
||||
{
|
||||
vertex_program stars_vertex
|
||||
fragment_program stars_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
shader_properties
|
||||
{
|
||||
mrt_output $mrt_output
|
||||
}
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
|
@ -60,10 +98,18 @@ material openmw_stars
|
|||
// used for both sun and sun glare
|
||||
material openmw_sun
|
||||
{
|
||||
mrt_output true
|
||||
pass
|
||||
{
|
||||
vertex_program sun_vertex
|
||||
fragment_program sun_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
shader_properties
|
||||
{
|
||||
mrt_output $mrt_output
|
||||
}
|
||||
|
||||
texture unit diffuseMap
|
||||
{
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
#include "core.h"
|
||||
|
||||
#define MRT @shPropertyBool(mrt_output)
|
||||
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
#if MRT
|
||||
shDeclareMrtOutput(1)
|
||||
#endif
|
||||
shUniform(float4 materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
shUniform(float4 materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColor(0) = float4(1,1,1,materialDiffuse.a) * float4(materialEmissive.xyz, 1) * shSample(diffuseMap, UV);
|
||||
|
||||
#if MRT
|
||||
shOutputColor(1) = float4(1,1,1,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,15 @@
|
|||
shader_set sun_vertex
|
||||
{
|
||||
source sun.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set sun_fragment
|
||||
{
|
||||
source sun.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
Loading…
Reference in a new issue