Hello,
Is it possible to remove some meshes/sprites from showing on the water's refraction ?
Is it possible to remove some meshes/sprites from showing on the water's refraction ?
;D3DCULL Const D3DCULL_NONE = 1 Const D3DCULL_CW = 2 Const D3DCULL_CCW = 3 ;D3DSHADE_MODE Const D3DSHADE_FLAT = 1 Const D3DSHADE_GOURAUD = 2 Const D3DSHADE_PHONG = 3 ;D3DFILL_MODE Const D3DFILL_POINT = 1 Const D3DFILL_WIREFRAME = 2 Const D3DFILL_SOLID = 3 ;D3DSTENCILOP Const D3DSTENCILOP_KEEP = 1 Const D3DSTENCILOP_ZERO = 2 Const D3DSTENCILOP_REPLACE = 3 Const D3DSTENCILOP_INCRSAT = 4 Const D3DSTENCILOP_DECRSAT = 5 Const D3DSTENCILOP_INVERT = 6 Const D3DSTENCILOP_INCR = 7 Const D3DSTENCILOP_DECR = 8 Const D3DSTENCILCAPS_TWOSIDED = 9 ;D3DCMPFUNC Const D3DCMP_NEVER = 1 Const D3DCMP_LESS = 2 Const D3DCMP_EQUAL = 3 Const D3DCMP_LESSEQUAL = 4 Const D3DCMP_GREATER = 5 Const D3DCMP_NOTEQUAL = 6 Const D3DCMP_GREATEREQUAL = 7 Const D3DCMP_ALWAYS = 8 ;D3DBLEND Const D3DBLEND_ZERO = 1 Const D3DBLEND_ONE = 2 Const D3DBLEND_SRCCOLOR = 3 Const D3DBLEND_INVSRCCOLOR = 4 Const D3DBLEND_SRCALPHA = 5 Const D3DBLEND_INVSRCALPHA = 6 Const D3DBLEND_DESTALPHA = 7 Const D3DBLEND_INVDESTALPHA = 8 Const D3DBLEND_DESTCOLOR = 9 Const D3DBLEND_INVDESTCOLOR = 10 Const D3DBLEND_SRCALPHASAT = 11 Const D3DBLEND_BOTHSRCALPHA = 12 Const D3DBLEND_BOTHINVSRCALPHA = 13 ; D3DRENDERSTATES Const D3DRS_TEXTUREHANDLE = 1 Const D3DRS_ANTIALIAS = 2 ; D3DANTIALIASMODE Const D3DRS_TEXTUREADDRESS = 3 Const D3DRS_TEXTUREPERSPECTIVE = 4 ; True For perspective correction Const D3DRS_WRAPU = 5 Const D3DRS_WRAPV = 6 Const D3DRS_ZENABLE = 7 ; D3DZBUFFERTYPE (Or True/False For legacy) Const D3DRS_FILLMODE = 8 ; D3DFILL_MODE Const D3DRS_SHADEMODE = 9 ; D3DFILL_MODE Const D3DRS_LINEPATTERN = 10 ; D3DLINEPATTERN Const D3DRS_MONOENABLE = 11 Const D3DRS_ROP2 = 12 ;Const D3DRS_LINEPATTERN = 13 Const D3DRS_ZWRITEENABLE = 14 ; True To enable z writes Const D3DRS_ALPHATESTENABLE = 15 ; True To enable alpha tests Const D3DRS_LASTPIXEL = 16 ; True For Last-pixel on lines Const D3DRS_TEXTUREMAG = 17 ; D3D7 Const D3DRS_TEXTUREMIN = 18 ; D3D7 Const D3DRS_SRCBLEND = 19 ; D3DBLEND Const D3DRS_DESTBLEND = 20 ; D3DBLEND Const D3DRS_TEXTUREMAPBLEND = 21 ; D3D7 Const D3DRS_CULLMODE = 22 ; D3DCULL Const D3DRS_ZFUNC = 23 ; D3DCMPFUNC Const D3DRS_ALPHAREF = 24 ; D3DFIXED (long) Const D3DRS_ALPHAFUNC = 25 ; D3DCMPFUNC Const D3DRS_DITHERENABLE = 26 ; True To enable dithering Const D3DRS_ALPHABLENDENABLE = 27 ; True To enable alpha blending Const D3DRS_FOGENABLE = 28 ; True To enable fog blending Const D3DRS_SPECULARENABLE = 29 ; True To enable specular Const D3DRS_ZVISIBLE = 30 ; True To enable z checking Const D3DRS_SUBPIXEL = 31 ; D3D7 Const D3DRS_SUBPIXELX = 32 ; D3D7 Const D3DRS_STIPPLEDALPHA = 33 ; True To enable stippled alpha (RGB device only) Const D3DRS_FOGCOLOR = 34 ; D3DCOLOR Int ( (a shl 24) Or (r Shl 16) Or (g Shl 8) Or b ) Const D3DRS_FOGTABLEMODE = 35 ; D3DFOGMODE Const D3DRS_FOGSTART = 36 ; Float Fog start (For both vertex And pixel fog) Const D3DRS_FOGEND = 37 ; Float Fog End Const D3DRS_FOGDENSITY = 38 ; Fog Density Const D3DRS_STIPPLEENABLE = 39 ; Const D3DRS_EDGEANTIALIAS = 40 ; True To enable edge antialiasing Const D3DRS_COLORKEYENABLE = 41 ; True To enable source colorkeyed textures Const D3DRS_BORDERCOLOR = 43 ; D3D7 Const D3DRS_TEXTUREADDRESSU = 44 ; D3D7 Const D3DRS_TEXTUREADDRESSV = 45 ; D3D7 Const D3DRS_MIPMAPLODBIAS = 46 ; D3D7 Const D3DRS_ZBIAS = 47 ; Int Z bias (D3D7, D3D8) Const D3DRS_RANGEFOGENABLE = 48 ; Enables range-based fog Const D3DRS_ANISOTROPY = 49 Const D3DRS_FLUSHBATCH = 50 Const D3DRS_TRANSLUCENTSORTINDEPENDENT= 51 ; D3D7 ; *** STENCIL OPS *** Const D3DRS_STENCILENABLE = 52 ; BOOL enable/disable stenciling Const D3DRS_STENCILFAIL = 53 ; D3DSTENCILOP To do If stencil test fails Const D3DRS_STENCILZFAIL = 54 ; D3DSTENCILOP To do If stencil test passes And Z test fails Const D3DRS_STENCILPASS = 55 ; D3DSTENCILOP To do If both stencil And Z tests pass Const D3DRS_STENCILFUNC = 56 ; D3DCMPFUNC fn. Stencil Test passes If ((ref & mask) stencilfn (stencil & mask)) is True Const D3DRS_STENCILREF = 57 ; INT Reference value used in stencil test Const D3DRS_STENCILMASK = 58 ; Mask value used in stencil test e.g (= $ffffffff) Const D3DRS_STENCILWRITEMASK = 59 ; Write mask applied To values written To stencil buffer e.g (= $ffffffff) Const D3DRS_TEXTUREFACTOR = 60 ; D3DCOLOR used For multi-texture blend Const D3DRS_WRAP7 = 135 Const D3DRS_CLIPPING = 136 Const D3DRS_LIGHTING = 137 Const D3DRS_EXTENTS = 138 ; D3D7 Const D3DRS_AMBIENT = 139 Const D3DRS_FOGVERTEXMODE = 140 Const D3DRS_COLORVERTEX = 141 Const D3DRS_LOCALVIEWER = 142 Const D3DRS_NORMALIZENORMALS = 143 Const D3DRS_COLORKEYBLENDENABLE= 144 ; D3D7 Const D3DRS_DIFFUSEMATERIALSOURCE=145 Const D3DRS_SPECULARMATERIALSOURCE=146 Const D3DRS_AMBIENTMATERIALSOURCE= 147 Const D3DRS_EMISSIVEMATERIALSOURCE=148 Const D3DRS_VERTEXBLEND = 151 Const D3DRS_CLIPPLANEENABLE = 152 Const D3DRS_SOFTWAREVERTEXPROCESSING=153 ; D3D8 Const D3DRS_POINTSIZE = 154 Const D3DRS_POINTSIZE_MIN = 155 Const D3DRS_POINTSPRITEENABLE = 156 Const D3DRS_MULTISAMPLEANTIALIAS=161 Const D3DRS_MULTISAMPLEMASK = 162 Const D3DRS_PATCHEDGESTYLE = 163 Const D3DRS_PATCHSEGMENTS = 164 ; D3D8 Const D3DRS_DEBUGMONITORTOKEN = 165 Const D3DRS_POINTSIZE_MAX = 166 Const D3DRS_INDEXEDVERTEXBLENDENABLE = 167 Const D3DCLEAR_TARGET = $00000001 ;Clear target surface Const D3DCLEAR_ZBUFFER = $00000002 ;Clear target z buffer Const D3DCLEAR_STENCIL = $00000004 ;Clear Stencil Const D3DCLEAR_ALL = $00000007 Type RenderState ; BB Defaults Field ZEnable ; True Field AlphaTestEnable ; False Field SrcBlend ; 5 = D3DBLEND_SRCALPHA Field DestBlend ; 6 = D3DBLEND_INVSRCALPHA Field CullMode ; 3 = D3DCULL_CCW Field ZFunc ; 4 = D3DCMP_LESSEQUAL Field AlphaRef ; 128 Field AlphaFunc ; 5 = D3DCMP_GREATER Field AlphaBlendEnable ; False Field ZBias ; 0 Field StencilEnable ; False Field StencilFail ; 1 = D3DSTENCILOP_KEEP Field StencilZFail ; 1 = D3DSTENCILOP_KEEP Field StencilPass ; 1 = D3DSTENCILOP_KEEP Field StencilFunc ; 8 = D3DCMP_ALWAYS Field StencilRef ; 0 Field StencilMask ; -1 Field StencilWriteMask ; -1 End Type Function D3D_Init() Direct3D7=SystemProperty$("Direct3D7") Direct3DDevice7=SystemProperty$("Direct3DDevice7") DirectDraw7=SystemProperty$("DirectDraw7") AppHWND=SystemProperty$("AppHWND") AppHINSTANCE=SystemProperty$("AppHINSTANCE") If Direct3D7=0 RuntimeError "FATAL ERROR: Can't get access to Drect3DDevice!" DX7_SetSystemProperties (Direct3D7,Direct3DDevice7,DirectDraw7,AppHWND,AppHINSTANCE) End Function ; Use this after a D3D_Init to keep the original RenderState Function StoreRenderState(r.RenderState) r\ZEnable = DX7_GetRenderState( D3DRS_ZENABLE) r\AlphaTestEnable = DX7_GetRenderState( D3DRS_ALPHATESTENABLE) r\SrcBlend = DX7_GetRenderState( D3DRS_SRCBLEND) r\DestBlend = DX7_GetRenderState( D3DRS_DESTBLEND) r\CullMode = DX7_GetRenderState( D3DRS_CULLMODE) r\ZFunc = DX7_GetRenderState( D3DRS_ZFUNC) r\AlphaRef = DX7_GetRenderState( D3DRS_ALPHAREF) r\AlphaFunc = DX7_GetRenderState( D3DRS_ALPHAFUNC) r\AlphaBlendEnable = DX7_GetRenderState( D3DRS_ALPHABLENDENABLE) r\ZBias = DX7_GetRenderState( D3DRS_ZBIAS) r\StencilEnable = DX7_GetRenderState( D3DRS_STENCILENABLE) r\StencilFail = DX7_GetRenderState( D3DRS_STENCILFAIL) r\StencilZFail = DX7_GetRenderState( D3DRS_STENCILZFAIL) r\StencilPass = DX7_GetRenderState( D3DRS_STENCILPASS) r\StencilFunc = DX7_GetRenderState( D3DRS_STENCILFUNC) r\StencilRef = DX7_GetRenderState( D3DRS_STENCILREF) r\StencilMask = DX7_GetRenderState( D3DRS_STENCILMASK) r\StencilWriteMask = DX7_GetRenderState( D3DRS_STENCILWRITEMASK) End Function ; Use this for every screen refresh, to bring the RenderState back to original values Function RestoreRenderState(r.RenderState) DX7_SetRenderState(D3DRS_ZENABLE, r\ZEnable) DX7_SetRenderState(D3DRS_ALPHATESTENABLE, r\AlphaTestEnable) DX7_SetRenderState(D3DRS_SRCBLEND, r\SrcBlend) DX7_SetRenderState(D3DRS_DESTBLEND, r\DestBlend) DX7_SetRenderState(D3DRS_CULLMODE, r\CullMode) DX7_SetRenderState(D3DRS_ZFUNC, r\ZFunc) DX7_SetRenderState(D3DRS_ALPHAREF, r\AlphaRef) DX7_SetRenderState(D3DRS_ALPHAFUNC, r\AlphaFunc) DX7_SetRenderState(D3DRS_ALPHABLENDENABLE, r\AlphablendEnable) DX7_SetRenderState(D3DRS_ZBIAS, r\ZBias) DX7_SetRenderState(D3DRS_STENCILENABLE, r\StencilEnable) DX7_SetRenderState(D3DRS_STENCILFAIL, r\StencilFail) DX7_SetRenderState(D3DRS_STENCILZFAIL, r\StencilZFail) DX7_SetRenderState(D3DRS_STENCILPASS, r\StencilPass) DX7_SetRenderState(D3DRS_STENCILFUNC, r\StencilFunc) DX7_SetRenderState(D3DRS_STENCILREF, r\StencilRef) DX7_SetRenderState(D3DRS_STENCILMASK, r\StencilMask) DX7_SetRenderState(D3DRS_STENCILWRITEMASK, r\StencilWriteMask) End Function
Include "AShadowBBinclude/Ashadow.bb" Graphics3D 800,600,16,2 SetBuffer BackBuffer() cam=CreateCamera() Ref_Glow_DarkPower=5 Ref_Glow_BlurPower=3 Ref_BlSprAlpha#=.22 CreateGlow cam, 180, 135 ,.4,.8 Ref_Glow_ON=0 CreateBlur cam,.0 CreateDOF ( cam, 4, 15, 1, 3, 0.35) Ref_DOF=0 Pivottest = CreatePivot() Spritetest = CreateSprite(Pivottest) ; ACreateSprite(Pivottest) PositionEntity Pivottest,0,0,10 Pivottest2 = CreatePivot() Spritetest2 = CreateSprite(Pivottest2) EntityColor Spritetest2,255,0,0 PositionEntity Pivottest2,-1,0,15 Pivottest3 = CreatePivot() Spritetest3 = CreateSprite(Pivottest3) EntityColor Spritetest3,0,255,0 PositionEntity Pivottest3,-2,0,17 While Not KeyHit(1) KeyControl(cam,.01) mouselook(cam) If KeyHit(29) Ref_Glow_ON=1-Ref_Glow_ON If KeyHit(33) Ref_DOF = 1 - Ref_DOF RenderWorld() PostProcess_Render cam RenderEntity( Pivottest, cam) Text 5,105,"Press ''Ctrl'' for Glow-effect: "+Ref_Glow_ON Text 5,125,"Press ''F'' for DOF: "+Ref_DOF Flip Wend End Function mouselook(ent) mxspd#=MouseXSpeed()*0.25 myspd#=MouseYSpeed()*0.25 MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 campitch#=EntityPitch(ent)+myspd# If campitch#<-85 Then campitch#=-85 If campitch#>85 Then campitch#=85 RotateEntity ent,campitch#,EntityYaw(ent)-mxspd#,EntityRoll(ent) End Function Function KeyControl(ent,mov#=1) If KeyDown(200) MoveEntity ent,0,0,mov If KeyDown(208) MoveEntity ent,0,0,-mov If KeyDown(205) MoveEntity ent,mov,0,0 If KeyDown(203) MoveEntity ent,-mov,0,0 If KeyDown(17) MoveEntity ent,0,0,mov If KeyDown(31) MoveEntity ent,0,0,-mov If KeyDown(32) MoveEntity ent,mov,0,0 If KeyDown(30) MoveEntity ent,-mov,0,0 If MouseDown(1) MoveEntity ent,0,0,mov If MouseDown(2) MoveEntity ent,0,0,-mov End Function
Include "AShadowBBinclude/Ashadow.bb" Graphics3D 1024,768,32,2 ;loadstuff blah blah Camera=CreateCamera() Ref_Glow_DarkPower=5 Ref_Glow_BlurPower=3 Ref_BlSprAlpha#=.22 CreateGlow Camera, 180, 135 ,.4,.8 Ref_Glow_ON=0 CreateBlur Camera,.0 CreateDOF ( Camera, 4, 15, 1, 3, 0.35) Ref_DOF=0 ;load one sprite and same rule apply to parent ;lo=LoadTexture("wall_00.jpg",2) Global logo=CreateSprite(Camera) ;EntityTexture logo,lo MoveEntity Logo,7,-5.5,8 PositionEntity logo,0,0,4,False EntityOrder Logo,-1 ;main loop While Not KeyDown(1) ;your game loop stuff here blah blah If KeyHit(29) Ref_Glow_ON=1-Ref_Glow_ON ;L CTRL If KeyHit(33) Ref_DOF = 1 - Ref_DOF ;F UpdateWorld RenderWorld ;Ashadow stuff here AUpdateWater (Camera) UpdateRefract Camera PostProcess_Render Camera ;and now postprocessing stuff you want to be rendered over everything RenderEntity (Logo,Camera,0,0) Text 10,10,Ref_Glow_ON Text 10,20,Ref_DOF Flip False Wend End