Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

WIP: JDK-8217477: Implement attenuation-coefficients for PointLight #384

Draft
wants to merge 23 commits into
base: develop
Choose a base branch
from

Conversation

ProggerFox
Copy link

Adding attenuation factors to the ES2-pipeline of the JavaFX 3D-API

Adding attenuation factors to the JavaFX 3D-API
@kevinrushforth kevinrushforth added enhancement New feature or request WIP Work In Progress labels Feb 21, 2019
Added SetRange opeator
@brcolow
Copy link
Contributor

brcolow commented Feb 21, 2019

I'm not sure if this is super WIP or not but it's pretty non-standard to add comments to all the changes with your handle "FalcoTheBold" as that's what git/hg history is for. Not a big deal just pointing it out this superficial (non-code related) detail.

- Added missing shader-files
- Changed default values of attenuation-factors
@ProggerFox
Copy link
Author

@brcolow They can indeed be considered super WIP, these comments are just reminders from the time when i worked on the code apart from my usual work station and are supposed to be removed/replaced later of course.

@ProggerFox ProggerFox changed the title [WIP] JDK-8217477: Add attenuation for the es2 pipeline [WIP] JDK-8217477: Implement attenuation-coefficients for PointLight Mar 11, 2019
Copy link

@nlisker nlisker left a comment

Choose a reason for hiding this comment

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

OpenJFX uses spaces in stead of tabs, please change this.

Moreover, there are many spacing changes, such as in D3DContext.java and I'm not sure at all these are within the style conventions of OpenJFX. Kevin would have to comment on this I think.

The comments with your name and what you changed might be useful for reviewers, just remember to remove them later.

.idea/misc.xml Outdated
<component name="IdProvider" IDEtalkID="9BC0DE4049720C1246C2D3B835C6F7C3" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
Copy link

Choose a reason for hiding this comment

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

I don't think changes to IDE files belong in this patch. Is it necessary?

Copy link
Author

Choose a reason for hiding this comment

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

No, these were set by my IDE when i imported OpenJFX it seems, but i changed these back already. Thus it will be resetted within the next commits.

@@ -82,8 +85,12 @@ void main()
vec3 l = normalize(lightTangentSpacePositions[0].xyz);
d = clamp(dot(n,l), 0.0, 1.0)*(lights[0].color).rgb;
s = pow(clamp(dot(-refl, l), 0.0, 1.0), power)*lights[0].color.rgb;

//FalcoTheBold - added attenuation calculation for a single light
float dist = (lights[0].pos.xyz - gl_Position) / lights[0].atten.range;
Copy link

Choose a reason for hiding this comment

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

I don't understand this. If the distance from the pixel to the light is lights[0].pos.xyz - gl_Position, why divide by the range? If that distance is larger than the range, the light should have no effect. I don't see how this happens.

Copy link
Author

Choose a reason for hiding this comment

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

Honestly, tiredness got the better of me that time and i was led too much by findings in other forums regarding how to use the range in these places. Truly an error on my part there. There will be a conditional element regarding the affected range instead in the next commit as well.

@nlisker
Copy link

nlisker commented Mar 11, 2019

Did you test with the test code I linked to you that both implementations produce the same results?

@kevinrushforth
Copy link
Collaborator

Moreover, there are many spacing changes, such as in D3DContext.java and I'm not sure at all these are within the style conventions of OpenJFX. Kevin would have to comment on this I think.

I think these should be reverted. This sort of wholesale reformatting is discouraged because it makes changes harder to review (and can sometimes cause merge conflicts).

@ProggerFox
Copy link
Author

@nlisker

Did you test with the test code I linked to you that both implementations produce the same results?

Not yet, but i plan to do just that shortly.
I admit i worked a little hastly in order to finish this issue before the next incoming flood of customer support will steal the remaining time from me.

Regarding

Moreover, there are many spacing changes, such as in D3DContext.java and I'm not sure at all these are within the style conventions of OpenJFX. Kevin would have to comment on this I think.

I took the file as it is from the sources you provided and the IDE seems to have no issues with the indents (i use spaces, no tabs) or the likes.
My own additions indeed need some reworking, albeit there are indent issues at places in the sources i didn't touched.
Surely this is not a common thing with the sources in OpenJFX? (not saying i wouldn't fix them though)

- Tabs to spaces
- line at end of sources
- removal of "Falco"-comments
- changed policy of line separator
Copy link

@nlisker nlisker left a comment

Choose a reason for hiding this comment

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

Additional comments:

  • .idea/misc.xml has been changed again.
  • Undo the formatting (adding extra spaces) changes to: MeshView.java, D3DContext.java, LightBase.java and D3DMeshView.java.


private:

};

