Skip to content
Closed
Changes from all commits
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
27 changes: 6 additions & 21 deletions chunky/src/java/se/llbit/chunky/renderer/scene/Sun.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,33 +281,18 @@ public double getAzimuth() {
* @return <code>true</code> if the ray intersects the sun model
*/
public boolean intersect(Ray ray) {
if (!drawTexture || ray.d.dot(sw) < .5) {
return false;
}

double width = radius * 4;
double width2 = width * 2;
double a;
a = Math.PI / 2 - FastMath.acos(ray.d.dot(su)) + width;
if (a >= 0 && a < width2) {
double b = Math.PI / 2 - FastMath.acos(ray.d.dot(sv)) + width;
if (b >= 0 && b < width2) {
texture.getColor(a / width2, b / width2, ray.color);
ray.color.x *= apparentTextureBrightness.x * 10;
ray.color.y *= apparentTextureBrightness.y * 10;
ray.color.z *= apparentTextureBrightness.z * 10;
return true;
}
}

return false;
return doIntersect(ray, apparentTextureBrightness);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return doIntersect(ray, apparentTextureBrightness);
return doIntersect(ray, apparentTextureBrightness, false);

}

/**
* Used with <code>SSS: OFF</code> and <code>SSS: HIGH_QUALITY</code>.
*/
public boolean intersectDiffuse(Ray ray) {
if (ray.d.dot(sw) < .5) {
return doIntersect(ray, color);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return doIntersect(ray, color);
return doIntersect(ray, color, true);

}

private boolean doIntersect(Ray ray, Vector3 color) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
private boolean doIntersect(Ray ray, Vector3 color) {
private boolean doIntersect(Ray ray, Vector3 color, boolean isDiffuse) {

if (!drawTexture || ray.d.dot(sw) < .5) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (!drawTexture || ray.d.dot(sw) < .5) {
if ((!isDiffuse && !drawTexture) || ray.d.dot(sw) < .5) {

return false;
}

Expand Down