WIP
This commit is contained in:
parent
386d9d0258
commit
dbb780f357
4 changed files with 7 additions and 8 deletions
|
@ -44,8 +44,7 @@ CloudBasicLayerRenderer::CloudBasicLayerRenderer(SoftwareRenderer *parent) : Bas
|
||||||
*/
|
*/
|
||||||
int CloudBasicLayerRenderer::findSegments(BaseCloudsModel *model, const Vector3 &start, const Vector3 &direction,
|
int CloudBasicLayerRenderer::findSegments(BaseCloudsModel *model, const Vector3 &start, const Vector3 &direction,
|
||||||
int max_segments, double max_inside_length, double max_total_length,
|
int max_segments, double max_inside_length, double max_total_length,
|
||||||
double *inside_length, double *total_length, CloudSegment *out_segments,
|
double *inside_length, double *total_length, CloudSegment *out_segments) {
|
||||||
double base_detail) {
|
|
||||||
double ymin, ymax;
|
double ymin, ymax;
|
||||||
int inside, segment_count;
|
int inside, segment_count;
|
||||||
double current_total_length, current_inside_length;
|
double current_total_length, current_inside_length;
|
||||||
|
@ -175,10 +174,10 @@ Color CloudBasicLayerRenderer::getColor(BaseCloudsModel *model, const Vector3 &e
|
||||||
material.shininess = 3.0;
|
material.shininess = 3.0;
|
||||||
|
|
||||||
segment_count = findSegments(model, start, direction, 30, transparency_depth, max_length, &inside_length,
|
segment_count = findSegments(model, start, direction, 30, transparency_depth, max_length, &inside_length,
|
||||||
&total_length, segments, 0.001);
|
&total_length, segments);
|
||||||
for (i = segment_count - 1; i >= 0; i--) {
|
for (i = segment_count - 1; i >= 0; i--) {
|
||||||
const Vector3 &location = segments[i].start;
|
const Vector3 &location = segments[i].start;
|
||||||
Vector3 normal = model->getNormal(location, 1.0);
|
Vector3 normal = model->getNormal(location);
|
||||||
|
|
||||||
material.ambient = 1.0 - normal.getNorm() * 0.2;
|
material.ambient = 1.0 - normal.getNorm() * 0.2;
|
||||||
material.reflection = 0.2 * normal.getNorm();
|
material.reflection = 0.2 * normal.getNorm();
|
||||||
|
@ -222,7 +221,7 @@ bool CloudBasicLayerRenderer::alterLight(BaseCloudsModel *model, LightComponent
|
||||||
model->getAltitudeRange(&ymin, &ymax);
|
model->getAltitudeRange(&ymin, &ymax);
|
||||||
double light_traversal = (ymax - ymin) * 0.8 * light->color.getPower();
|
double light_traversal = (ymax - ymin) * 0.8 * light->color.getPower();
|
||||||
findSegments(model, start, direction, 30, light_traversal, end.sub(start).getNorm(), &inside_depth, &total_depth,
|
findSegments(model, start, direction, 30, light_traversal, end.sub(start).getNorm(), &inside_depth, &total_depth,
|
||||||
segments, 0.1);
|
segments);
|
||||||
|
|
||||||
if (light_traversal < 0.0001) {
|
if (light_traversal < 0.0001) {
|
||||||
factor = 0.0;
|
factor = 0.0;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class SOFTWARESHARED_EXPORT CloudBasicLayerRenderer : public BaseCloudLayerRende
|
||||||
private:
|
private:
|
||||||
int findSegments(BaseCloudsModel *model, const Vector3 &start, const Vector3 &direction, int max_segments,
|
int findSegments(BaseCloudsModel *model, const Vector3 &start, const Vector3 &direction, int max_segments,
|
||||||
double max_inside_length, double max_total_length, double *inside_length, double *total_length,
|
double max_inside_length, double max_total_length, double *inside_length, double *total_length,
|
||||||
CloudSegment *out_segments, double base_detail);
|
CloudSegment *out_segments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ static inline Vector3 _getPseudoNormal(const BaseCloudsModel *model, const Vecto
|
||||||
return direction.scale(diff > 0.0 ? diff : 0.0);
|
return direction.scale(diff > 0.0 ? diff : 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 BaseCloudsModel::getNormal(const Vector3 &location, double quality) const
|
Vector3 BaseCloudsModel::getNormal(const Vector3 &location) const
|
||||||
{
|
{
|
||||||
double precision = 0.3;
|
double precision = 0.3;
|
||||||
Vector3 normal = VECTOR_ZERO;
|
Vector3 normal = VECTOR_ZERO;
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SOFTWARESHARED_EXPORT BaseCloudsModel {
|
||||||
* The length of the result vector indicates its relevance. A short vector marks an area
|
* The length of the result vector indicates its relevance. A short vector marks an area
|
||||||
* where applying a normal vector is not relevant.
|
* where applying a normal vector is not relevant.
|
||||||
*/
|
*/
|
||||||
virtual Vector3 getNormal(const Vector3 &location, double quality) const;
|
Vector3 getNormal(const Vector3 &location) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CloudLayerDefinition *layer;
|
CloudLayerDefinition *layer;
|
||||||
|
|
Loading…
Reference in a new issue