PB 6.00 - Exemples 3D - Environment mapping

Généralités sur la programmation 3D
Avatar de l’utilisateur
Guillot
Messages : 529
Inscription : jeu. 25/juin/2015 16:18

PB 6.00 - Exemples 3D - Environment mapping

Message par Guillot »

les exemples 3D relatifs aux nouvelles fonctions de la 6.00 n'ayant pas été integrées, je vous en donne quelques uns

les parametres de CreateCubeMapTexture ont changé avec la v6.00
le parametre "hauteur" est remplacer par le parametre option pouvant prendre la valeur:
- #PB_Texture_AutomaticUpdate : La texture est mise à jour automatiquement à chaque RenderWorld()
- #PB_Texture_ManualUpdate : La texture n'est pas mise à jour automatiquement, UpdateRenderTexture() doit être appelé manuellement
(note : la hauteur est égale à la largeur)

Code : Tout sélectionner

; ----------------------------------------------------------------------------------------------------------
;   Environment mapping
; ----------------------------------------------------------------------------------------------------------
#PB_Material_CubicEnvBumpShader=$10009

Define.f a,da,r,MouseX,Mousey,depx,depz,dist

InitEngine3D():InitSprite():InitKeyboard():InitMouse()

ExamineDesktops()
OpenWindow(0, 0,0, DesktopWidth(0)*0.8,DesktopHeight(0)*0.8, "Environment mapping - [Esc] quit",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)