#endif /* D3DLIGHT_H */


Copy link

Choose a reason for hiding this comment

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

Remove empty lines.

glContext.setPointLight(nativeHandle, index, x, y, z, r, g, b, w);
/*
* FacloTheBold: - new operator, added parameters for attenuation coefficients
*/
Copy link

Choose a reason for hiding this comment

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

Remove this comment if you removed the rest.


gl_FragColor = vec4(clamp(rez, 0.0, 1.0) , diffuse.a);
vec3 rez = (ambientColor+d) * (att * (diffuse.xyz + s*specular.rgb));
Copy link

Choose a reason for hiding this comment

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

I think that att should multiply d and s (same as multiplying lights[0].color.rgb). The same is done in the d3d pipeline.

@nlisker
Copy link

nlisker commented Mar 15, 2019

I took the file as it is from the sources you provided and the IDE seems to have no issues with the indents (i use spaces, no tabs) or the likes.
My own additions indeed need some reworking, albeit there are indent issues at places in the sources i didn't touched.
Surely this is not a common thing with the sources in OpenJFX? (not saying i wouldn't fix them though)

The sources I uploaded do not change indentation. I'm not sure what indentation issues you are referring to.

@ProggerFox
Copy link
Author

ProggerFox commented Mar 15, 2019

The sources I uploaded do not change indentation. I'm not sure what indentation issues you are referring to.

May i know which IDE you used for working on your sources?
I think i will switch temporarily the tools i use for editing since something is not working straight at the moment.

@ProggerFox ProggerFox closed this Mar 15, 2019
@ProggerFox ProggerFox reopened this Mar 15, 2019
@ProggerFox
Copy link
Author

You see a Github-rookie at its finest, sorry for the inconveniences.
I plan to squash the commits soon, but since @nlisker is now listed as reviewer, how should i go on about the squashing?

@nlisker
Copy link

nlisker commented Mar 15, 2019

May i know which IDE you used for working on your sources?

I use Eclipse.

@nlisker
Copy link

nlisker commented Mar 19, 2019

The implementation looks promising. Can you test with the app I uploaded that we get the same visuals?


vec3 rez = (ambientColor+d) * diffuse.xyz + s*specular.rgb;
rez += apply_selfIllum().xyz;
vec3 rez = (ambientColor+d) * (diffuse.xyz + s*specular.rgb);
Copy link

Choose a reason for hiding this comment

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

I'm not sure that this change to the formula is correct. d should only multiply the diffuse color I think. Same for the other shaders.

@nlisker
Copy link

nlisker commented May 5, 2019

@FalcoTheBold How's it going? We are slowly running out of time to get all the planned changes into 13. We need to leave enough time for reviewers too.

@ProggerFox
Copy link
Author

@FalcoTheBold How's it going? We are slowly running out of time to get all the planned changes into 13. We need to leave enough time for reviewers too.

Hello there.
At the moment i am in quite a pinch with my regular work, finding little time to work on this and my other projects. Nonetheless i am on it to test it on the Linux-systems, just lately i had a sprint with my colleague on another work, thus taking less time on the issues here. This will change in a short while however, i will update you then.

@kevinrushforth kevinrushforth changed the title [WIP] JDK-8217477: Implement attenuation-coefficients for PointLight WIP: JDK-8217477: Implement attenuation-coefficients for PointLight Oct 1, 2019
@kevinrushforth
Copy link
Collaborator

kevinrushforth commented Oct 1, 2019

As announced in this message, the official jfx repository is moving from hg.openjdk.java.net/openjfx/jfx-dev/rt to github.com/openjdk/jfx.

This sandbox repository is being retired on 1-Oct-2019. You will need to migrate your WIP pull request to the openjdk/jfx repo if you want to continue working on it. Here are instructions for migrating your pull request. The updated CONTRIBUTING.md doc has additional information on how to proceed.

Once you have done this, it would be helpful to add a comment with a pointer to the new PR.

NOTE: since this is a feature / enhancement request it needs to be discussed on the openjfx-dev mailing list if you want it to be considered.


The new openjdk/jfx repo will be open for pull requests on Wednesday, 2-Oct-2019. I will send email to the openjfx-dev mailing list announcing this.

@nlisker
Copy link

nlisker commented Dec 6, 2019

PR on the Skara repo: openjdk/jfx#43

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants