processing / processing/processing4
Support for #include in PShader (Enhancement)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 494
- Forks
- 183
- Ø Merge
- 4 Std. 39 Min.
- Gemergte PRs (30 T.)
- 3
Beschreibung
Created by: patriciogonzalezvivo
Although #include routines are defined by Khronos as an extension they are left for the environment/framework running the GL driver to implement. The reason for that is the required access to file system. Implementing #include routines are fairly straight forward with a couple of gotchas to avoid, like: relative paths and infinite recursions.
Most serious CG engines support them because their advantages on modularity, reusability and clearer code.
For Processing this also could mean support for LYGIA a rich shader library pack with useful resources for creative coders and artist.
I made a simple implementations of a #include parser in this repository together with some examples on how it can be use.
void loadSource(String current_folder, String filename, ArrayList<String> source) {
println("search for", filename, "in", current_folder);
File file = new File(current_folder,filename);
String url = file.getPath().substring(1);
println("open", url);
String[] lines = loadStrings(url);
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
String line_trim = line.trim();
if (line_trim.startsWith("#include")){
String include_file = line_trim.substring("#include".length()).replace("\"", "").trim();
File f = new File(current_folder,include_file);
loadSource(f.getParent(), f.getName(), source);
} else {
source.add(line + System.getProperty("line.separator") );
}
}
}
Adding this feature to createShader() to parse both vert and frag shaders shouldn't be hard and potentially bring numerous advantages.
cc @codeanticode @SableRaf @cacheflowe
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, createShader() und die Codepfade zu finden, die Vertex- und Fragment-PShaders laden. Lies den verlinkten lygia_p5_examples include parser im Hinblick auf den Umgang mit relativen Pfaden und Rekursion und ermittle anschließend vorhandene Tests oder Beispiele zum Laden von Shadern. Erledigt ist die Aufgabe, wenn beide Shader-Typen #include-Dateien sicher erweitern können, einschließlich verschachtelter relativer Includes, ohne unendliche Rekursion.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- computer-graphics
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100