Add3DArchive(#PB_Compiler_Home + "examples\3D\Data\Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples\3D\Data\Textures\nvidia", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples\3D\Data\Packs\desert.zip", #PB_3DArchive_Zip)
Add3DArchive(GetCurrentDirectory(), #PB_3DArchive_FileSystem )
Parse3DScripts()

SkyBox("desert07.jpg")

CreateCamera(0, 0, 0, 100, 100):MoveCamera(0,0,2,0):CameraLookAt(0,0,0,10)
CreateLight(0, $ffffff, 8000, 5700,4500);  ;light on the sun of the skybox !
AmbientColor($444444)

; Ground
LoadTexture(0, "MRAMOR6X6.jpg")
CreateMaterial(0,TextureID(0))
CreatePlane(0,256,256,1,1,32,32)
CreateEntity(0,MeshID(0),MaterialID(0))

; objects
CreateSphere(0,1.5,32,32)
CreateCapsule(1,1,1.5)
CreateCylinder(2,1.5,2,32,1,1)
CreateTorus(3,1.5,0.6,32,32)
CreateCube(4,2.5)

tx_rock_diff=LoadTexture(-1,"dirt_grayrocky_diffusespecular.jpg")
tx_rock_normal=LoadTexture(-1,"dirt_grayrocky_normalheight.jpg")

Dim tx_Cubic(50)

For j=0 To 6
	For i=0 To 6
		c+1
		CreateShaderMaterial(c,#PB_Material_CubicEnvBumpShader)
		tx_Cubic(c) = CreateCubeMapTexture(#PB_Any, 512,#PB_Texture_ManualUpdate, "")
		MaterialShaderTexture(c,TextureID(tx_Cubic(c)),TextureID(tx_rock_diff),TextureID(tx_rock_normal),0)
		SetMaterialAttribute(c,#PB_Material_TAM,#PB_Material_ClampTAM,0)
		SetMaterialColor(c,3,RGBA(127*Random(2),127*Random(2),127*Random(2),0))
		MaterialShaderParameter(c,1,"bumpy",1,  Random(1,0)*0.2,0,0,0)
		MaterialShaderParameter(c,1,"glossy",1, Random(2,1)*0.2,0,0,0)
		CreateEntity(c,MeshID(c%5),MaterialID(c), (i-3)*8,2,(j-3)*8)
		RotateEntity(c,Random(360),Random(360),Random(360),#PB_Absolute)
		EntityCubeMapTexture(tx_Cubic(c), c)  ; <- associate the entity to position the cubic texture
	Next
Next

; get the cubic texture (2 pass for better result)
For j=0 To 1
	For i=1 To c
		UpdateRenderTexture(tx_Cubic(i))
	Next
Next

; apply the ground reflection
CreateCamera(1,0,0,100,100)
CreateRenderTexture(1,CameraID(1),ScreenWidth()/1,ScreenHeight()/1)
AddMaterialLayer(0,TextureID(1),#PB_Material_ModulateX2)
SetMaterialAttribute(0,#PB_Material_ProjectiveTexturing,1,1)

Repeat
	While WindowEvent():Wend
	ExamineKeyboard()
	ExamineMouse()
	depx=(-Bool(KeyboardPushed(#PB_Key_Left))+Bool(KeyboardPushed(#PB_Key_Right)))*0.1
	depz=(-Bool(KeyboardPushed(#PB_Key_Down))+Bool(KeyboardPushed(#PB_Key_Up   )))*0.1+MouseWheel()*2
	MouseX = -MouseDeltaX() *  0.05
	MouseY = -MouseDeltaY() *  0.05
	RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
	dist+(depz-dist)*0.05:MoveCamera  (0, depX, 0, -dist)
	CameraReflection(1,0,EntityID(0))
	RenderWorld()
	FlipBuffers()    
Until KeyboardReleased(#PB_Key_Escape) Or MouseButton(3)
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par falsam »

Bonjour Guillot. Merci pour tous ces exemples mais comme tu peux le voir, le résultat pique les yeux.

■ Environnement de test
Windows 11 Famille 64-bit
PB 6.0 x64
AMD Ryzen 7
NVIDIA GeForce GTX 1650 Ti

Image

Est ce bien le résultat attendu ?
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
Guillot
Messages : 529
Inscription : jeu. 25/juin/2015 16:18

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par Guillot »

non, pas vraiment...
merde, encore une couille dans le potage

et les 3 autres exemples "PB 6.00 - Exemples 3D - Shaders" ont l'air correct pour toi ?
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par falsam »

Guillot a écrit : et les 3 autres exemples "PB 6.00 - Exemples 3D - Shaders" ont l'air correct pour toi ?
Meme genre de souci d'affichage.
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par falsam »

Ca serait bien que d'autres utilisateurs testent le code de Guillot s'il vous plait. Merci :wink:
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
Ar-S
Messages : 9477
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par Ar-S »

Resultat pas top non : Image
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
Guillot
Messages : 529
Inscription : jeu. 25/juin/2015 16:18

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par Guillot »

ben mince,

quelqu'un peut me fournir les log ?
( InitEngine3D(#PB_Engine3D_DebugLog) )
G-Rom
Messages : 3627
Inscription : dim. 10/janv./2010 5:29

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par G-Rom »

Lu Guillot , au passage, bon boulot ;)
09:29:05: Can't assign material Capsule to SubEntity of E1 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E2 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E3 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E4 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E5 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E6 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E7 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E8 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E9 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E10 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E11 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E12 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E13 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E14 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E15 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E16 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E17 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E18 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E19 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E20 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E21 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E22 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E23 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E24 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E25 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E26 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E27 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E28 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E29 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E30 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E31 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E32 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E33 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E34 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E35 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E36 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E37 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E38 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E39 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E40 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E41 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E42 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E43 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E44 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Sphere to SubEntity of E45 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Capsule to SubEntity of E46 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material cylinder to SubEntity of E47 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Torus to SubEntity of E48 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: Can't assign material Cube to SubEntity of E49 because this Material does not exist. Have you forgotten to define it in a .material script?
09:29:05: GLSL compiled: 0(4) : warning C7555: 'attribute' is deprecated, use 'in/out' instead
0(13) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(14) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(15) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(16) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(17) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(18) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(19) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(23) : warning C7533: global variable gl_Vertex is deprecated after version 120
0(26) : warning C7533: global function ftransform is deprecated after version 120
0(27) : warning C7533: global variable gl_Normal is deprecated after version 120
0(29) : warning C7533: global variable gl_TextureMatrix is deprecated after version 120
0(29) : warning C7533: global variable gl_MultiTexCoord0 is deprecated after version 120
0(30) : warning C7533: global variable gl_Color is deprecated after version 120

09:29:05: GLSL compiled: 0(14) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(15) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(16) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(17) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(18) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(19) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(20) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(40) : warning C7533: global variable gl_FragColor is deprecated after version 120
Avatar de l’utilisateur
Guillot
Messages : 529
Inscription : jeu. 25/juin/2015 16:18

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par Guillot »

salut Grom,

est ce que tu peux me dire si pour toi l'affichage à l'air correcte
est ce que tu peux aussi tester les les 3 démos :
PB 6.00 - Exemples 3D - Shaders viewtopic.php?t=18709&sid=caf4322650cf1 ... abe8dfe29a
et me dire si c'est ok pour toi (pas besoin des log si c'est le cas)
G-Rom
Messages : 3627
Inscription : dim. 10/janv./2010 5:29

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par G-Rom »

ca à l'air de fonctionner, je vois sur le torus ( des 2 démos ) un morceau de texture blanche
Avatar de l’utilisateur
SPH
Messages : 4726
Inscription : mer. 09/nov./2005 9:53

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par SPH »

Image

All is OK here !

ps: pb6 64bits sur un ordi portable de 10 ans d'age...
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Avatar de l’utilisateur
Guillot
Messages : 529
Inscription : jeu. 25/juin/2015 16:18

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par Guillot »

c'est chipset intel ?
Avatar de l’utilisateur
SPH
Messages : 4726
Inscription : mer. 09/nov./2005 9:53

Re: PB 6.00 - Exemples 3D - Environment mapping

Message par SPH »

Moi ? 8)

AMD A4
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Répondre