Improve compatibility with GLES back-end
This commit is contained in:
@@ -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) """
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 |
@@ -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()
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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++){
|
||||
|
||||
@@ -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++){
|
||||
|
||||
Reference in New Issue
Block a user