Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/celengine/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,9 @@ static void renderSphereUnlit(const RenderInfo& ri,
textures.push_back(ri.overlayTex);
}

if (ri.isStar)
shadprop.lightModel = LightingModel::StarModel;

// Get a shader for the current rendering configuration
auto* prog = r->getShaderManager().getShader(shadprop);
if (prog == nullptr)
Expand All @@ -1838,6 +1841,8 @@ static void renderSphereUnlit(const RenderInfo& ri,
prog->textureOffset = 0.0f;
prog->ambientColor = ri.color.toVector3();
prog->opacity = 1.0f;
if (ri.isStar)
prog->eyePosition = ri.eyePos_obj;

Renderer::PipelineState ps;
ps.depthMask = true;
Expand Down Expand Up @@ -2388,6 +2393,7 @@ void Renderer::renderObject(const Vector3f& pos,
}
else
{
ri.isStar = obj.isStar;
renderSphereUnlit(ri, viewFrustum, planetMVP, this);
}
}
Expand Down Expand Up @@ -3014,6 +3020,7 @@ void Renderer::renderStar(const Star& star,
surface.appearanceFlags |= Surface::ApplyBaseTexture;
surface.appearanceFlags |= Surface::Emissive;

rp.isStar = true;
rp.surface = &surface;
rp.rings = nullptr;
rp.radius = star.getRadius();
Expand Down
9 changes: 6 additions & 3 deletions src/celengine/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,15 @@ class Renderer
Surface* surface{ nullptr };
const Atmosphere* atmosphere{ nullptr };
RingSystem* rings{ nullptr };
LightingState::EclipseShadowVector* eclipseShadows{ nullptr };

Eigen::Quaternionf orientation{ Eigen::Quaternionf::Identity() };
Eigen::Vector3f semiAxes{ Eigen::Vector3f::Ones() };
float radius{ 1.0f };
float geometryScale{ 1.0f };
Eigen::Vector3f semiAxes{ Eigen::Vector3f::Ones() };

ResourceHandle geometry{ InvalidResource };
Eigen::Quaternionf orientation{ Eigen::Quaternionf::Identity() };
LightingState::EclipseShadowVector* eclipseShadows;
bool isStar{ false };
};

struct DepthBufferPartition
Expand Down
7 changes: 4 additions & 3 deletions src/celengine/renderinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class Texture;

struct RenderInfo
{
Color color{ 1.0f, 1.0f, 1.0f };
Eigen::Quaternionf orientation{ Eigen::Quaternionf::Identity() };

Texture* baseTex{ nullptr };
Texture* bumpTex{ nullptr };
Texture* nightTex{ nullptr };
Texture* glossTex{ nullptr };
Texture* overlayTex{ nullptr };
Color color{ 1.0f, 1.0f, 1.0f };
Color specularColor{ 0.0f, 0.0f, 0.0f };
float specularPower{ 0.0f };
Eigen::Vector3f sunDir_eye{ Eigen::Vector3f::UnitZ() };
Expand All @@ -36,10 +38,9 @@ struct RenderInfo
Color sunColor{ 1.0f, 1.0f, 1.0f };
Color ambientColor{ 0.0f, 0.0f, 0.0f };
float lunarLambert{ 0.0f };
Eigen::Quaternionf orientation{ Eigen::Quaternionf::Identity() };
float pixWidth{ 1.0f };
float pointScale{ 1.0f };
bool isStar{ false };
};

extern LODSphereMesh* g_lodSphere;

5 changes: 5 additions & 0 deletions src/celengine/shadermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,11 @@ ShaderManager::buildFragmentShader(const ShaderProperties& props)
source += "gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + scatterColor;\n";
}

if (props.lightModel == LightingModel::StarModel)
{
source += "gl_FragColor.rgb = gl_FragColor.rgb - vec3(1.0 - NV) * vec3(0.56, 0.61, 0.72);\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to write down how the coefficients were obtained.

}

source += "}\n";

DumpFSSource(source);
Expand Down
1 change: 1 addition & 0 deletions src/celengine/shadermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum class LightingModel : std::uint16_t
EmissiveModel = 0x0100,
ParticleModel = 0x0200,
UnlitModel = 0x0400,
StarModel = 0x0800,
};

ENUM_CLASS_BITWISE_OPS(LightingModel);
Expand Down