Improve compatibility with GLES back-end

This commit is contained in:
Edwin Jakobs
2024-03-10 18:39:21 +01:00
parent b9b1b95ca0
commit e3f5e07b86
62 changed files with 182 additions and 195 deletions

View File

@@ -73,7 +73,9 @@ abstract class CollectScreenshotsTask @Inject constructor() : DefaultTask() {
this.jvmArgs(
"-DtakeScreenshot=true",
"-DscreenshotPath=${outputDir.get().asFile}/$imageName.png",
"-Dorg.openrndr.exceptions=JVM"
"-Dorg.openrndr.exceptions=JVM",
"-Dorg.openrndr.gl3.debug=true",
"-Dorg.openrndr.gl3.delete_angle_on_exit=false"
)
}
}

View File

@@ -49,6 +49,10 @@ dependencies {
"demoImplementation"(main.output.classesDirs + main.runtimeClasspath)
"demoImplementation"(libs.openrndr.application)
"demoImplementation"(libs.openrndr.extensions)
if (DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX) {
"demoRuntimeOnly"(libs.openrndr.gl3.natives.macos.arm64)
}
"demoRuntimeOnly"(libs.openrndr.gl3.core)
"demoRuntimeOnly"(libs.slf4j.simple)
}

View File

@@ -1,11 +1,10 @@
package org.openrndr.extra.convention
import CollectScreenshotsTask
import gradle.kotlin.dsl.accessors._a37e1a3c5785f18372ed85a4dc9bbdf6.testRuntimeOnly
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
val libs = the<LibrariesForLibs>()
@@ -49,6 +48,11 @@ kotlin {
outputDir.set(project.file(project.projectDir.toString() + "/images"))
dependsOn(compileTaskProvider)
}
dependencies {
if (DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX) {
runtimeOnly(libs.openrndr.gl3.natives.macos.arm64)
}
}
}
}
testRuns["test"].executionTask {

17
gradlew vendored
View File

@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

View File

@@ -29,8 +29,8 @@ fun main() = application {
// sets angle and radius based on time and shape ID.
drawer.shadeStyle = shadeStyle {
vertexTransform = """
float a = c_instance + p_time * 0.1;
float r = 200 + 100 * sin(a * 0.998);
float a = float(c_instance) + p_time * 0.1;
float r = 200.0 + 100.0 * sin(a * 0.998);
x_position.x += r * sin(a);
x_position.y += r * cos(a);
""".trimIndent()

View File

@@ -1,15 +1,12 @@
import org.openrndr.application
import org.openrndr.draw.Cubemap
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.Session
import org.openrndr.draw.shadeStyle
import org.openrndr.draw.*
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.boxMesh
fun main() = application {
program {
val cubemap = Cubemap.fromUrl("file:demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cubemap = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cube = boxMesh()
extend(Orbital()) {

View File

@@ -5,7 +5,7 @@ import org.openrndr.extra.meshgenerators.boxMesh
fun main() = application {
program {
val cubemap1 = Cubemap.fromUrl("file:demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cubemap1 = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cube = boxMesh()
val cubemap2 = cubemap(cubemap1.width, format = cubemap1.format, type = cubemap1.type, levels = 2, session = Session.active)
cubemap1.copyTo(cubemap2, 0, 0)

View File

@@ -5,7 +5,7 @@ import org.openrndr.extra.meshgenerators.boxMesh
fun main() = application {
program {
val cubemap1 = Cubemap.fromUrl("file:demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cubemap1 = loadCubemap("demo-data/cubemaps/garage_iem.dds", null, session = Session.active)
val cube = boxMesh()
val cubemap2 = cubemap(cubemap1.width, format = cubemap1.format, type = cubemap1.type, levels = 2, session = Session.active)
cubemap1.copyTo(cubemap2, 0, 0)

View File

@@ -61,9 +61,9 @@ object ColorPhraseBook : ShaderPhraseBook("color") {
|vec4 linear_rgb_to_srgb(vec4 c) {
| const float t = 0.00313066844250063;
| return vec4(
| c.r <= t ? c.r * 12.92 : 1.055 * pow(c.r, 1 / 2.4) - 0.055,
| c.g <= t ? c.g * 12.92 : 1.055 * pow(c.g, 1 / 2.4) - 0.055,
| c.b <= t ? c.b * 12.92 : 1.055 * pow(c.b, 1 / 2.4) - 0.055,
| c.r <= t ? c.r * 12.92 : 1.055 * pow(c.r, 1.0 / 2.4) - 0.055,
| c.g <= t ? c.g * 12.92 : 1.055 * pow(c.g, 1.0 / 2.4) - 0.055,
| c.b <= t ? c.b * 12.92 : 1.055 * pow(c.b, 1.0 / 2.4) - 0.055,
| c.a);
|}""".trimMargin())

View File

@@ -14,6 +14,7 @@ import org.openrndr.shape.Rectangle
* Try changing which layer has multisampling applied and observe the results.
*/
fun main() = application {
System.setProperty("org.openrndr.gl3.debug", "true")
configure {
width = 800
height = 800
@@ -21,7 +22,7 @@ fun main() = application {
program {
val layers = compose {
layer(multisample = BufferMultisample.SampleCount(16)) {
layer(multisample = BufferMultisample.SampleCount(4)) {
draw {
drawer.translate(drawer.bounds.center)
drawer.rotate(seconds)

View File

@@ -33,9 +33,9 @@ vec3 srgb_to_linear(vec3 c) {
vec3 linear_to_srgb(vec3 c) {
const float t = 0.00313066844250063;
return vec3(
c.r <= t ? c.r * 12.92 : 1.055 * pow(c.r, 1 / 2.4) - 0.055,
c.g <= t ? c.g * 12.92 : 1.055 * pow(c.g, 1 / 2.4) - 0.055,
c.b <= t ? c.b * 12.92 : 1.055 * pow(c.b, 1 / 2.4) - 0.055
c.r <= t ? c.r * 12.92 : 1.055 * pow(c.r, 1.0 / 2.4) - 0.055,
c.g <= t ? c.g * 12.92 : 1.055 * pow(c.g, 1.0 / 2.4) - 0.055,
c.b <= t ? c.b * 12.92 : 1.055 * pow(c.b, 1.0 / 2.4) - 0.055
);
}
@@ -86,7 +86,7 @@ void main() {
*/
@Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
@Description("Blend spectral")
class BlendSpectral : Filter2to1(filterShaderFromCode(spectralBlendShader, "color-burn")) {
class BlendSpectral : Filter2to1(filterShaderFromCode(spectralBlendShader, "blend-spectral")) {
@BooleanParameter("source clip")
var clip: Boolean by parameters

View File

@@ -12,7 +12,7 @@ import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Lenses")
class Lenses : Filter1to1(mppFilterShader(fx_lenses, "block-repeat")) {
class Lenses : Filter1to1(mppFilterShader(fx_lenses, "lenses")) {
@IntParameter("rows", 1, 64, order = 0)
var rows: Int by parameters

View File

@@ -1,7 +1,6 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.fx.blur.*
import org.openrndr.math.Polar
import kotlin.math.sin

View File

@@ -2,7 +2,6 @@ import org.openrndr.application
import org.openrndr.draw.createEquivalent
import org.openrndr.draw.loadImage
import org.openrndr.extra.fx.dither.LumaHalftone
import org.openrndr.math.mod_
fun main() {
application {

View File

@@ -16,11 +16,6 @@ fun main() {
checkers.size = 64.0
checkers.apply(emptyArray(), image)
if (System.getProperty("takeScreenshot") == "true") {
extend(SingleScreenshot()) {
this.outputFile = System.getProperty("screenshotPath")
}
}
extend {
fd.blend = mouse.position.x/width
fd.apply(image, distorted)

View File

@@ -21,14 +21,14 @@ void main() {
vec4 b = texture2D(tex1, v_texCoord0);
#endif
vec3 na = a.a > 0 ? a.rgb/a.a : vec3(0.0);
vec3 nb = b.a > 0 ? b.rgb/b.a : vec3(0.0);
vec3 na = a.a > 0.0 ? a.rgb/a.a : vec3(0.0);
vec3 nb = b.a > 0.0 ? b.rgb/b.a : vec3(0.0);
vec3 addColor = b.rgb;
vec4 result;
if (clip) {
result = vec4((na + addColor), 1) * a.a;
result = vec4((na + addColor), 1.0) * a.a;
} else {
result = (1.0-a.a) * b + a.a * b.a * vec4(min(na + nb, vec3(1.0)), 1.0) + (1.0-b.a) * a;
}

View File

@@ -25,9 +25,9 @@ void main() {
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
vec3 m = vec3(
nb.r <= 0.5? 2*na.r * nb.r : 1.0 - 2.0*(1.0 - na.r)*(1.0 - nb.r),
nb.g <= 0.5? 2*na.g * nb.g : 1.0 - 2.0*(1.0 - na.g)*(1.0 - nb.g),
nb.b <= 0.5? 2*na.b * nb.b : 1.0 - 2.0*(1.0 - na.b)*(1.0 - nb.b)
nb.r <= 0.5? 2.0*na.r * nb.r : 1.0 - 2.0*(1.0 - na.r)*(1.0 - nb.r),
nb.g <= 0.5? 2.0*na.g * nb.g : 1.0 - 2.0*(1.0 - na.g)*(1.0 - nb.g),
nb.b <= 0.5? 2.0*na.b * nb.b : 1.0 - 2.0*(1.0 - na.b)*(1.0 - nb.b)
);
vec4 result;

View File

@@ -21,14 +21,14 @@ void main() {
vec4 b = texture2D(tex1, v_texCoord0);
#endif
float alpha = min(1,max(0, b.a));
float alpha = min(1.0, max(0.0, b.a));
vec4 result;
if (!clip) {
result = a * (1.0-alpha) + b;
result = a * (1.0 - alpha) + b;
result.a = clamp(o_color.a, 0.0, 1.0);
} else {
result = a * (1.0-alpha) + b * a.a;
result = a * (1.0 - alpha) + b * a.a;
}
#ifdef OR_GL_FRAGCOLOR

View File

@@ -13,7 +13,7 @@ out vec4 o_color;
#endif
vec3 demul(vec4 c) {
if (c.a == 0) {
if (c.a == 0.0) {
return vec3(0.0);
} else {
return c.rgb / c.a;

View File

@@ -21,8 +21,8 @@ void main() {
vec4 b = texture2D(tex1, v_texCoord0);
#endif
vec3 na = a.a > 0 ? a.rgb/a.a : vec3(0.0);
vec3 nb = b.a > 0 ? b.rgb/b.a : vec3(0.0);
vec3 na = a.a > 0.0 ? a.rgb/a.a : vec3(0.0);
vec3 nb = b.a > 0.0 ? b.rgb/b.a : vec3(0.0);
vec3 subColor = b.rgb;
vec4 result;
if (clip) {

View File

@@ -20,7 +20,7 @@ void main() {
float lw = exp( float(-(x*x)) / (2.0 * sigma * sigma) ) ;
vec2 tc = v_texCoord0 + float(x) * blurDirection * s;// * spread;
#ifndef OR_WEBGL2
sum += textureLod(tex0, tc, sourceLevel) * lw;
sum += textureLod(tex0, tc, float(sourceLevel)) * lw;
#else
sum += texture(tex0, tc);
#endif

View File

@@ -8,12 +8,12 @@ void main()
{
float centerWeight = 0.16210282163712664;
vec2 diagonalOffsets = vec2(0.3842896354828526, 1.2048616327242379);
vec4 offsets = vec4(-diagonalOffsets.xy, +diagonalOffsets.xy) / textureSize(tex0, 0).xyxy;
vec4 offsets = vec4(-diagonalOffsets.xy, +diagonalOffsets.xy) / vec2(textureSize(tex0, 0)).xyxy;
float diagonalWeight = 0.2085034734347498;
o_output = textureLod(tex0, v_texCoord0, 0) * centerWeight +
textureLod(tex0, v_texCoord0 + offsets.xy, 0) * diagonalWeight +
textureLod(tex0, v_texCoord0 + offsets.wx, 0) * diagonalWeight +
textureLod(tex0, v_texCoord0 + offsets.zw, 0) * diagonalWeight +
textureLod(tex0, v_texCoord0 + offsets.yz, 0) * diagonalWeight;
o_output = textureLod(tex0, v_texCoord0, 0.0) * centerWeight +
textureLod(tex0, v_texCoord0 + offsets.xy, 0.0) * diagonalWeight +
textureLod(tex0, v_texCoord0 + offsets.wx, 0.0) * diagonalWeight +
textureLod(tex0, v_texCoord0 + offsets.zw, 0.0) * diagonalWeight +
textureLod(tex0, v_texCoord0 + offsets.yz, 0.0) * diagonalWeight;
}

View File

@@ -20,55 +20,55 @@ uniform sampler2D tex4;
uniform sampler2D tex5;
vec4 sampleBloom(vec2 pos, float shape) {
vec4 sum = vec4(0);
float total = 0;
vec4 sum = vec4(0.0);
float total = 0.0;
{
float weight = pow(0.0, shape);
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
nrand(5 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 2 - 1) / textureSize(tex0, 0);
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 2.0 - 1.0) / vec2(textureSize(tex0, 0));
sum += textureLod(tex0, pos + rnd * noiseGain, 0.0) * weight;
total += weight;
}
{
float weight = pow(1.0, shape);
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
nrand(5 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 2 - 1) / textureSize(tex1, 0);
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 2.0 - 1.0) / vec2(textureSize(tex0, 0));
sum += textureLod(tex1, pos + rnd * noiseGain, 0.0) * weight;
total += weight;
}
{
float weight = pow(2.0, shape);
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
nrand(5 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 2 - 1) / textureSize(tex2, 0);
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 2.0 - 1.0) / vec2(textureSize(tex0, 0));
sum += textureLod(tex2, pos + rnd * noiseGain, 0.0) * weight;
total += weight;
}
{
float weight = pow(3.0, shape);
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
nrand(5 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 3.0 - 1.0) / vec2(textureSize(tex0, 0));
sum += textureLod(tex3, pos + rnd * noiseGain, 0.0) * weight;
total += weight;
}
{
float weight = pow(4.0, shape);
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
nrand(5 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 3.0 - 1.0) / vec2(textureSize(tex0, 0));
sum += textureLod(tex4, pos + rnd * noiseGain, 0.0) * weight;
total += weight;
}
{
float weight = pow(5.0, shape);
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
nrand(5 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
rnd = (rnd * 3.0 - 1.0) / vec2(textureSize(tex0, 0));
sum += textureLod(tex5, pos + rnd * noiseGain, 0.0) * weight;
total += weight;
}

View File

@@ -10,17 +10,17 @@ uniform float gain;
out vec4 o_color;
void main() {
vec2 s = textureSize(tex0, 0).xy;
vec2 s = vec2(textureSize(tex0, 0).xy);
s = vec2(1.0/s.x, 1.0/s.y);
int w = window;
vec4 sum = vec4(0,0,0,0);
float weight = 0;
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
float weight = 0.0;
for (int y = -w; y<= w; ++y) {
for (int x = -w; x<= w; ++x) {
float lw = exp(-(x*x+y*y) / (2 * sigma * sigma));
sum+=texture(tex0, v_texCoord0 + vec2(x,y) * s * spread) * lw;
float lw = exp(-float(x*x+y*y) / (2.0 * sigma * sigma));
sum+=texture(tex0, v_texCoord0 + vec2(x, y) * s * spread) * lw;
weight+=lw;
}
}

View File

@@ -5,7 +5,7 @@ uniform int levels;
out vec4 o_output;
void main() {
vec4 c = texture(tex0, v_texCoord0);
vec2 step = 1.0 / textureSize(tex0, 0);
vec2 step = 1.0 / vec2(textureSize(tex0, 0));
float w = 0.0;
vec3 s = vec3(0.0);
for (int v = -window; v <= window; ++v) {
@@ -14,7 +14,7 @@ void main() {
if (c.a != 0.0) {
c.rgb /= c.a;
}
vec3 q = min(floor(c.rgb * float(levels))/float(levels-1.0), vec3(1.0));
vec3 q = min(floor(c.rgb * float(levels))/float(levels-1), vec3(1.0));
s += q;
w += 1.0;
}

View File

@@ -10,7 +10,7 @@ void main() {
}
c.rgb *= 255.0;
float y = 0.0 + 0.299 * c.r + 0.587 * c.g + 0.114 * c.b;
float cb = 128 - (0.168736 * c.r) - (0.331264 * c.g) + (0.5 * c.b);
float cr = 128 + (0.5 * c.r) - 0.418688 * c.g - 0.081312 * c.b;
float cb = 128.0 - (0.168736 * c.r) - (0.331264 * c.g) + (0.5 * c.b);
float cr = 128.0 + (0.5 * c.r) - 0.418688 * c.g - 0.081312 * c.b;
o_color = vec4(y/255.0, cb/255.0, cr/255.0, 1.0) * c.a;
}

View File

@@ -4,7 +4,7 @@ uniform sampler2D tex0;
out vec4 o_color;
void main() {
vec2 ts = textureSize(tex0, 0);
vec2 ts = vec2(textureSize(tex0, 0));
vec4 c = texture(tex0, v_texCoord0);
if (c.a != 0.0) {

View File

@@ -22,7 +22,7 @@ void main() {
float ar = targetSize.y / targetSize.x;
vec4 nb = b.a > 0? b/b.a : vec4(0.0);
vec4 nb = b.a > 0.0? b/b.a : vec4(0.0);
vec2 offset = (nb.rg - vec2(offset))*vec2(gain) * nb.a;
offset = rm * offset * vec2(1.0, ar);

View File

@@ -34,11 +34,11 @@ uniform float blend;
out vec4 o_color;
float getRot(vec2 pos, vec2 b) {
vec2 Res = textureSize(tex0, 0);
vec2 Res = vec2(textureSize(tex0, 0));
vec2 p = b;
float rot = 0.0;
for (int i = 0; i < RotNum; i++) {
rot += dot(texture(tex0, fract((pos + p) / Res.xy)).xy -vec2(0.5), p.yx * vec2(1, -1));
rot += dot(texture(tex0, fract((pos + p) / Res.xy)).xy -vec2(0.5), p.yx * vec2(1.0, -1.0));
p = m * p;
}
return rot / float(RotNum)/dot(b, b);
@@ -46,10 +46,10 @@ float getRot(vec2 pos, vec2 b) {
void main() {
vec2 pos = v_texCoord0 * targetSize;
vec2 Res = textureSize(tex0, 0);
vec2 Res = vec2(textureSize(tex0, 0));
vec2 b = vec2(cos(ang * random), sin(ang * random));
vec2 v = vec2(0);
vec2 v = vec2(0.0);
float bbMax = 0.5 * Res.y;
bbMax *= bbMax;
for (int l = 0; l < 20; l++) {

View File

@@ -18,7 +18,7 @@ void main() {
float ca = cos(radians(rotation));
float sa = sin(radians(rotation));
vec2 ts = textureSize(tex0, 0);
vec2 ts = vec2(textureSize(tex0, 0));
mat2 rm = mat2(1.0, 0.0, 0.0, ts.x / ts.y) * mat2(vec2(ca, sa), vec2(-sa, ca)) * mat2(1.0, 0.0, 0.0, ts.y / ts.x);
vec2 ruv = (uv - blockCenter);
vec2 luv;

View File

@@ -11,11 +11,11 @@ uniform float rotation;
out vec4 o_color;
void main() {
vec2 origin = vec2((xOrigin+1.0)/2.0, (yOrigin+1.0)/2.0);
vec2 ts = textureSize(tex0, 0);
vec2 ts = vec2(textureSize(tex0, 0));
float r = ts.x/ts.y;
vec2 offset = vec2(1.0, r) * vec2(xOffset, yOffset);
vec2 uv = v_texCoord0 - vec2(origin);
float rad = (rotation/180) * 3.1415926535;
float rad = (rotation / 180.0) * 3.1415926535;
vec2 cs0 = vec2(cos(rad), -sin(rad));
vec2 cs1 = vec2(sin(rad), cos(rad));
mat2 rotStep = mat2(cs0, cs1);
@@ -24,7 +24,7 @@ void main() {
vec4 c = texture(tex0, v_texCoord0);
for (int i = 1; i <= repeats; ++i) {
//vec2 s = (uv * (1.0 + zoom) * i) + vec2(0.5);
vec2 s = (rot * uv * pow(1.0 + zoom,i*1.0) )+ vec2(origin) + vec2(offset) * i;
vec2 s = (rot * uv * pow(1.0 + zoom, float(i) * 1.0))+ vec2(origin) + vec2(offset) * float(i);
float f = s.x >= 0.0 && s.y > 0.0 && s.x < 1.0 && s.y < 1.0? 1.0 : 0.0;
vec4 sc = texture(tex0, s) * f;
@@ -34,7 +34,5 @@ void main() {
}
rot *= rotStep;
}
o_color = c;
}

View File

@@ -35,19 +35,19 @@ void main() {
o_output = vec4(0.0);
for (int k = 0; k < 10; ++k ) {
vec2 duv = v_texCoord0;
duv.y += smoothstep(pow(cos(time+k*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.0, v_texCoord0.x)*deformAmplitude * cos((time+k*dk)*deformFrequency);
duv.y += smoothstep(pow(1.0-cos(time+k*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.9, v_texCoord0.x)*deformAmplitude * cos((time+k*dk)*deformFrequency);
duv.y += smoothstep(pow(cos(time+float(k)*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.0, v_texCoord0.x)*deformAmplitude * cos((time+float(k)*dk)*deformFrequency);
duv.y += smoothstep(pow(1.0-cos(time+float(k)*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.9, v_texCoord0.x)*deformAmplitude * cos((time+float(k)*dk)*deformFrequency);
duv.y += sin(v_texCoord0.x*3.1415926535)*0.0;
float bc = floor(hash22(vec2(time+k*dk, (time+k*dk)*0.1)).x*20.0);
float bc = floor(hash22(vec2(time+float(k)*dk, (time+float(k)*dk)*0.1)).x*20.0);
float gb3 = floor(duv.y*bc)/bc;
vec2 v = hash22(duv.xy*0.003+time+k*dk);
vec2 v2 = hash22(duv.xy*0.03+time+k*dk);
vec2 v2b = hash22(duv.yx*0.03+time+k*dk);
float stretch = (cos(time+k*dk)*0.001+0.002)*0.3+0.001;
vec2 h = hash22(duv.yy*stretch+time+k*dk);
float gap = smoothstep(gapLow, gapHigh, cos(gb3*(gapFrequency+duv.y*gapFrequency + (time+k*dk)*gapFrequency) +duv.x*gapFrequency)) * (cos(gb3)*0.5+0.5);
vec2 v = hash22(duv.xy*0.003+time+float(k)*dk);
vec2 v2 = hash22(duv.xy*0.03+time+float(k)*dk);
vec2 v2b = hash22(duv.yx*0.03+time+float(k)*dk);
float stretch = (cos(time+float(k)*dk)*0.001+0.002)*0.3+0.001;
vec2 h = hash22(duv.yy*stretch+time+float(k)*dk);
float gap = smoothstep(gapLow, gapHigh, cos(gb3*(gapFrequency+duv.y*gapFrequency + (time+float(k)*dk)*gapFrequency) +duv.x*gapFrequency)) * (cos(gb3)*0.5+0.5);
float r = smoothstep(noiseLow, noiseHigh, h.x*gap*v2.x)*1.0;
float g = smoothstep(noiseLow, noiseHigh, h.x*gap*v2.y)*1.0;

View File

@@ -30,8 +30,8 @@ vec4 getVideo(vec2 uv, float amplitude, float seconds) {
float iTime = seconds;
vec2 look = mod(uv, vec2(1.0));
float window = 1.0/(1.0 + 20.0*(look.y-mod(iTime*vfreq, 1.0))*(look.y-mod(iTime*vfreq, 1.)));
look.x = look.x + sin(look.y*pfreq + poffset * 3.1415)/50 *(1.+cos(iTime*hfreq))*window*amplitude;
look.y = mod(look.y, 1.);
look.x = look.x + sin(look.y*pfreq + poffset * 3.1415)/50.0 *(1.0+cos(iTime*hfreq))*window*amplitude;
look.y = mod(look.y, 1.0);
vec4 video = texture(tex0, look);
return video;
@@ -48,11 +48,11 @@ void main() {
float ds = scrollOffset1 - scrollOffset0;
if (aa > 0.0 || ds > 0.0) {
for (int i = 1; i < 16; ++i) {
vec4 lc = getVideo(v_texCoord0 + vec2(0.0, scrollOffset0+ds*i), aa, time-i/(16*60.0));
vec4 lc = getVideo(v_texCoord0 + vec2(0.0, scrollOffset0+ds*float(i)), aa, time-float(i)/(16.0*60.0));
if (!linearInput) {
lc.rgb = pow(lc.rgb, vec3(2.2));
}
c += lc * (3.0/16.0) * aberrationColor(i/16.0);
c += lc * (3.0/16.0) * aberrationColor(float(i)/16.0);
}
o_output = c;
} else {
@@ -63,6 +63,6 @@ void main() {
o_output = lc;
}
if (!linearOutput) {
o_output.rgb = pow(o_output.rgb, vec3(1/2.2));
o_output.rgb = pow(o_output.rgb, vec3(1.0/2.2));
}
}

View File

@@ -7,22 +7,22 @@ uniform int pattern;
uniform int levels;
float mask1(int levels, float l, int x, int y, int c) {
float mask = ((x ^ y * 149) * 1234& 511)/511.0;
return floor(levels * l + mask)/levels;
float mask = float((x ^ y * 149) * 1234& 511)/511.0;
return floor(float(levels) * l + mask)/float(levels);
}
float mask2(int levels, float l, int x, int y, int c) {
float mask = (((x+c*17) ^ y * 149) * 1234 & 511)/511.0;
return floor(levels * l + mask)/levels;
float mask = float(((x+c*17) ^ y * 149) * 1234 & 511)/511.0;
return floor(float(levels) * l + mask)/float(levels);
}
float mask3(int levels, float l, int x, int y, int c) {
float mask = ((x + y * 237) * 119 & 255)/255.0;
return floor(levels * l + mask)/levels;
float mask = float((x + y * 237) * 119 & 255)/255.0;
return floor(float(levels) * float(l) + mask)/float(levels);
}
float mask4(int levels, float l, int x, int y, int c) {
float mask = (((x+c*67) + y * 236) * 119 & 255)/255.0;
return floor(levels * l + mask)/levels;
float mask = float(((x+c*67) + y * 236) * 119 & 255)/255.0;
return floor(float(levels) * float(l) + mask)/float(levels);
}
out vec4 o_color;
@@ -31,7 +31,7 @@ void main() {
if (c.a > 0.0) {
c.rgb/=c.a;
}
ivec2 ic = ivec2(v_texCoord0 * textureSize(tex0, 0));
ivec2 ic = ivec2(v_texCoord0 * vec2(textureSize(tex0, 0)));
vec4 rgba = vec4(0.0);
if (pattern == 0) {

View File

@@ -23,7 +23,7 @@ vec3 cmyki2rgb(in vec4 c)
return c.rgb * c.a;
}
vec3 u(vec4 c) {
if (c.a == 0) {
if (c.a == 0.0) {
return vec3(0.0);
} else {
return c.rgb/c.a;
@@ -46,7 +46,7 @@ vec4 cmyki2rgba(in vec4 cmyk){
vec2 px2uv(in vec2 px)
{
return vec2(px / textureSize(tex0, 0));
return vec2(px / vec2(textureSize(tex0, 0)));
}
vec2 grid(in vec2 px)
@@ -63,7 +63,7 @@ vec4 halftone(in vec2 fc,in mat2 m)
{
vec2 smp = (grid(m*fc) + 0.5*scale) * m;
float s = min(length(fc-smp) / (dotSize*0.5*scale), 1.0);
vec3 texc = texture(tex0, px2uv(smp+textureSize(tex0, 0)/2.0)).rgb;
vec3 texc = texture(tex0, px2uv(smp+vec2(textureSize(tex0, 0))/2.0)).rgb;
vec4 c = rgb2cmyki(texc);
return c+s;
}
@@ -79,7 +79,7 @@ mat2 rotm(in float r)
}
void main() {
vec2 fc = v_texCoord0 * textureSize(tex0, 0) - textureSize(tex0, 0)/2.0;
vec2 fc = v_texCoord0 * vec2(textureSize(tex0, 0)) - vec2(textureSize(tex0, 0))/2.0;
mat2 mc = rotm(rotation + radians(15.0));
mat2 mm = rotm(rotation + radians(75.0));

View File

@@ -16,7 +16,7 @@ float cosine_sample(vec2 uv){
float ca = cos(radians(rotation));
float sa = sin(radians(rotation));
vec2 ts = textureSize(tex0, 0);
vec2 ts = vec2(textureSize(tex0, 0));
mat2 rm = mat2(1.0, 0.0, 0.0, ts.x/ts.y) * mat2(vec2(ca, sa), vec2(-sa, ca)) * mat2(1.0, 0.0, 0.0, ts.y/ts.x);
vec2 cuv = (rm * (uv - vec2(0.5))) + vec2(0.5);
@@ -28,7 +28,7 @@ float cosine_sample(vec2 uv){
}
float l = dot(vec3(1.0/3.0), c.rgb);
if (invert) {
l = 1 - l;
l = 1.0 - l;
}
float t = 0.0;
@@ -38,14 +38,14 @@ float cosine_sample(vec2 uv){
float cosine_halftone(vec2 uv) {
int w = 3;
vec2 step = 1.0 / textureSize(tex0, 0);
step /= (2*w);
vec2 step = 1.0 / vec2(textureSize(tex0, 0));
step /= (2.0*float(w));
float weight = 0.0;
float sum = 0.0;
for (int v = -w; v <= w; ++v) {
for (int u = -w; u <= w; ++u) {
sum += cosine_sample(uv + step * vec2(u, v));
weight+=1;
weight+=1.0;
}
}
return sum / weight;
@@ -56,7 +56,7 @@ void main() {
vec4 c = texture(tex0, v_texCoord0);
float t = cosine_halftone(v_texCoord0);
if (invert) {
t = 1 - t;
t = 1.0 - t;
}
o_color = vec4(t, t, t, 1.0) * c.a;
}

View File

@@ -15,8 +15,7 @@ uniform vec4 foregroundColor;
uniform float backgroundOpacity;
uniform float foregroundOpacity;
vec2 iResolution = textureSize(tex0, 0);
vec2 fragCoord = v_texCoord0 * iResolution;
vec2 iResolution;
float getAve(vec2 uv){
vec3 rgb = texture(tex0, uv).rgb;
@@ -104,6 +103,8 @@ float cannyEdge(vec2 fragCoord, float mn, float mx){
}
void main(){
iResolution = vec2(textureSize(tex0, 0));
vec2 fragCoord = v_texCoord0 * iResolution;
float edge = cannyEdge(fragCoord, threshold0, threshold1);
o_output = mix(foregroundColor * foregroundOpacity, backgroundColor * backgroundOpacity, 1.-edge);
}

View File

@@ -17,13 +17,13 @@ float calc_contour(vec2 uv) {
}
void main() {
vec2 step = 1.0 / textureSize(tex0, 0);
vec2 step = 1.0 / vec2(textureSize(tex0, 0));
float contour = 0.0;
float weight = 0.0;
for (int i = -window; i <= window; ++i) {
for (int j = -window; j <= window; ++j) {
contour += calc_contour(v_texCoord0 + step/(window+1.0) * vec2(i, j));
contour += calc_contour(v_texCoord0 + step/(float(window)+1.0) * vec2(float(i), float(j)));
weight += 1.0;
}
}

View File

@@ -16,7 +16,7 @@ float luma(vec4 color){
}
void main() {
vec2 step = 1.0 / textureSize(tex0, 0);
vec2 step = 1.0 / vec2(textureSize(tex0, 0));
float tl = luma(texture(tex0, v_texCoord0 + vec2(-step.x, step.y)));
float l = luma(texture(tex0, v_texCoord0 + vec2(-step.x, 0)));
@@ -39,7 +39,7 @@ void main() {
float x = tl + 2.0 * l + bl - tr - 2.0 * r - br;
float y = -tl - 2.0 * t - tr + bl + 2.0 * b + br;
float intensity = sqrt((x*x) + (y*y)) / sqrt(2);
float intensity = sqrt(x*x + y*y) / sqrt(2.0);
vec4 color = mix(vec4(backgroundColor.rgb, backgroundOpacity), vec4(edgeColor.rgb, edgeOpacity), intensity);
vec4 a = texture(tex0, v_texCoord0);

View File

@@ -21,7 +21,7 @@ void main() {
vec2 cell = (uv / size);
ivec2 cellIndex = ivec2(floor(cell));
vec2 cellUV = cell - cellIndex;
vec2 cellUV = cell - vec2(cellIndex);
int c = (cellIndex.x + cellIndex.y) % 2;
vec2 w = fwidth(cell);

View File

@@ -7,6 +7,6 @@ out vec4 o_color;
void main() {
vec4 a = texture(tex0, v_texCoord0-shift);
vec4 b = texture(tex1, v_texCoord0);
float alpha = min(1,max(0, b.a));
float alpha = min(1.0,max(0.0, b.a));
o_color = a * (1.0-alpha) + b;
}

View File

@@ -10,16 +10,16 @@ uniform float spread;
uniform vec4 color;
out vec4 o_color;
void main() {
vec2 s = textureSize(tex0, 0).xy;
vec2 s = vec2(textureSize(tex0, 0)).xy;
s = vec2(1.0/s.x, 1.0/s.y);
int w = window;
vec4 sum = vec4(0, 0, 0, 0);
float weight = 0;
float weight = 0.0;
for (int x = -w; x<= w; ++x) {
float lw = 1.0;
sum += texture(tex0, v_texCoord0 + x * blurDirection * s * spread);
sum += texture(tex0, v_texCoord0 + float(x) * blurDirection * s * spread);
weight += lw;
}

View File

@@ -20,6 +20,6 @@ vec3 ACESFilm(vec3 x) {
void main() {
vec3 texColor = texture(tex0,v_texCoord0).rgb;
vec3 color = ACESFilm(texColor * exposureBias);
vec3 retColor = pow(color, vec3(1/2.2));
o_output = vec4(retColor, 1);
vec3 retColor = pow(color, vec3(1.0/2.2));
o_output = vec4(retColor, 1.0);
}

View File

@@ -28,6 +28,6 @@ vec3 reinhard_extended_luminance(vec3 v, float max_white_l) {
void main() {
vec3 texColor = texture(tex0,v_texCoord0).rgb;
vec3 color = reinhard_extended_luminance(texColor * exposureBias, maxLuminance);
vec3 retColor = pow(color, vec3(1/2.2));
vec3 retColor = pow(color, vec3(1.0/2.2));
o_output = vec4(retColor, 1);
}

View File

@@ -22,6 +22,6 @@ void main() {
vec3 whiteScale = 1.0f/Uncharted2Tonemap(vec3(W));
vec3 color = curr*whiteScale;
vec3 retColor = pow(color, vec3(1/2.2));
vec3 retColor = pow(color, vec3(1.0/2.2));
o_output = vec4(retColor, 1);
}

View File

@@ -42,31 +42,31 @@ void main() {
if (mask == 1) {
offset.x = 1.0 - (threshold-t10) / zd(t00-t10);
offset.y = 1.0 - ((threshold-t01) / zd(t00-t01));
offset /= 2;
offset /= 2.0;
}
if (mask == 2) {
offset.x = ((threshold-t00) / zd(t10-t00));
offset.y = 1.0-(threshold-t11) / zd(t10-t11);
offset /= 2;
offset /= 2.0;
}
if (mask == 3) { // OK
float dy0 = 1.0 - (threshold - t01) / zd(t00 - t01);
float dy1 = 1.0 - (threshold - t11) / zd(t10 - t11);
offset.y = dy0 + dy1;
offset.x = 1.0;
offset /= 2;
offset /= 2.0;
}
if (mask == 4) { // OK
offset.x = 1.0 - (threshold-t11) / zd(t01-t11);
offset.y = (threshold-t00) / zd(t01-t00);
offset /= 2;
offset /= 2.0;
}
if (mask == 5) { // OK
float dx0 = 1.0- (threshold - t10) / zd(t00 - t10);
float dx1 = 1.0-(threshold - t11) / zd(t01 - t11);
offset.x = dx0 + dx1;
offset.y = 1.0;
offset /= 2;
offset /= 2.0;
}
if (mask == 6 || mask == 9) {
offset = vec2(0.5);
@@ -74,41 +74,41 @@ void main() {
if (mask == 7) { // OK
offset.x = 1.0 - (threshold-t11) / zd(t01-t11);
offset.y = 1.0 - (threshold-t11) / zd(t10-t11);
offset /= 2;
offset /= 2.0;
}
if (mask == 8) { // OK
offset.x = (threshold-t01) / zd(t11-t01);
offset.y = (threshold-t10) / zd(t11-t10);
offset /= 2;
offset /= 2.0;
}
if (mask == 10) { // OK
float dx0 = (threshold - t00) / zd(t10 - t00);
float dx1 = (threshold - t01) / zd(t11 - t01);
offset.x = (dx0 + dx1);
offset.y = 1.0;
offset /= 2;
offset /= 2.0;
}
if (mask == 11) { // OK
offset.x = (threshold-t01) / zd(t11-t01);
offset.y = (threshold-t01) / zd(t00-t01);
offset /= 2;
offset /= 2.0;
}
if (mask == 12) { // OK
float dy0 = (threshold - t00) / zd(t01 - t00);
float dy1 = (threshold - t10) / zd(t11 - t10);
offset.y = dy0 + dy1;
offset.x = 1.0;
offset /= 2;
offset /= 2.0;
}
if (mask == 13) { // OK
offset.x = 1.0 - (threshold-t10) / zd(t00-t10);
offset.y = (threshold-t10) / zd(t11-t10);
offset /= 2;
offset /= 2.0;
}
if (mask == 14) { // OK
offset.x = (threshold-t00) / zd(t10-t00);
offset.y = (threshold-t00) / zd(t01-t00);
offset /= 2;
offset /= 2.0;
}
float contour = (mask != 0 && mask != 15)?1.0:0.0;

View File

@@ -51,9 +51,9 @@ void main() {
}
#else
if (!normalizedDistance) {
o_color = vec4( length(pixelDistance * distanceScale).xx, outputData, 1.0);
o_color = vec4( vec2(length(pixelDistance * distanceScale)), outputData, 1.0);
} else if (!unitDirection) {
o_color = vec4( length(pixelDistance / originalSize).xx, outputData, 1.0);
o_color = vec4( vec2(length(pixelDistance / originalSize)), outputData, 1.0);
}
#endif
}

View File

@@ -39,7 +39,7 @@ void main() {
fc += backgroundColor * backgroundColor.a;
}
if ((d0 < angleTreshold || d1 < angleTreshold || d2 < angleTreshold || d3 < angleTreshold) && ct.z > 0.0 && length(ct.xy) > 4) {
if ((d0 < angleTreshold || d1 < angleTreshold || d2 < angleTreshold || d3 < angleTreshold) && ct.z > 0.0 && length(ct.xy) > 4.0) {
fc = fc * (1.0 - skeletonColor.a) + (skeletonColor * skeletonColor.a);
}
o_color = fc;

View File

@@ -41,7 +41,7 @@ private fun PointLight.fs(index: Int, hasNormalAttribute: Boolean): String = """
| vec3 L = normalize(Lr);
|
| float side = ${if (hasNormalAttribute) "dot(L, N)" else "3.1415"};
| f_diffuse += attenuation * max(0, side / 3.1415) * p_lightColor$index.rgb * m_color.rgb;
| f_diffuse += attenuation * max(0.0, side / 3.1415) * p_lightColor$index.rgb * m_color.rgb;
| f_specular += attenuation * ggx(N, V, L, m_roughness, m_f0) * p_lightColor$index.rgb * m_color.rgb;
}
""".trimMargin()
@@ -71,7 +71,7 @@ private fun DirectionalLight.fs(index: Int, hasNormalAttribute: Boolean) = """
private fun HemisphereLight.fs(index: Int, hasNormalAttribute: Boolean): String = """
|{
| float f = ${if (hasNormalAttribute) "dot(N, p_lightDirection$index) * 0.5 + 0.5" else "1"};
| float f = ${if (hasNormalAttribute) "dot(N, p_lightDirection$index) * 0.5 + 0.5" else "1.0"};
| vec3 irr = ${irradianceMap?.let { "texture(p_lightIrradianceMap$index, N).rgb" } ?: "vec3(1.0)"};
| f_diffuse += mix(p_lightDownColor$index.rgb, p_lightUpColor$index.rgb, f) * irr * ((1.0 - m_metalness) * m_color.rgb) * m_ambientOcclusion;
|}
@@ -460,7 +460,7 @@ class PBRMaterial : Material {
vec3 Vr = ep - v_worldPosition;
vec3 V = normalize(Vr);
float NoV = ${if (primitiveContext.hasNormalAttribute) "abs(dot(N, V)) + 1e-5" else "1"};
float NoV = ${if (primitiveContext.hasNormalAttribute) "abs(dot(N, V)) + 1e-5" else "1.0"};
${if (environmentMap && materialContext.meshCubemaps.isNotEmpty() && primitiveContext.hasNormalAttribute) """
{

View File

@@ -84,7 +84,7 @@ class SceneRenderer {
}
val target = shadowLightTargets.getOrPut(shadowLight) {
val mapSize = (shadowLight.shadows as Shadows.MappedShadows).mapSize
pass.createPassTarget(mapSize, mapSize, DepthFormat.DEPTH16)
pass.createPassTarget(mapSize, mapSize, DepthFormat.DEPTH_STENCIL)
}
target.clearDepth(depth = 1.0)

View File

@@ -93,7 +93,7 @@ val shaderVSM = """
|// -- shaderVSM
|float linstep(float min, float max, float v)
|{
| return clamp((v - min) / (max - min), 0, 1);
| return clamp((v - min) / (max - min), 0.0, 1.0);
|}
|// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch08.html
|float chebyshevUpperBound(vec2 moments, float t, float minVariance) {
@@ -224,7 +224,7 @@ float ggx(vec3 N, vec3 V, vec3 L, float roughness, float F0)
D = alphaSqr/(pi * denom * denom);
// F
float dotLH5 = pow(1.0f-dotLH,5);
float dotLH5 = pow(1.0f-dotLH,5.0);
F = F0 + (1.0-F0)*(dotLH5);
// V

View File

@@ -27,7 +27,7 @@ fun Shadows.VSM.fs(index: Int) : String = """
|{
| vec4 smc = (p_lightTransform$index * vec4(v_worldPosition,1.0));
| vec3 lightProj = (smc.xyz/smc.w) * 0.5 + 0.5;
| if (lightProj.x > 0.0 && lightProj.x < 1.0 && lightProj.y > 0 && lightProj.y < 1) {
| if (lightProj.x > 0.0 && lightProj.x < 1.0 && lightProj.y > 0.0 && lightProj.y < 1.0) {
| vec2 moments = texture(p_lightShadowMap$index, lightProj.xy).xy;
| attenuation *= (chebyshevUpperBound(moments, length(Lr), 50.0));
| }
@@ -38,9 +38,9 @@ fun Shadows.Simple.fs(index: Int): String = """
|{
| vec4 smc = (p_lightTransform$index * vec4(v_worldPosition,1.0));
| vec3 lightProj = (smc.xyz/smc.w) * 0.5 + 0.5;
| if (lightProj.x > 0.0 && lightProj.x < 1.0 && lightProj.y > 0 && lightProj.y < 1) {
| if (lightProj.x > 0.0 && lightProj.x < 1.0 && lightProj.y > 0.0 && lightProj.y < 1.0) {
| vec3 smz = texture(p_lightShadowMap$index, lightProj.xy).rgb;
| vec2 step = 1.0 / textureSize(p_lightShadowMap$index,0);
| vec2 step = 1.0 / vec2(textureSize(p_lightShadowMap$index,0));
| float result = 0.0;
| float compToZ = (lightProj.z- 0.0020 * tan(acos(NoL))) - 0.0003;
| float currentDepth = lightProj.z;
@@ -69,19 +69,19 @@ fun Shadows.PCF.fs(index: Int): String = """
| fTaps_Poisson[11] = vec2(-.792,-.598);
| vec4 smc = (p_lightTransform$index * vec4(v_worldPosition,1.0));
| vec3 lightProj = (smc.xyz/smc.w) * 0.5 + 0.5;
| if (lightProj.x > 0.0 && lightProj.x < 1.0 && lightProj.y > 0 && lightProj.y < 1) {
| if (lightProj.x > 0.0 && lightProj.x < 1.0 && lightProj.y > 0.0 && lightProj.y < 1.0) {
| vec3 smz = texture(p_lightShadowMap$index, lightProj.xy).rgb;
| vec2 stepSize = 1.0 / textureSize(p_lightShadowMap$index,0);
| vec2 stepSize = 1.0 / vec2(textureSize(p_lightShadowMap$index,0));
| float result = 0.0;
| float compToZ = (lightProj.z- 0.0020 * tan(acos(NoL))) - 0.0003;
| float noise = hash22(lightProj.xy*10.0).x;
| float r = noise * 3.1415926535 * 2.0;
| mat2 rot = mat2( vec2(cos(r), -sin(r)), vec2(sin(r),cos(r)));
| for (int i = 0; i < 12; ++i) {
| float depth = texture(p_lightShadowMap$index, lightProj.xy + rot*fTaps_Poisson[i]*i*lrl*stepSize ).r;
| float depth = texture(p_lightShadowMap$index, lightProj.xy + rot*fTaps_Poisson[i]*float(i)*lrl*stepSize ).r;
| result += step(compToZ, depth);
| }
| result /= 12;
| result /= 12.0;
| float currentDepth = lightProj.z;
| float closestDepth = smz.x;
| float shadow = result;// (currentDepth - 0.0020 * tan(acos(NoL))) - 0.0003 >= closestDepth ? 0.0 : 1.0;

View File

@@ -97,7 +97,7 @@ fun GltfFile.buildSceneNodes(): GltfSceneData {
val cb = loadImage(MPPBuffer(localBuffer))
cb.generateMipmaps()
cb.filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
cb.anisotropy = 100.0
cb.anisotropy = 10.0
localBuffer.limit(localBuffer.capacity())
cb
} ?: error("no uri and no bufferview")

View File

@@ -295,7 +295,7 @@ void main() {
float angle = abs(dot(reflected, viewNormal));
float frontalFade = clamp(-reflected.z,0, 1);
float frontalFade = clamp(-reflected.z,0.0, 1.0);
if ( true ) {
bool hit = traceScreenSpaceRay1(
viewPos,

View File

@@ -1,12 +1,10 @@
#version 330
uniform usampler2D tex0;
uniform highp usampler2D tex0;
in vec2 v_texCoord0;
out vec4 o_output;
void main() {
ivec2 ts = textureSize(tex0, 0);
ivec2 pixel = ivec2(v_texCoord0 * ts);
ivec2 pixel = ivec2(v_texCoord0 * vec2(ts));
ivec2 c = pixel;
ivec2 n = c + ivec2(0, -1);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -8,11 +8,9 @@ import org.openrndr.draw.ColorType
import org.openrndr.draw.colorBuffer
import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.renderTarget
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.noise.Random
import org.openrndr.math.Polar
import org.openrndr.math.clamp
import org.openrndr.math.mix
import org.openrndr.poissonfill.PoissonFill
import org.openrndr.shape.Rectangle
import kotlin.math.sin
@@ -25,7 +23,7 @@ fun main() {
val dry = renderTarget(width, height) {
colorBuffer(type = ColorType.FLOAT32)
}
val wet = colorBuffer(width, height)
val wet = colorBuffer(width, height, type = ColorType.FLOAT32)
val fx = PoissonFill()

View File

@@ -1,7 +1,4 @@
// from https://github.com/kosua20/Rendu/blob/master/resources/common/shaders/screens/convolution-pyramid/downscale.frag
#version 330
in vec2 v_texCoord0;
uniform vec2 targetSize;
@@ -43,7 +40,8 @@ void main(){
continue;
//accum = vec4(1.0, 0.0, 0.0, 1.0);
}
accum += h1[dx+2] * h1[dy+2] * texelFetch(tex0, newPix,0);
accum += h1[dx+2] * h1[dy+2] * texelFetch(tex0, newPix,0
);
}
}
o_output = accum;

View File

@@ -1,7 +1,5 @@
// from https://github.com/kosua20/Rendu/blob/master/resources/common/shaders/screens/convolution-pyramid/fill-boundary.frag
#version 330
in vec2 v_texCoord0;
uniform sampler2D tex0;

View File

@@ -1,7 +1,5 @@
// from https://github.com/kosua20/Rendu/blob/master/resources/common/shaders/screens/convolution-pyramid/fill-combine.frag
#version 330
in vec2 v_texCoord0;
uniform sampler2D tex0; // result of pyramid convolution

View File

@@ -1,7 +1,5 @@
// from https://github.com/kosua20/Rendu/blob/master/resources/common/shaders/screens/convolution-pyramid/filter.frag
#version 330
//layout(binding = 0) uniform sampler2D screenTexture; ///< Level to filter.
uniform sampler2D tex0;
@@ -24,7 +22,7 @@ void main(){
vec4 accum = vec4(0.0);
ivec2 size = textureSize(tex0, 0).xy;
ivec2 coords = ivec2(v_texCoord0 * size);
ivec2 coords = ivec2(v_texCoord0 * vec2(size));
for(int dy = -1; dy <=1; dy++){
for(int dx = -1; dx <=1; dx++){

View File

@@ -1,7 +1,5 @@
// from https://github.com/kosua20/Rendu/blob/master/resources/common/shaders/screens/convolution-pyramid/upscale.frag
#version 330
in vec2 v_texCoord0;
uniform sampler2D tex0; ///< Current h1 filtered level.
@@ -27,7 +25,7 @@ bool isOutside(ivec2 pos, ivec2 size){
void main(){
vec4 accum = vec4(0.0);
ivec2 size = textureSize(tex0, 0).xy;
ivec2 coords = ivec2(v_texCoord0 * size);
ivec2 coords = ivec2(v_texCoord0 * vec2(size));
for(int dy = -1; dy <=1; dy++){
for(int dx = -1; dx <=1; dx++){