Ocean shadows draft

This commit is contained in:
Lubos Lenco 2017-07-07 17:23:32 +02:00
parent edaacb6a38
commit fe1c7c70c1
6 changed files with 61 additions and 5 deletions

View file

@ -11,8 +11,19 @@ precision mediump float;
#include "../compiled.glsl"
#include "../std/gbuffer.glsl"
// #include "../std/math.glsl"
// #ifndef _NoShadows
// #include "../std/shadows.glsl"
// #endif
uniform sampler2D gbufferD;
// #ifndef _NoShadows
// uniform mat4 LWVP;
// uniform float shadowsBias;
// uniform vec2 lightPlane;
// uniform int lightShadow;
//-!-uniform sampler2D shadowMap;
//-!-uniform samplerCube shadowMapCube;
// #endif
// uniform sampler2D gbuffer0;
// uniform sampler2D senvmapRadiance;
uniform sampler2D snoise;
@ -20,7 +31,7 @@ uniform sampler2D snoise;
uniform float time;
uniform vec3 eye;
uniform vec3 eyeLook;
// uniform vec3 light;
// uniform vec3 lightPos;
uniform vec3 ld;
uniform float envmapStrength;
@ -219,6 +230,15 @@ vec3 getSeaColor(vec3 p, vec3 n, vec3 l, vec3 eye, vec3 dist) {
return color;
}
// #ifndef _NoShadows
// float shadowTest(const vec3 lPos) {
// return PCF(lPos.xy, lPos.z - shadowsBias);
// }
// float shadowTestCube(const vec3 lp, const vec3 l) {
// return PCFCube(lp, -l, shadowsBias, lightPlane);
// }
// #endif
void main() {
float gdepth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
// vec4 colorOriginal = vec4(1.0);//texture(tex, texCoord);
@ -309,4 +329,16 @@ void main() {
fragColor.rgb = color;
fragColor.a = clamp(depthZ * seaFade, 0.0, 1.0);
// #ifndef _NoShadows
// if (lightShadow == 1) {
// vec4 lampPos = LWVP * vec4(surfacePoint.xyz, 1.0);
// if (lampPos.w > 0.0) fragColor.rgb *= shadowTest(lampPos.xyz / lampPos.w);
// }
// else if (lightShadow == 2) { // Cube
// vec3 lp = lightPos - surfacePoint.xyz;
// vec3 l = normalize(lp);
// fragColor.rgb *= shadowTestCube(lp, l);
// }
// #endif
}

View file

@ -43,6 +43,31 @@
{
"name": "envmapStrength",
"link": "_envmapStrength"
},
{
"name": "LWVP",
"link": "_biasLampWorldViewProjectionMatrix",
"ifdef": ["_Disabled"]
},
{
"name": "shadowsBias",
"link": "_lampShadowsBias",
"ifdef": ["_Disabled"]
},
{
"name": "lightPlane",
"link": "_lampPlane",
"ifdef": ["_Disabled"]
},
{
"name": "lightShadow",
"link": "_lampCastShadow",
"ifdef": ["_Disabled"]
},
{
"name": "lightPos",
"link": "_lampPosition",
"ifdef": ["_Disabled"]
}
],
"texture_params": [],

View file

@ -453,7 +453,7 @@ def make_sss_pass(stages, node_group, node):
make_quad_pass(stages, node_group, node, target_index=2, bind_target_indices=[3, 4, 5], bind_target_constants=['tex', 'gbufferD', 'gbuffer1'], shader_context='sss_pass/sss_pass/sss_pass_y')
def make_water_pass(stages, node_group, node):
make_quad_pass(stages, node_group, node, target_index=1, bind_target_indices=[2], bind_target_constants=['tex'], shader_context='water_pass/water_pass/water_pass')
make_quad_pass(stages, node_group, node, target_index=1, bind_target_indices=[2, 3], bind_target_constants=['gbufferD', 'shadowMap'], shader_context='water_pass/water_pass/water_pass')
def make_deferred_light_pass(stages, node_group, node):
make_quad_pass(stages, node_group, node, target_index=1, bind_target_indices=[2, 3], bind_target_constants=['gbuffer', 'shadowMap'], shader_context='', with_draw_quad=False)

View file

@ -304,6 +304,7 @@ class WaterPassNode(Node, CGPipelineTreeNode):
self.inputs.new('NodeSocketShader', "Stage")
self.inputs.new('NodeSocketShader', "Target")
self.inputs.new('NodeSocketShader', "GBufferD")
self.inputs.new('NodeSocketShader', "Shadow Map")
self.outputs.new('NodeSocketShader', "Stage")

View file

@ -89,9 +89,7 @@ def get_ffmpeg_path():
return addon_prefs.ffmpeg_path
def get_ease_viewport_camera():
user_preferences = bpy.context.user_preferences
addon_prefs = user_preferences.addons['armory'].preferences
return addon_prefs.ease_viewport_camera
return True
def get_save_on_build():
user_preferences = bpy.context.user_preferences

Binary file not shown.