Ocean shader draws black water

Everything related to 3D programming
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Ocean shader draws black water

Post by MightyMAC »

Hi guys,

I tried to implement the water from the ocean demo into my current project and now I have the problem that the water is black, looking like an ocean of tar, no texture showing (should be the skybox texture). I first thought of some missing resources or something, but the shader is loaded correctly (water surface is moving) and the skybox is showing (so the needed skybox textures should be found, too). Ogre log doesn't show any errors. I experimented with the original ocean demo and tested how it would behave if I delete some of the resources, etc. but did not find a clue (the ocean never turns black). It would be a bit complicated to show the actual code from my project because I'd have to rip out all needed parts out of a 40k+ lines project and so I ask quite general:

Does anybody of the shader pros around here have an idea why the water is complete black? Did anybody have a similar problem in the past?

Regards
MAC
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Ocean shader draws black water

Post by Samuel »

Sounds like your using the example Idle posted a while back. Have you changed anything in the shaders or scripts?
Could you post a screenshot of the water?
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: Ocean shader draws black water

Post by MightyMAC »

Yes, I think it's the one from Idle. I didn't change anything in the shaders or scripts. I just made a small video of what it looks like:
http://www.mac-bs.de/temp/Wasser.mp4

As you can see the water is moving and the skybox is showing, too.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Ocean shader draws black water

Post by Samuel »

When I get some spare time I'll try to replicate the problem. I'll let you know if I find anything.
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Ocean shader draws black water

Post by idle »

maybe you should check your orge log the demo runs here no problem
after commenting out the lines of code with GetEntityMaterial

Code: Select all

;Cross platform Ocean glsl vertex and fragment shader demo, from ogre 1.7.3 samples OceanDemo

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
If Not Subsystem("OpenGL")
   MessageRequester("Warning :", "Please compile With OpenGL subsystem") 
   End 
 EndIf   
CompilerEndIf

Structure ScriptParams
   entity.i
   subentity.i
   index.i
EndStructure 

Structure OceanScene 
  entity.i
  matOcean.i
  matOcean2.i 
  matFlare.i
EndStructure

Global ocean.OceanScene

Global NewMap Script.ScriptParams(64)

Procedure AddNamedParameter(entity.i,subentity.i,name.s,index.i,value.f,value1.f=0,value2.f=0,value3.f=0) 
   Script(name)\entity = entity
   Script()\subentity = subentity 
   Script()\index = index  
   EntityCustomParameter(entity,subentity,index,value,value1,value2,value3)
EndProcedure

Procedure SetNamedParmeter(name.s,value.f,value1.f=0,value2.f=0,value3.f=0) 
   Protected *ScriptParam.ScriptParams
   *ScriptParam = @script(name)
   If *ScriptParam
     EntityCustomParameter(*ScriptParam\entity,*ScriptParam\subentity,*ScriptParam\index,value,value1,value2,value3)
  EndIf    
  EndProcedure  


#CameraSpeed = 5

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

;define variables to control Ocean2 material 
Global WaveFreq.f,WaveAmp.f,BumpScale.f,TextureScaleX.f,TextureScaleY.f,WaveSpeedX.f,WaveSpeedY.f,ActiveOcean.i, bshowgui.i

;shader setting index enums
Enumeration 1
#WaveFreq  
#WaveAmp 
#BumpScale  
#TextureScaleX  
#TextureScaleY 
#WaveSpeedX  
#WaveSpeedY 
EndEnumeration 

Enumeration 100
  #GUIWindow
  #Ocean1 
  #Ocean2 
  #Frequency 
  #Amplitude
  #Surface
  #SpeedX
  #SpeedY
  #ScaleX
  #ScaleY
  #Close
EndEnumeration

#FrequencySF = 0.001
#AmplitudeSF = 0.1 
#SurfaceSF = 0.10
#SpeedXSF = 0.001
#SpeedYSF = 0.001

    

