I think so video explains the problem good enaugh…
Had you changed anything with the file, or was that a fresh download?
Also, what kind of graphics card are you using, and are your drivers up to date?
I am using this very water shader in a project of mine…
(although I have modified it quite a bit, but it worked for me on first download)
Hi adriansnetlis,
is this the same issue that you are reporting here https://developer.blender.org/T43839 ?
It is only to know it because the martinsh blend file is easier to debug.
No, it is not the same. This doesn’t crash, it’s buffer layer just looks fully blue. I haven’t modified it. Maybe it is possible to get rid of that buffer layer? However, PC data is the same as in that bug…
Hello! Maybe you can try to increase the clip end value of the rendercamera (“watercamera”)…
Nope, doesn’t help…
Have you some errors in the console? When you modify background color bgR, bgG, bgB in watertexture.py, does the water color change?
No console for me(it is difficult to access it in linux version of blender), but the water color changes. However, if I change theese values, water don’t get reflections…
To launch Blender in a linux console, open a terminal, then type in ./path/to/blender/blender
It seems that’s a problem with watertexture.py. Have you modified it? Try to get the watertexture.py script from watershader v1.1, rename your watercamera rendercamera and see if it works… (you’ll probably have to remove lens filter in front of the camera…)
EDIT: have you tried to change clip end value both on normal camera and watercamera? (increase it to 10000)
When you download the .blend from here: https://dl.dropboxusercontent.com/u/11542084/water_0.99_optimized.blend you have the same issue?
Yes, I have the same issue when I download from there. Maybe you could try to modify it as if I remove lens filter, I can see grid etc…
Maybe you can try this watertexture.py script:
from bge import logic as gfrom bge import texture
from mathutils import *
from math import *
import bgl
#import bpy
cont = g.getCurrentController()
own = cont.owner
scene = g.getCurrentScene()
objlist = scene.objects
reflsize = 512 #reflection tex dimensions
refrsize = 512 #refraction tex dimensions
offset = 0.2 #geometry clipping offset
#texture background color
bgR = 0.63
bgG = 0.84
bgB = 1.0
bgA = 0.0
activecam = scene.active_camera
viewer = activecam
#if 'initcam' not in own:
# cam = bpy.data.cameras.new('rendercamera')
# cam_ob = bpy.data.objects.new('watercamera', cam)
# bpy.context.scene.objects.link(cam_ob)
# own['initcam'] = 1
lens = objlist['lens']
rendercamera = objlist['watercamera'] #camera used for rendering the textures
#setting lens and projection to rendercamera same as active camera
rendercamera.lens = activecam.lens
rendercamera.projection_matrix = activecam.projection_matrix
#rotation and mirror matrices
m1=Matrix(own.orientation)
m2=Matrix(own.orientation)
m2.invert()
r180 = Matrix.Rotation(radians(180),3,'Y')
unmir = Matrix.Scale(-1,3,Vector([1,0,0]))
#disable visibility for the water surface during texture rendering
own.visible = False
lens.visible = False
###REFLECTION####################
#initializing camera for reflection pass
pos = (viewer.position - own.position)*m1
pos = own.position + pos*r180*unmir*m2
ori = Matrix(viewer.orientation)
ori.transpose()
ori = ori*m1*r180*unmir*m2
ori.transpose()
#delay reduction using delta offset
if 'oldori' not in own:
own['oldori'] = ori
own['oldpos'] = pos
own['deltaori'] = own['oldori']-ori
own['deltapos'] = own['oldpos']-pos
own['deltaori'] = own['oldori']-ori
own['deltapos'] = own['oldpos']-pos
#orienting and positioning the reflection rendercamera
rendercamera.orientation = ori - own['deltaori']
rendercamera.position = pos - own['deltapos']
#storing the old orientation and position of the camera
own['oldori'] = ori
own['oldpos'] = pos
#culling front faces as the camera is scaled to -1
bgl.glCullFace(bgl.GL_FRONT)
#plane equation
normal = own.getAxisVect((0.0, 0.0, 1.0)) #plane normals Z=front
D = -own.position.project(normal).magnitude #closest distance from center to plane
V = (activecam.position-own.position).normalized().dot(normal) #VdotN to get frontface/backface
#invert normals when backface
if V<0:
normal = -normal
#making a clipping plane buffer
plane = bgl.Buffer(bgl.GL_DOUBLE, [4], [-normal[0], -normal[1], -normal[2], -D+offset])
bgl.glClipPlane(bgl.GL_CLIP_PLANE0,plane)
bgl.glEnable(bgl.GL_CLIP_PLANE0)
#rendering the reflection texture in tex channel 0
if not hasattr(g, 'reflection'):
g.reflection = texture.Texture(own, 0, 0)
g.reflection.source = texture.ImageRender(scene,rendercamera)
g.reflection.source.capsize = [reflsize,reflsize]
g.reflection.source.background = [int(bgR*255),int(bgG*255),int(bgB*255),int(bgA*255)]
g.reflection.refresh(True)
#restoring face culling to normal and disabling the geometry clipping
bgl.glCullFace(bgl.GL_BACK)
bgl.glDisable(bgl.GL_CLIP_PLANE0)
###REFRACTION####################
#initializing camera for refraction pass
pos = viewer.position
ori = Matrix(viewer.orientation)
#delay reduction using delta offset
if 'oldori1' not in own:
own['oldori1'] = own.orientation
own['oldpos1'] = own.position
own['deltaori1'] = own['oldori1']-viewer.orientation
own['deltapos1'] = own['oldpos1']-viewer.position
own['deltaori1'] = own['oldori1']-ori
own['deltapos1'] = own['oldpos1']-pos
#orienting and positioning the refraction rendercamera
rendercamera.orientation = ori - own['deltaori1']
rendercamera.position = pos - own['deltapos1']
#storing the old orientation and position of the camera
own['oldori1'] = ori
own['oldpos1'] = pos
#making another clipping plane buffer
plane = bgl.Buffer(bgl.GL_DOUBLE, [4], [normal[0], normal[1], normal[2], -D+offset])
bgl.glClipPlane(bgl.GL_CLIP_PLANE1,plane)
bgl.glEnable(bgl.GL_CLIP_PLANE1)
#rendering the refraction texture in tex channel 1
if not hasattr(g, 'refraction'):
g.refraction = texture.Texture(own, 0, 1)
g.refraction.source = texture.ImageRender(scene,rendercamera)
g.refraction.source.capsize = [refrsize,refrsize]
g.refraction.source.background = [int(bgR*255),int(bgG*255),int(bgB*255),int(bgA*255)]
g.refraction.refresh(True)
#disabling the geometry clipping
bgl.glDisable(bgl.GL_CLIP_PLANE1)
#restoreing visibility for the water surface
own.visible = True
lens.visible = True
With that water surface is fully black. Underwater still works:D
Try… in water_0.99_optimized.blend, watertexture.py
line 46 from:
r180 = Matrix.Rotation(radians(180),3,‘Y’)
to
r180 = Matrix.Rotation(radians(15),3,‘Y’)
Great, it works, looks much better. However- how do I make this use only water, underwater and sky, nothing else of the effects?