Hi, When I tried to set up some custom material shader on a mesh, the current fog setting does not affect that object when I apply ShadeEntity.
A good example is with per pixel lighting demo where the scene fog is ignored if you add fog in it.
' sl_pixellight.bmx
' per pixel lighting
Strict
Framework Openb3d.B3dglgraphics
Graphics3D 800,600,0,2
Local camera:TCamera=CreateCamera()
CameraClsColor camera,70,180,235
Local lighttype%=2 ' set lighttype 1 or 2
Local light:TLight=CreateLight(lighttype)
RotateEntity light,45,45,0
PositionEntity light,10,10,0
LightRange light , 10
CameraFogMode camera,1
CameraFogRange camera , 1 , 100
CameraFogColor camera , 94 , 95 , 110
Local teapot:TMesh=LoadMesh("media/teapot.b3d")
PositionEntity teapot,0,5,3
Local teapot2:TMesh=LoadMesh("media/teapot.b3d")
PositionEntity teapot2,0,5,3
HideEntity teapot2
Local shader:TShader=LoadShader("","shaders/pixellight.vert.glsl","shaders/pixellight.frag.glsl")
SetInteger(shader,"lighttype",lighttype)
ShadeEntity(teapot,shader)
Local pixellight%=1
Local MSY
Local MSX
While Not KeyDown(KEY_ESCAPE)
' enable pixel lighting
If KeyHit(KEY_P)
pixellight=Not pixellight
If pixellight
HideEntity teapot2 ; ShowEntity teapot
Else
HideEntity teapot ; ShowEntity teapot2
EndIf
EndIf
MSY = MouseY() - GraphicsHeight()/2
MSX = MouseX() - GraphicsWidth()/2
RotateEntity camera, EntityPitch(camera) + MSY/2, EntityYaw(camera) - MSX/2, 0
If KeyDown(KEY_S) Then MoveEntity camera, 0, 0, -1
If KeyDown(KEY_W) Then MoveEntity camera, 0, 0, 1
If KeyDown(KEY_A) Then MoveEntity camera, -1, 0, 0
If KeyDown(KEY_D) Then MoveEntity camera , 1 , 0 , 0
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
TurnEntity teapot,0,0.5,-0.1
TurnEntity teapot2,0,0.5,-0.1
RenderWorld
Text 0,0,"lighttype = "+lighttype+", P: pixellight = "+pixellight
Flip
Wend
End
Maybe this has something to do with passing some uniforms or values to the pixel/frag shader or something?
|