Procedure OpenControls(state=0)
  ;note you need to set AutoScaled xml attributes in the guis .font and .imageset to false 
  ;otherwise it will scale them  
  If Not IsWindow3D(#GUIWindow)
    OpenWindow3D(#GUIWindow, 50, 50, 300, 300, "Ocean shader",#PB_Window3D_Invisible)
		OptionGadget3D(#Ocean1, 10, 30, 80,25,"Ocean1")
		OptionGadget3D(#Ocean2, 100, 30, 80,25,"Ocean2")
		TextGadget3D(#PB_Any,10,60,80,25,"Frequency") 
		SpinGadget3D(#Frequency,10,90,80,25,1,1000) 
		TextGadget3D(#PB_Any,100,60,80,25,"Amplitude")  
		SpinGadget3D(#Amplitude,100,90,80,25,1,100)   
		TextGadget3D(#PB_Any,190,60,80,25,"Surface")
		SpinGadget3D(#Surface,190,90,80,25,1,10)  
		
		TextGadget3D(#PB_Any,10,120,80,25,"SpeedX") 
		SpinGadget3D(#SpeedX,10,150,80,25,1,1000)  
		TextGadget3D(#PB_Any,100,120,80,25,"SpeedY")  
		SpinGadget3D(#SpeedY,100,150,80,25,1,1000)  
		
		TextGadget3D(#PB_Any,10,180,80,25,"ScaleX") 
		SpinGadget3D(#ScaleX,10,210,80,25,1,100)  
		TextGadget3D(#PB_Any,100,180,80,25,"ScaleY")  
		SpinGadget3D(#ScaleY,100,210,80,25,1,100)  
		
		ButtonGadget3D(#Close,10, 250,80,25,"Close")
		If ActiveOcean = #Ocean1
		  SetGadgetState3D(#Ocean1,1) 
		  SetGadgetState3D(#Ocean2,0)
	  Else 
	    SetGadgetState3D(#Ocean1,0) 
		  SetGadgetState3D(#Ocean2,1)
		EndIf 
		x.i = 1.0/#Frequencysf * WaveFreq
		SetGadgetState3D(#Frequency,x)
		SetGadgetText3D(#Frequency,Str(x)) 
		x = (1.0/#AmplitudeSF) * WaveAmp
		SetGadgetState3D(#Amplitude,x)
		SetGadgetText3D(#Amplitude,Str(x))
		x = (1.0/#SurfaceSF)*BumpScale
		SetGadgetState3D(#Surface,x)
		SetGadgetText3D(#Surface,Str(x))
		x = (1.0/#SpeedXSF)*WaveSpeedX
		SetGadgetState3D(#SpeedX,x)
		SetGadgetText3D(#SpeedX,Str(x))
		x = (1.0/#SpeedYSF)*WaveSpeedY
		SetGadgetState3D(#SpeedY,x)
		SetGadgetText3D(#SpeedY,Str(x))
    SetGadgetState3D(#ScaleX,TextureScaleX)
    SetGadgetText3D(#ScaleX,Str(TextureScaleX))
    SetGadgetState3D(#ScaleY,TextureScaleY)
    SetGadgetText3D(#ScaleY,Str(TextureScaleY))
  EndIf 
  If state = 1
    ShowGUI(128,1)
	  HideWindow3D(#GUIWindow,0)
	Else 
	  ShowGUI(128,0)
	  HideWindow3D(#GUIWindow,1)
	EndIf   
		
EndProcedure  

Procedure CheckOutGui(x,y)
  Protected L,R,T,B
  L =  WindowX3D(#GUIWindow)
  R = L + WindowWidth3D(#GUIWindow)
  T =  WindowY3D(#GUIWindow)
  B = T + WindowHeight3D(#GUIWindow)
  If (x > L And x < R And y > T And y < B)   
      ProcedureReturn 0 
  EndIf 
  ProcedureReturn 1 
EndProcedure  

Procedure HandleGui() 
 
  Repeat
      	Event = WindowEvent3D()
       	Select Event
      		Case #PB_Event3D_Gadget
      		  Select EventGadget3D() 
      		    Case #Close
      		      bshowgui = 1 - bshowgui
                If bshowgui 
                 OpenControls(1)
      	        Else 
      	         OpenControls(0)
      	        EndIf   
      		    Case #Frequency
      		      WaveFreq = GetGadgetState3D(#Frequency) * #FrequencySF
      		      If bshowgui
      		         ;EntityCustomParameter(ocean\entity,0,#WaveFreq,WaveFreq,0,0,0)
      		         SetNamedParmeter("WaveFrequency",WaveFreq)   
      		      EndIf   
      		     Case #Amplitude
      		      WaveAmp = GetGadgetState3D(#Amplitude) * #AmplitudeSF  
      		      If bshowgui
      		         ;EntityCustomParameter(ocean\entity,0,#WaveAmp,WaveAmp,0,0,0)
      		         SetNamedParmeter("WaveAmplitude",WaveAmp)   
      		      EndIf   
      		    Case #Surface
      		      BumpScale = GetGadgetState3D(#Surface) * #SurfaceSF
      		      If bshowgui
      		         ;EntityCustomParameter(ocean\entity,0,#BumpScale,BumpScale,0,0,0)
      		         SetNamedParmeter("BumpScale",BumpScale)   
      		      EndIf 
      		    Case #speedX
      		      WaveSpeedX = GetGadgetState3D(#SpeedX) * #SpeedXSF
      		      If bshowgui
      		         ;EntityCustomParameter(ocean\entity,0,#WaveSpeedX,WaveSpeedX,0,0,0)
      		         SetNamedParmeter("WaveSpeedX",WaveSpeedX)   
      		      EndIf   
      		    Case #speedY
      		      WaveSpeedY = GetGadgetState3D(#SpeedY) * #SpeedYSF
      		      If bshowgui 
      		         ;EntityCustomParameter(ocean\entity,0,#WaveSpeedY,WaveSpeedY,0,0,0)
      		         SetNamedParmeter("WaveSpeedY",WaveSpeedY)   
      		      EndIf   
      		    Case #scaleX
      		      TextureScaleX = GetGadgetState3D(#ScaleX)
      		      If bshowgui
      		         ;EntityCustomParameter(ocean\entity,0,#TextureScaleX,TextureScaleX,0,0,0)
      		         SetNamedParmeter("TextureScaleX",TextureScaleX)   
      		      EndIf   
 		   		    Case #scaleY   
      		      TextureScaleY = GetGadgetState3D(#ScaleY)
      		      If bshowgui
      		         ;EntityCustomParameter(ocean\entity,0,#TextureScaleY,TextureScaleY,0,0,0)
      		         SetNamedParmeter("TextureScaleY",TextureScaleY)   
      		      EndIf   
 		  		    Case #Ocean1
 		  		     ; If MaterialID(ocean\matOcean) <> GetEntityMaterial(ocean\entity)
 		  		       SetEntityMaterial(ocean\entity, MaterialID(ocean\matOcean)) 
                 ActiveOcean = #Ocean1
               ;EndIf
             Case #Ocean2 
               ;If MaterialID(ocean\matOcean2) <> GetEntityMaterial(ocean\entity)
                SetEntityMaterial(ocean\entity, MaterialID(ocean\matOcean2)) 
                ActiveOcean = #Ocean2  
              ;EndIf  
             EndSelect
         EndSelect
     	Until Event = 0
  EndProcedure   
  
Procedure main()
     
  If InitEngine3D(#PB_Engine3D_DebugLog)
    Add3DArchive("./GUI/", #PB_3DArchive_FileSystem)
    Add3DArchive("./Data/", #PB_3DArchive_FileSystem)
    Add3DArchive("./Data/cubemapsJS.zip", #PB_3DArchive_Zip)
       
     InitSprite()
     InitKeyboard()
     InitMouse()
      
    If Screen3DRequester()
      Parse3DScripts()   ;note you need to open a screen before calling parse3DScripts if the scripts contain glsl or hlsl programs
      
      KeyboardMode(#PB_Keyboard_International)  ;set keyboard to international so arrow keys will work   
           
        
      ocean\matOcean =  GetScriptMaterial(#PB_Any,"Ocean")  ;load the ocean material and shader programs 
      ocean\matOcean2 = GetScriptMaterial(#PB_Any,"Ocean2") 
      
      CreatePlane(1,1000,1000,256,128,1,1) ;create a surface to render the ocean on 
      
      
      ocean\entity = CreateEntity(#PB_Any, MeshID(1), MaterialID(ocean\matOcean2)) ;set the material to the entity
      
      ;set up some control variables for the ocean2 material and for use setting the gui controls    
      WaveFreq = 0.028 
      WaveAmp = 1.8 
      BumpScale = 0.2 
      TextureScaleX = 25
      TextureScaleY = 25 
      WaveSpeedX = 0.015
      WaveSpeedY = 0.005
      
      ;Set shader values wraps EntityCustomParameter 
      AddNamedParameter(ocean\entity,0,"WaveFrequency",1,WaveFreq) 
      AddNamedParameter(ocean\entity,0,"WaveAmplitude",2,WaveAmp) 
      AddNamedParameter(ocean\entity,0,"BumpScale",3,BumpScale) 
      AddNamedParameter(ocean\entity,0,"TextureScaleX",4,TextureScaleX) 
      AddNamedParameter(ocean\entity,0,"TextureScaleY",5,TextureScaleY) 
      AddNamedParameter(ocean\entity,0,"WaveSpeedX",6,WaveSpeedX) 
      AddNamedParameter(ocean\entity,0,"WaveSpeedY",7,WaveSpeedY) 
          
      ocean\matFlare = CreateMaterial(#PB_Any,LoadTexture(1,"flare.png")) 
      MaterialBlendingMode(ocean\matFlare,#PB_Material_Add)                      
      CreateBillboardGroup(0,MaterialID(ocean\matFlare), 2000, 2000)            
      AddBillboard(0,0,-5000,5000,5000)                                                              
      
      ;note you can change skybox at any time 
      SkyBox("morning.jpg")  
       		
      CreateCamera(0, 0, 0, 100, 100)
      MoveCamera(0,0,10,0)   
      CameraLookAt(0, 0,0,0)
      
      OpenControls()
    
      Repeat
        Screen3DEvents()
        
        If ExamineMouse()
          MouseX = -(MouseDeltaX()*0.10)*#CameraSpeed*0.5
          MouseY = -(MouseDeltaY()*0.10)*#CameraSpeed*0.5
          InputEvent3D(MouseX(), MouseY(),MouseButton(#PB_MouseButton_Left))
        EndIf      
      
        If ExamineKeyboard()
          If KeyboardPushed(#PB_Key_1)  ;switch ocean materal to ocean
            ;If MaterialID(ocean\matOcean) <> GetEntityMaterial(ocean\entity)
              SetEntityMaterial(ocean\entity, MaterialID(ocean\matOcean)) 
              ActiveOcean = #Ocean1
           ; EndIf   
          EndIf 
          If KeyboardPushed(#PB_Key_2) ;switch ocean materail to ocean2 
            ; If MaterialID(ocean\matOcean2) <> GetEntityMaterial(ocean\entity)
              SetEntityMaterial(ocean\entity, MaterialID(ocean\matOcean2)) 
              ActiveOcean = #Ocean2  
            ;EndIf  
          EndIf 
            
          If KeyboardPushed(#PB_Key_Left)
            KeyX = -#CameraSpeed 
          ElseIf KeyboardPushed(#PB_Key_Right)
            KeyX = #CameraSpeed 
          Else
            KeyX = 0
          EndIf
                    
          If KeyboardPushed(#PB_Key_Up)
            KeyY = -#CameraSpeed 
          ElseIf KeyboardPushed(#PB_Key_Down)
            KeyY = #CameraSpeed 
          Else
            KeyY = 0
          EndIf
          
          If KeyboardReleased(#PB_Key_Space)
            bshowgui = 1 - bshowgui
            If bshowgui 
             OpenControls(1)
  	        Else 
  	         OpenControls(0)
  	        EndIf   
          EndIf
        EndIf 
      
        HandleGui()
       	
       	If bshowgui
       	  If CheckOutGui(MouseX(),MouseY())
       	    MoveCamera(0, KeyX,0, KeyY)
            RotateCamera(0, MouseY, MouseX,0, #PB_Relative)
           EndIf 
        Else 
           MoveCamera(0, KeyX,0, KeyY)
           RotateCamera(0, MouseY, MouseX,0, #PB_Relative)
        EndIf    
      
        RotateBillboardGroup(0,0,0,-0.1,#PB_Relative)
        RenderWorld()
        Screen3DStats()
        FlipBuffers()
      Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
    EndIf
  Else
    MessageRequester("Error", "The 3D Engine can't be initialized",0)
  EndIf
EndProcedure 

main()
End
Windows 11, Manjaro, Raspberry Pi OS
Image
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: Ocean shader draws black water

Post by MightyMAC »

Yes, Idle, you're demo always works like a charme. I tried to harm it, but no chance! :D

The Ogre.log doesn't give any errors and the only difference between the log of my project and the log of your demo is the following:

From my project:

Code: Select all

17:13:15: GLSL compiling: Ocean2VS
17:13:15: GLSL compiled: 
17:13:15: Vertex Program:Ocean2VS GLSL link result : 
17:13:15: GLSL compiling: Ocean2FS
17:13:15: GLSL compiled: 
17:13:15: Vertex Program:Ocean2VS Fragment Program:Ocean2FS GLSL link result : 
From your demo:

Code: Select all

21:11:16: GLSL compiling: Ocean2VS
21:11:16: GLSL compiled: 
21:11:16: GLSL compiling: Ocean2FS
21:11:16: GLSL compiled: 
21:11:16: Vertex Program:Ocean2VS Fragment Program:Ocean2FS GLSL link result : 
I don't know what this means and if this has something to do with my problem.
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Ocean shader draws black water

Post by idle »

you can pm me a link to a zip of your source if you want
either you've missed setting something or there's some conflict
Windows 11, Manjaro, Raspberry Pi OS
Image
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: Ocean shader draws black water

Post by MightyMAC »

Got it! The water turns black if you use WorldShadow(#PB_Shadow_Additive). With all other shadow types the water is drawn correctly. Since additive shadow is the only one I can get to work (the others are ugly (modulative) or don't show any shadow at all (texture additive)), this is very frustrating. Do you know why the ocean shader doesn't like additive shadows?
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Ocean shader draws black water

Post by Samuel »

I'm not sure why they don't work, but I'm guessing it has something to do with how additive shadows are rendered.
I've seen several other shaders have issues with additive stencil shadows as well. I've heard additive shadows have issues
with static light, but that might be unrelated.
the others are ugly (modulative) or don't show any shadow at all (texture additive))
How are modulative shadows ugly?
Texture additive shadows won't work until you specify which entities will receive shadows and which ones will cast them.
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: Ocean shader draws black water

Post by MightyMAC »

Here is another video showing the differences between the three shadow types in my island scene. I have a directional light working as a sunlight and a spotlight shining straight down to the middle of the island. With additive shadows on the shadows of both light sources are rendered as expected, with modulative shadows on, the shadows of the spotlight are totally wrong, modulative shadows are not working with spotlights. And with texture additive there are no shadows. I don't know how to specify if entities should cast or receive shadows. The only ways I know to set shadow properties of lights and entities are: EntityRenderMode() for entities and DisableLightShadow() for lights.

http://www.mac-bs.de/temp/EditorWasser.mp4
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Ocean shader draws black water

Post by Samuel »

Is that island an entity or a terrain? If it's an entity you can use EntityRenderMode(#Island, 0) to make it receive textureadditive shadows.
MightyMac wrote:With additive shadows on the shadows of both light sources are rendered as expected, with modulative shadows on, the shadows of the spotlight are totally wrong, modulative shadows are not working with spotlights
I see the opposite of what your seeing.
I watched your video and it seems like modulative shadows are rendering correctly, but the additive are not. The modulative is rendering the shadows from both
lights whereas the additive is only rendering the directional light's shadows.

Here's some example code. Check out both modulative and additive shadow types.

Code: Select all


#CameraSpeed=0.5

Enumeration
  #Window
  #Camera
  #Light1
  #Light2
  #Texture
  #Material
  #PlaneMesh
  #Plane
  #CubeMesh
  #Cube1
  #Cube2
EndEnumeration

Global.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D(#PB_Engine3D_DebugLog)

  InitSprite()
  InitKeyboard()
  InitMouse()
 
  ExamineDesktops()
  DesktopW=DesktopWidth(0)
  DesktopH=DesktopHeight(0)

  OpenWindow(#Window, 0, 0, DesktopW, DesktopH, "Test")
  OpenWindowedScreen(WindowID(#Window), 0, 0, DesktopW, DesktopH, 0, 0, 0)
  
  ;Create Material
  CreateTexture(#Texture,512,512)
  StartDrawing(TextureOutput(#Texture))
    Box(0,0,256,256,RGB(255,125,0))
    Box(256,0,256,256,RGB(255,255,255))
    Box(0,256,256,256,RGB(255,255,255))
    Box(256,256,256,256,RGB(255,125,0))
  StopDrawing()
  CreateMaterial(#Material,TextureID(#Texture))
  
  ;Create Meshes
  CreatePlane(#PlaneMesh,200,200,20,20,20,20)
  CreateCube(#CubeMesh,2)
  
  ;Create Entities
  CreateEntity(#Plane,MeshID(#PlaneMesh),MaterialID(#Material),0,-1,0)
  CreateEntity(#Cube1,MeshID(#CubeMesh),MaterialID(#Material),0,0,0)
  CreateEntity(#Cube2,MeshID(#CubeMesh),MaterialID(#Material),4,3,-2)
  
  ;Create Camera
  CreateCamera(#Camera, 0, 0, 100, 100)
  MoveCamera(#Camera, 8, 5, 10, #PB_Absolute)
  CameraLookAt(#Camera,0,0,0)
  CameraBackColor(#Camera,RGB(80,80,80))
    
  ;Create Lights
  CreateLight(#Light1, RGB(100,100,100),200,200,100,#PB_Light_Directional)
  LightLookAt(#Light1,-100,0,-50)
  CreateLight(#Light2, RGB(100,100,100),0,20,20,#PB_Light_Spot)
  LightLookAt(#Light2,0,0,0)
  
  ;Set World Ambient Color
  AmbientColor(RGB(70,70,70))
  
  ;Modulative renders shadows from both Directional and Spot lights.
  WorldShadows(#PB_Shadow_Modulative,600,RGB(200,200,200))
  
  ;Additive only renders shadows from the Directional light.
  ;WorldShadows(#PB_Shadow_Additive,600,RGB(200,200,200))

  Repeat
    Event=WindowEvent()
    If ExamineMouse()
      MouseX = -MouseDeltaX()/10
      MouseY = -MouseDeltaY()/10
    EndIf
      
    If ExamineKeyboard()
      If KeyboardPushed(#PB_Key_Left)
        KeyX = -#CameraSpeed 
      ElseIf KeyboardPushed(#PB_Key_Right)
        KeyX = #CameraSpeed 
      Else
        KeyX = 0
      EndIf
                  
      If KeyboardPushed(#PB_Key_Up)
        KeyY = -#CameraSpeed 
      ElseIf KeyboardPushed(#PB_Key_Down)
        KeyY = #CameraSpeed 
      Else
        KeyY = 0
      EndIf
    EndIf
      
    RotateCamera(#Camera, MouseY, MouseX, 0, #PB_Relative)
    MoveCamera(#Camera, KeyX, 0, KeyY)

    RenderWorld()
    FlipBuffers()

  Until KeyboardPushed(#PB_Key_Escape)

EndIf
End
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: Ocean shader draws black water

Post by MightyMAC »

Wow, that is some kind of funny stuff. The shadow types in my program are flipped somehow. In the example you posted they work the opposite like you said. I just double checked the usage of shadow constants in my code and they are ok, as far as I can see. I'll have a deeper look later.

All entities in my island scene are meshes. I set the render mode to 0 and have texture shadows now, but they are really ugly and are offset (see markers). Also only the shadows of the directional light are rendered, the spot light is ignored:
Image

This is what modulative looks like in my program (which obviously is additive, like you mentioned right). The problem with this is that the shadows of the spot light are rendered where the light does not shine (market with arrows in the screenshot). The light shines to the area that is marked with the circle:
Image

And this is additive in my program (which should be modulative). The light is fading out of the spot light range, everything is looking beautiful, but in that mode the ocean is made of tar:
Image
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: Ocean shader draws black water

Post by MightyMAC »

Ok, guys, now it works like I wanted it to work. Additive shadows + ocean shader. And it was very simple to achieve: DisableMaterialLighting(OceanMaterial,#True) did the trick! I also added "receive_shadows off" to the ocean.material file but I don't know if has something to do with it. Thanks for all your replies. I'm a happy person now (until I get to the next problem... :D )
Post Reply