Ways to set Shader Parameters

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Ways to set Shader Parameters

Post by Vectrotek »

High Level vs Low Level GPU programming and how parameters are set.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

I have a question about this in the next few posts..

Code: Select all

 
 // THE MANUAL SAYS THIS:
 // = = = = = = = = = n= = = = = = = = = 
 virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
  {
   video::IVideoDriver* driver = services->getVideoDriver();
   
   // Set clip matrix at register 4   "WHAT EXACTLY DOES THIS MEAN?"  "HOW DO I SET IT?"
 
   core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
   worldViewProj *= driver->getTransform(video::ETS_VIEW);
   worldViewProj *= driver->getTransform(video::ETS_WORLD);
 
 
   // I can gather 4 is because 1 Reg is 4 floats..
   // THIS IS NOT ALLOWED ! ! !  (trying to access a private member)??
   services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4);
   // For high level shading languages, this would be ANOTHER solution:
   // services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16);
   // Set some light color at register 9.. AGAIN.. HOW DO I SET THIS ? ? 
   video::SColorf col(0.0f,1.0f,1.0f,0.0f);
   services->setVertexShaderConstant(reinterpret_cast<const f32*>(&col), 9, 1);
   // for high level shading languages, this would be another solution:
   //services->setVertexShaderConstant("myColor", reinterpret_cast<f32*>(&col), 4);
  }
 // = = = = = = = = = = = = = = = = = =   
 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Code: Select all

 
 
 // THEN, WHY DOES THIS WORK:
 TheMATRENDServices->setVertexShaderConstant("M05WorldViewProjection",
                                             M05WorldViewProjection.pointer(),
                                             16);
 // BUT THIS DOES NOT WORK:
 TheMATRENDServices->setVertexShaderConstant(M05WorldViewProjection.pointer(),
                                             1,    // Seems to START at 1 ..
                                             4);   // As 16 floats = 4 registers ..
 // THIS ALSO DOES NOT WORK:
 TheMATRENDServices->setVertexShaderConstant(M05WorldViewProjection.pointer(),
                                             4,    // Maybe starts at 4 (huh?)..
                                             4);   // As 16 floats = 4 registers ..
 // NEITHER DOES THIS WORK:
 TheMATRENDServices->setVertexShaderConstant(M05WorldViewProjection.pointer(),
                                             0,    // Maube starts at 0 ..
                                             4);   // As 16 floats = 4 registers ..
 // I EVEN TRIED THIS:
 TheMATRENDServices->setVertexShaderConstant(M05WorldViewProjection.pointer(),
                                             0,    // Seems to START at 1 but I tried 0..
                                             16);  // I know, but you never know.. :)~
 
 // "random_anonymouse" pasted code with this line that he says works ??
 services->setVertexShaderConstant(worldViewProj.pointer(), 4, 4);
 
 
 
Last edited by Vectrotek on Mon Nov 14, 2016 8:46 am, edited 1 time in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Code: Select all

 
 // Console spits out:
 Irrlicht Engine version 1.8.4
 Cannot set constant, please use high level shader call instead.
 Cannot set constant, please use high level shader call instead.
 Cannot set constant, please use high level shader call instead.
 Cannot set constant, please use high level shader call instead.
 ad infinitum...
   
 // YES I KNOW, BUT IS DOING IT BY REGISTER INDEX NOT MUCH FASTER?
   
 // Also Irrlicht DOES NOT ALLOW THIS: (I think)
 // Compiler says I can't access private member.
 services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4); 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Code: Select all

 
 // HERE IS THE SHADER CODE..
  
 #version 120
 
 uniform mat4   M05WorldViewProjection;        // REGISTER 0  (4 floats per register)
 uniform mat4   M27WorldReflectedProjection;   // My math tells me this one would then be REGISTER 4 ????
 uniform float  WaveLength;
 uniform float  Time;
 uniform float  WindForce;
 uniform vec2   WindDirection;
 // Vertex shader output..
 varying vec2 bumpMapTexCoord;
 varying vec2 bumpMapTexCoord02;
 varying vec3 refractionMapTexCoord;
 varying vec3 reflectionMapTexCoord;
 varying vec3 position3D;
 
 //----------------- --- -- - 
 void main()
  {
   vec4 pos = M05WorldViewProjection * gl_Vertex;
   gl_Position = pos;
   // ETC ETC ETC ETC....
  }
   
 // I really hope that to be able to access by index I don't HAVE TO write GPU assembly!!
 // Maybe the GPU Program compiler fixes it so that it IS NOT a time penalty to do it by name!!
 // If so, then how does it handle setting a parameter by name EVERY FRAME?
 // I'm sure that setting by Register Index would be faster for both Machine Code and High level code..
 
 // Any opinion?
 
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Ways to set Shader Parameters

Post by Mel »

As far as I remember, matrices have a "pointer" method, maybe that would work? M is a private member of the matrices, thus it is not possible to access it. BUT nobody says you can't access using math pointers (pointer()+4 is the starting point of the second row of the matrix and so on), As long as the memory is yours, whether static or dynamic, accessing a memory address which belongs to the process is admitted.

Also, High Level compiled shaders require you to access using high level access functions, there are methods to obtain the register index which map properly to variable names, as the register mapping of a high level compiled shader doesn't necesarily map to the order of the uniforms definition. That is left to the video card driver implementation, Say that, for instance, this ordering is diferent in Windows than in Linux, so you can't really assure that "uniform mat4 M05WorldViewProjection;" will be mapped to register 0, unless explicitly specified (if it is possible). Same goes to the other uniform variables, as in most cases they're ordered from larger size to shorter size, and they're mapped register aligned, so floats will fill a complete register, wasting precious register space.

And you don't have to send shader constants by name at all, eventhough the "oficial release" i think that still doesn't implement that, in the SVN version, you may query the register IDs that correspond to variable names and set shader constants by register ID, not by variable name anymore, speeding up this process even for high level shaders a lot. If you're using the SVN version, take a look at the Tutorial 10 about shaders
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Thanks! I suspected something along those lines..
Anyhow, every time I want to go SVN etc or do something serious I get sidelined by a new
idea for cool shader effect.. This time it is Pseudo Sub Surface Scattering..
Thanks again Mel!
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Ways to set Shader Parameters

Post by Mel »

Curse your curiosity XD You need to learn to focus on the task at hand ;) But without curiosity, we wouldn't be anywhere :P
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Hehe.. Well.. I've got this project going that renders to and from buffers in a non linear way..
It creates buffers for things like Depth, Normals, etc..
What makes it cool is that you have "absolute" control over your "inter buffer rendering"..
You could for example render a scene by first rendering "RGB encoded Depth" to a specified buffer.
You could then render that same scene, but only its normals, to another buffer..
You "associate" a "Shader for Screen Quad Material" to every "Inter buffer" pass..
These passes are all defined by associating shaders, associating Targets and associating Sources (buffers that is).
Now using these different rendered forms of your objects you can do things like Deferred Rendering, SSAO and much more..

Now, there are Three main types of passes:
1. "Geometry Render Passes" (must have only Target buffers assigned)..
2. "Inter Buffer Render Passes" (must have one or more Source Buffers assigned and must have only One Target Buffer assigned)..
3. "Final Render to Frame Buffer Passes" (must have only Source Buffers assigned)..

Internally the "Pass Type" is automatically determined by how you have assigned Sources and Targets using the following logics..
Logically, if a Pass was given ONLY A TARGET, then obviously it can only be a "Geometry Render Pass" (think about it, it does not have a source from a screen quad)
Logically, if a Pass was given SOURCES AND A TARGET, then obviously it can only be an "Inter Buffer Pass" (see, it gets a source or sources from Screen Quad Renders)
Logically, If a Pass was given ONLY SOURCES, then obviously it can only be a "Final Render To Frame Pass" (no screen quad "imaged materials" to render to, so render to the screen frame)

This set of rules thankfully covered that part of it..

More explanation of Passes:
"Geometry Passes"
Renders 3D Geometric Objects with Geometry Shaders like "Render only the Depth" or "Render Only its Range Compressed Normals"..
With these you can render the same object to many different buffers using many different Geo-shaders ..
Now you have a few buffers each containing a different mode image of the same object..
With Geometry passes you can even "Exclude" certain items like the clouds polygons and the lens flares..
This becomes use full if you've rendered the "Silhouette" of a scene to a buffer using "a Black on White Masking shader" sothat
you can "bloom blur" the image in that "buffer" to later mix it with another buffer..

"Inter Buffer Passes"
Render the result of one Screen Quad Render (now in a buffer) using a material shader (like a mixing shader)(not geometry shader) into another buffer..
There can be LOST AND LOTS of Inter Buffer Passes that will evenutally work their way into a Final Mixing Buffer that takes us to the last type of Pass.

"Final Render to Frame Pass"
This renders (traditionally only one) Buffer to the Screen.
All your work with the "Inter Buffer Passes" find its way into the final mage that you see..

This concept could be quite powerful if one can get the speed needed hence "Shader Parameters by Index"..
My machine is very slow so perhaps someone else can get more inspiring results once I upload the project (soon)..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Once I upload the project you'd probably have wanted to loot at this first..

First I create my buffers..

Code: Select all

 
 #ifndef NON_LINEAR_EFFECT_SYSTEM_INI_INC_INCD
 #define NON_LINEAR_EFFECT_SYSTEM_INI_INC_INCD
 
 #include "H_000_main_include.h"
 
 u32 GeneralPPX =  640 ;
 u32 GeneralPPY =  480 ;
 
 // With cleverly scaled "re-blur" we can get away with very small buffers..
 u32 BlurBuffX =  320 ; // 320
 u32 BlurBuffY =  240 ; // 240
 
 void InitiateNonLinearEffectSystem ()
  {
   // ADVANCED NON LINEAR MULTIPASS EFFECTS POST PROCESSOR..
   MyCoolEffect.SetDevice(TheDevice); // This function called twice for the sake of Smart Shader independence..
   MyCoolEffect.SetBackGroundColour (SColor( 255 , 0 , 0 , 255 ));
   MyCoolEffect.AccessThePPShaderCollection()->SetDevice(TheDevice);  // ABSOLUTELY NECESSARY..
   MyCoolEffect.AccessThePPShaderCollection()->SetGlobalDriverType (SelectedDriverType); // ABSOLUTELY NECESSARY..
 
   if (SelectedDriverType == video::EDT_OPENGL) // REMEMBER TO DO HLSL COUNTERPART (should be the same)..
    {     
     // Add Inter - Effect Buffers..(should not be driver type specific)..
     // WE ACTULLY HAVE ENOUGH BUFFERS TO SWAP AN INTERCHANGE BETWEEN THEM..
     // THESE JUST HELPS US KEEP OUR HEADS.. 
     // WE SHOULD CALL THEM "INTERCHANGEABLEBUFFERA to D", or something.. (very few are actually needed)..
     // BUT.. WHERE BUFFER SIZES DIFFER WELL NEED THEM SEPARATE..
 
    #define BUF_SCENE_RENDER                        0  // The scene is rendered to this buffer by our very first "Sourceless" Pass.. (see note below about more sourceless passes)..
    #define BUF_FRONT_F_DEPTH_RGB_ENCODED_RENDER    1  // Domain Maximised Depth Image.. (nonsensical stripes decode into a reasonabe domain depth)..
    #define BUF_BACK_F_DEPTH_RGB_ENCODED_RENDER     2  // Domain Maximised Depth Image.. (nonsensical stripes decode into a reasonabe domain depth)..
    #define BUF_RC_NML_AND_8_BIT_DEPTH_RENDER       3 // NON Domain Maximised Depth Image.. (grey 256 bit)..
    #define BUF_PRESERVED_FXAA_IMAGE                4
    #define BUF_EMISSION_ONLY                       5  // Kept around for when we have a "Global Alert" causing renering if emission mapping only..
    #define BUF_PRE_BLUR_CURVED                     6
    #define BUF_BLUR_ALTER_A                        7  // Called "Alternating Buffers" because a low res blurred image
    #define BUF_BLUR_ALTER_B                        8  // allows for high quality "Re-blurring" with minimal GPU time penalty..
    #define BUF_FINAL_BLOOMED                       9  // Rendered to the FRAME BUFFER by our ONE AND ONLY "TARGETLESS" Pass..
    #define BUF_GENERIC_ALTERNTOR_A                10
    #define BUF_GENERIC_ALTERNTOR_B                11
    #define BUF_GENERIC_ALTERNTOR_C                12
    #define BUF_GENERIC_ALTERNTOR_D                13
    #define BUF_GENERIC_ALTERNTOR_E                14
    #define BUF_GENERIC_ALTERNTOR_F                15
    #define BUF_CLIPPED_BLACK_ON_WHITE_MASK        16
    #define BUF_CLIPPED_WHITE_ON_BLACK_MASK        17
    #define BUF_CLIPPED_BLACK_ON_BLACK_MASK        18
    #define BUF_BYPASS_IMAGE_TV_TEST               19
    #define BUF_BYPASS_IMAGE_DOT_SCREEN            20
    #define BUF_BYPASS_NORMAL_MAP_SITORT           21
    #define BUF_POS_RGB                            22
    #define BUF_BYPASS_RANDOMIZER                  23
    #define BUF_NORMALS_WORLD                      24
    #define BUF_NORMALS_VIEW                       25
    #define BUF_TEST_DEFERRED_SHADING              26
    #define BUF_TEST_DEFERRED_RENDERING            27
    #define BUF_SMALL_FOR_AO_OVERLAY               28
    #define BUF_THICKNESS                          29
    #define BUF_RANGE_COMPRESSED_WORLD_SPACE_POSITION   30
    #define BUF_NORMAL_NOISE                            31
    #define BUF_SCREEN_SPACE_REFLECTION                 32
    #define BUF_BOKEH_2_3_RESULT                        33
    #define BUF_BOKEH_2_4_RESULT                        34
    #define BUF_MASKED_BLUR                             35
 
    // These Buffers are referred to by "Associating" them to Renderpasses..
    // Clever use in ALTERNATING BUFFERS could result in much less buffers! (you'll figure it out)
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_SCENE_RENDER          is "A L L W A Y S" the Target for Original render OR the result of the previous Effect.. (need control over this)
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_FRONT_F_DEPTH_RGB_ENCODED_RENDER
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_BACK_F_DEPTH_RGB_ENCODED_RENDER
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_RC_NML_AND_8_BIT_DEPTH_RENDER
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_PRESERVED_FXAA_IMAGE  is PRESERVED because it is USED TWICE.. Used for 'Pre-Blurring' and used for 'Final Mixing'..
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_EMISSION_ONLY         not used now, it is the render altered by the EMISSION ONLY Alert Pointer??) (advanced stuff coming soon)
    MyCoolEffect.AddPFXBuffer( BlurBuffX , BlurBuffY );    // BUF_PRE_BLUR_CURVED       similar to above is the result of "treating" the scene render with contrast before blurring (bloom thing)..
    MyCoolEffect.AddPFXBuffer( BlurBuffX , BlurBuffY );    // BUF_BLUR_ALTER_A          is the H Blurred Contrasted Render in the Buffer above.. (see how SMALL these buffer could be)
    MyCoolEffect.AddPFXBuffer( BlurBuffX , BlurBuffY );    // BUF_BLUR_ALTER_B          is the Final Blurred Emission or Contrasted/Intensity-Curved Image.. THESE ARE 'RE-BLURRED' TWICE (cause thy're small)..
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_FINAL_BLOOMED         is is MIXTURE of ORIGINAL RENDER and FINAL BLURRED EMISSION Image ready to be rendered to FRAME BUFFER...
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_GENERIC_ALTERNTOR_A   AS you get better with this you'll want to use these more..
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_GENERIC_ALTERNTOR_B
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_GENERIC_ALTERNTOR_C   AS you get better with this you'll want to use these more..
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_GENERIC_ALTERNTOR_D
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_GENERIC_ALTERNTOR_E
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_GENERIC_ALTERNTOR_F
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_CLIPPED_BLACK_ON_WHITE_MASK
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_CLIPPED_WHITE_ON_BLACK_MASK
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_CLIPPED_BLACK_ON_BLACK_MASK
    // And a special ones that are "prefilled" with a given image..
    // Offcourse Buffer Size comes into play here where BuffSize Shaders are concerned..
    // This function may have a different name but internally everything happens the same like updating
    // The buffer count etc.. Sizeing is done automatically by the loading function..
    MyCoolEffect.AddPFXBufferAsLoadedImage("Data/0005_PP_UTILIY_IMAGES/PNG_001_TEST_SIGNAL.png");   // BUF_BYPASS_IMAGE_TV_TEST     Logics of this system allows us to add a buffer to Passes that are not
    MyCoolEffect.AddPFXBufferAsLoadedImage("Data/0005_PP_UTILIY_IMAGES/PNG_003_DOTSPARSE.png");     // BUF_BYPASS_IMAGE_DOT_SCREEN  Result of a P/P Shaded Render but rather a LOADED IMAGE!! (very cool)
    MyCoolEffect.AddPFXBufferAsLoadedImage("Data/0005_PP_UTILIY_IMAGES/PNG_018_FACE_NORMALS.png"); // BUF_BYPASS_NORMAL_MAP_SITORT RGB Normal Map used for Image Distortion..
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_POS_RGB
    MyCoolEffect.AddPFXBufferAsLoadedImage("Data/0007_SSAO_RANDOMIZER/DEFERRED_RADOMIZER.png"); // BUF_BYPASS_RANDOMIZER RGB Normal Map used for Image Distortion..
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_NORMALS_WORLD
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_NORMALS_VIEW
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_TEST_DEFERRED_SHADING
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );  // BUF_TEST_DEFERRED_RENDERING
    MyCoolEffect.AddPFXBuffer( BlurBuffX , BlurBuffY );    // BUF_SMALL_FOR_AO_OVERLAY   
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );    // BUF_THICKNESS   
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );    // BUF_RANGE_COMPRESSED_WORLD_SPACE_POSITION   
    MyCoolEffect.AddPFXBufferAsLoadedImage("Data/0005_PP_UTILIY_IMAGES/TGA_001_NORMAL_NOISE.tga"); // BUF_NORMAL_NOISE RGB Normal Map used for Image Distortion..
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );    // BUF_SCREEN_SPACE_REFLECTION   
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );    // BUF_BOKEH_2_3_RESULT   
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );    // BUF_BOKEH_2_4_RESULT   
    MyCoolEffect.AddPFXBuffer( GeneralPPX , GeneralPPY );    // BUF_MASKED_BLUR     
 
    // O.K. Buffers created..
 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Then I Add Shaders to the effect system using (much improved) "Smart Shaders" inside of the effect system..

Code: Select all

 
     MyCoolEffect.AccessThePPShaderCollection()->AddShader ("Shaders/GL_0000_VERT_PP_GENERIC.glsl",
                                                         "Shaders/GL_0010_FRAG_PP_BYPASS.glsl");  // EMMIS ONLY "OR" Image gets contrasted in prep for bloom..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S00_BYPASS)->SetVertexEntryFunctionName      ("main");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S00_BYPASS)->SetFragmentEntryFunctionName    ("main");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S00_BYPASS)->
       SetVFProfilesAndMatBaseType(EVST_VS_2_0 , EPST_PS_2_0 ,EMT_SOLID); // This Material Type could form part of an effect and sensibly remains this shader's attribute for life..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S00_BYPASS)->AddFragmentImageNameAndLayerNo  ("Image01", 0); // "Image01" is our standard naming of Samplers in ALL our shaders..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S00_BYPASS)->GenerateTheMaterialID ();
     MyCoolEffect.AccessThePPShaderCollection()->AddShader ("Shaders/GL_0000_VERT_PP_GENERIC.glsl",
                                                         "Shaders/GL_0040_FRAG_PP_H_BLUR.glsl");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S01_HBLUR)->SetVertexEntryFunctionName      ("main");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S01_HBLUR)->SetFragmentEntryFunctionName    ("main");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S01_HBLUR)->
       SetVFProfilesAndMatBaseType(EVST_VS_2_0 , EPST_PS_2_0 ,EMT_SOLID);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S01_HBLUR)->AddFragmentImageNameAndLayerNo  ("Image01", 0);
     // See why we do the bufers first (well, I thought order would become important later)..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S01_HBLUR)->AddFragmentFloatParameter ("BufferWidth",  (f32)MyCoolEffect.GetBufferWidth  (BUF_BLUR_ALTER_A));
     //MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S01_HBLUR)->AddFragmentFloatParameter ("BufferHeight", (f32)MyCoolEffect.GetBufferHeight (BUF_BLUR_ALTER_A));
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S01_HBLUR)->AddFragmentFloatParameter ("BlurParameter", (f32)3.75);
     // AND ALSO THE VERTICAL BLUR VERSION..
 
    // OTHER INTERESTING ONES..
 
     MyCoolEffect.AccessThePPShaderCollection()->AddShader ("Shaders/GL_0000_VERT_PP_GENERIC.glsl", // remember this.. _WITH_CAMERA
        //    "Shaders/GL_0320_FRAG_PP_SSAO_001_Compare_Depths_WORKS.glsl");
        //    "Shaders/GL_0320_FRAG_PP_SSAO_002_Ring_Samples_diff_luminance_WORKS.glsl"); // Cool one..
        //    "Shaders/GL_0320_FRAG_PP_SSAO_003_Jose_Larios_WORKS_BUT.glsl");
 
        //    "Shaders/GL_0320_FRAG_PP_SSAO_AAA_002_THIS_ONE_LOOKS_INTERESTING.glsl");
 
     "Shaders/GL_0320_FRAG_PP_SSAO_002_Ring_Samples_diff_luminance_WORKS.glsl"); // Hot stuff..
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->SetVertexEntryFunctionName      ("main");
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->AddFragment3Floats ("CameraPosition", CameraPosition);
 
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->SetFragmentEntryFunctionName    ("main");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->SetVFProfilesAndMatBaseType(EVST_VS_2_0 , EPST_PS_2_0 ,EMT_SOLID);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->AddFragmentImageNameAndLayerNo  ("Image01", 0); // Depth..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->AddFragmentImageNameAndLayerNo  ("Image02", 1); // Original Render..
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->AddFragmentFloatParameter ("BufferWidth",  (f32)GeneralPPX);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->AddFragmentFloatParameter ("BufferHeight", (f32)GeneralPPY);
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S19_SSAO_A_DEPTH_DIFF)->AddFragmentIntegerParameter ("OpSwitch", OpSwitchSSAO_001);
 
    // THIS ONE IS COOL (needs help from devsh)
     MyCoolEffect.AccessThePPShaderCollection()->AddShader ("Shaders/GL_0000_VERT_PP_GENERIC.glsl", // remember this.. _WITH_CAMERA
            "Shaders/GL_0310_FRAG_PP_DEFER_01_WORLD_DEPTH_NORM_SPEC.glsl");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->SetVertexEntryFunctionName      ("main");
     // MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->AddVertex3Floats ("CameraPosition", CameraPosition); // MAY BE..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->AddFragment3Floats ("CameraPosition", CameraPosition);
 
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->SetFragmentEntryFunctionName    ("main");
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->NameFragmentWORLDMatrix("M01World");
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->SetVFProfilesAndMatBaseType(EVST_VS_2_0 , EPST_PS_2_0 ,EMT_SOLID);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->AddFragmentImageNameAndLayerNo  ("Image01", 0);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S18_DEFERRED_A)->AddFragmentImageNameAndLayerNo  ("Image02", 1);
     // WHAT? THE CAMERA POSITION IN A P/P SHADER??
     // Yes.. Welcome to "Deferred Rendering/Shading"..
     // In particular the Camera Position is for Specular Calculation..
     // SEE HOW THIS VALUE IS ALSO SET CYCLICALLY IN THE MAIN LOOP!!
 
  // THIS ONE TOO!!
 
     MyCoolEffect.AccessThePPShaderCollection()->AddShader ("Shaders/GL_0000_VERT_PP_GENERIC.glsl", "Shaders/GL_0280_FRAG_PP_BOKEH_2_3.glsl");
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->SetVertexEntryFunctionName      ("main"); // SCENE RENDER..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->SetFragmentEntryFunctionName    ("main"); // 8 BIT DEPTH..
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->SetVFProfilesAndMatBaseType(EVST_VS_2_0 , EPST_PS_2_0 ,EMT_SOLID);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentImageNameAndLayerNo  ("Image01", 0);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentImageNameAndLayerNo  ("Image02", 1);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentFloatParameter ("BufferWidth",  GeneralPPX);
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentFloatParameter ("BufferHeight", GeneralPPY);
 
 
 
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentFloatParameter   ("focalDepth",  1.0 );
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentFloatParameter   ("focalLength",  1.0 );
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentFloatParameter   ("aperture",  1.0 );
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddFragmentIntegerParameter ("showFocus",  0 );
     // Remember these for HLSL!!!
     //MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddVertexFloatParameter ("BufferWidth",  (f32)MyCoolEffect.GetBufferWidth  (xxxxx));
     //MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->AddVertexFloatParameter ("BufferHeight", (f32)MyCoolEffect.GetBufferHeight (xxxxx));
     MyCoolEffect.AccessThePPShaderCollection()->AccessShader (S17_BOKEH_2_3)->GenerateTheMaterialID ();
 
 // AND A LOT MORE..
 
 // THE GEOMETRY SHADERS FOR NORMALS AND DEPTH ETC IS DONE ELSEWHERE..
 
 
 
Last edited by Vectrotek on Thu Nov 17, 2016 2:42 pm, edited 1 time in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Finally add and define the LAST PASS which RENDER TO SCREEN..
See how I comment and un-comment lines to see different final results

Code: Select all

 
   // - LAST "TO FRAME BUFFER PASS" -  "MANDATORY (no buffsize) "BYPASS SHADER" to the Frame Buffer, i.e. SCREEN..
   RunFXPASSI++;
   MyCoolEffect.AddPFXRenderPass();
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_BLUR_ALTER_A);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_BLUR_ALTER_B);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_GENERIC_ALTERNTOR_A); // BAKED SMALL AO BY SCENE..
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_GENERIC_ALTERNTOR_B); // BAKED SMALL AO BY SCENE..
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_GENERIC_ALTERNTOR_C);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_GENERIC_ALTERNTOR_D); // fxaa FROM F
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_GENERIC_ALTERNTOR_E);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_GENERIC_ALTERNTOR_F); // SSAO..
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_CLIPPED_WHITE_ON_BLACK_MASK);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_CLIPPED_BLACK_ON_WHITE_MASK);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_FRONT_F_DEPTH_RGB_ENCODED_RENDER);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_BACK_F_DEPTH_RGB_ENCODED_RENDER);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_RC_NML_AND_8_BIT_DEPTH_RENDER); //xxxxxxx
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_NORMALS_WORLD);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_NORMALS_VIEW); // "Blue" style..
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_POS_RGB);
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_URC_NORMAL); // I DONT KNOW WHY WE WOULD WANT THESE IN A BUFFER..
   //  MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_SCENE_RENDER);
   //  MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_TEST_DEFERRED_SHADING);  // Cool
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_SMALL_FOR_AO_OVERLAY);  // Cool
   // YOURE ON THE RIGHT TRACK BUT FRAGMENT POSITION OF POLYGINS FRONT ND BACK IS ACTUALLY BETTER..
   //  MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_THICKNESS);  // Cool
   MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_RC_NML_AND_8_BIT_DEPTH_RENDER);  // Cool
   //  MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_RANGE_COMPRESSED_WORLD_SPACE_POSITION);  // Cool
   //  MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_SCENE_RENDER);  // Cool
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_NORMAL_NOISE);  // Cool
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_SCREEN_SPACE_REFLECTION);  // Cool
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_BOKEH_2_3_RESULT);  // QUITE COOL BUT NEEDS UNDERSTANDING..
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_BOKEH_2_4_RESULT);  // NOT SO COOL YET..
   // MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AddSourceBuffer(BUF_PRE_BLUR_CURVED);  // NOT SO COOL YET..
 
 
   // No Target associated means this pass is the LAST RENDER TO SCREEN.. (see the 'smart' decision making process called inside the "associate()" functions..)
   MyCoolEffect.AccessPFXRenderPass(RunFXPASSI)->AssociateShader(S00_BYPASS); // OR ANY "NON BUFFSIZE SHADER" (such as MIXING SHADER)..
 
 
 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Here is only the Class Definition of the RENDER PASS:

Code: Select all

 
 
 class PFXRenderPass 
  {public:
   PFXRenderPass();    
   ~PFXRenderPass(); 
   void   AddSourceBuffer(u32 BuffIndex);     // Pass mode starts of as 0 (render from scene to buffer), no changes made..
   void   AssociateTargetBuffer(u32 BuffIndex);
   u32    GetSourceBufferIndex(u32 SourceBufferNo); // Pass mode starts of as 0 (render from scene to buffer), no changes made..
   u32    GetSourceBufferCount (); 
   u32    GetTargetBufferIndex();
   void   AssociateShader(u32 ShaderIndex);         // This logically tells us that it is either MIDDLE PASS or LAST PASS, but NOT the First Pass..
   u32    GetAssociatedShader();
   void   UpdatePassType();
   int*   GetPassGlobalAlertPointer (u32 GAPIndex);
   bool   GetPassRenderAlertFlagValue (u32 GAPIndex);
   void   SetPassUVClamp (video::E_TEXTURE_CLAMP UClamp, video::E_TEXTURE_CLAMP VClamp);
   video::E_TEXTURE_CLAMP GetPassUClamp ();
   video::E_TEXTURE_CLAMP GetPassVClamp ();
   video::SMaterial GetPassMaterial ();
   video::SMaterial* GetPassMaterialPointer ();
   int    GetGeneralPassMode ();
   u32    GetAssginedShaderIndex ();
   void   AddPassExcludedItem (ISceneNode* Node);
   u32    GetPassExcludedItemCount ();
   ISceneNode* AccessExcludedItem (u32 EII);
   // THIS 8BIT COLOUR ISSUE BETWEEN IRRLICHT AND GPU PROGRAMS NEEDS LOOKING AT..
   // WE SHOULD HAVE "FColor" and "vector4Df".. (Irrlicht 9?)..
   void   SetPassBackGroundColour( SColor Col );
   SColor GetPassBackGroundColour ();
   void   SetPassMatOverrideID (u32 OID);
   u32    GetPassMatOverrideID ();
   bool   GetPassMatOverrideStatus ();
   bool   GetPassBackFaceCullState ();
   void   SetPassBackFaceCullState (bool CullState);
   void   AddAnimatedMeshToPass (ISceneNode* Mesh);
   void   AddAnimatedSkinnedMeshToPass (IAnimatedMeshSceneNode* Mesh);
   u32    GetAnimatedMeshCount ();
   u32    GetAnimatedSkinnedMeshCount ();
   void   SetPassFragmentShaderFloatParameter (const char* ParamName, f32 InitialVal); // Of which we could have many..
   void   SetPassFragmentShader3FloatsParameter (const char* ParamName, vector3df InitialVal); // Of which we could have many..
   void   SetPassFragmentShader3FloatsParameter (const char* ParamName, f32 F1, f32 F2, f32 F3);
   void   SetPassFragmentShaderIntParameter (const char* ParamName, u32 InitialVal); 
   u32    GetPassUniqueShaderFloatParamCount ();
   u32    GetPassUniqueShader3FloatsParamCount ();
   u32    GetPassUniqueShaderIntParamCount ();
   f32    GetPassUniqueShaderFloatParamValueByIndex (u32 Index);
 
   // THIS WAS THE ISSUE WITH GETTING SHADER PARAMETER IN A FASTER WAY..
   vector3df   GetPassUniqueShader3FloatsParamValueByIndex (u32 Index);
   u32         GetPassUniqueShaderIntParamValueByIndex (u32 Index);
   const char* GetPassUniqueShaderFloatParamNameByIndex (u32 Index);
   const char* GetPassUniqueShader3FloatsParamNameByIndex (u32 Index);
   const char* GetPassUniqueShaderIntParamNameByIndex (u32 Index);
 
   // ----------------- ---- --- -- - 
 
   private:
   bool SourceBufferWasAssociated;
   bool TargetBufferWasAssociated;
   bool ShaderWasAssociated;
   u32  PassShaderAssociationIndex;
   video::E_TEXTURE_CLAMP ThePassUClamp;
   video::E_TEXTURE_CLAMP ThePassVClamp;
   // This is set depending on when Source Buffers and Target Buffers were associated..
   // PASS_MODE_SCENE   (0) = Render Scene to Buffer.. "VERY FIRST PASS".. [ONLY TARGET BUFFER WERE ASSOCIATED]
   // PASS_MODE_BETWEEN (1) = Render from Buffer to Buffer.. "PASSES IN BETWEEN FIRST AND LAST PASSES".. [SOURCE AND TARGET BUFFERS WERE ASSOCICATED]
   // PASS_MODE_LAST    (2) = Render From Buffer to Screen.. "VERY LAST PASS" [ONLY SOURCE BUFFERS WERE ASSIGNED]
   int GeneralPassMode;
   video::SMaterial ThePassMaterial; // Gets assigned shaders by "Association"..
   // video::SMaterial* ThePassMaterialPointer;
   // As we can have MORE THAN ONE SOURCE.. (Usually two, but 4, 8 or even more can be accomodated by PP Shaders)
   core::array<u32> SourceBufferIndexArray;
   u32 SourceBufferCount;
   u32 TargetBufferIndex;                       // As we can have only one Target..
   core::array<int*> AlertPointersArray; 
   core::array <ISceneNode*> PassExcludedItems;
   u32 PassExcludedItemCount;
   SColor PassBackGroundColour;
   u32  PassMatOverrideID;
   bool OverrideMaterial;
   bool PassBackFaceCullState; // default TRUE..
   core::array<ISceneNode*>             AnimatedMeshesPTRArray;
   core::array<IAnimatedMeshSceneNode*> AnimatedSkinnedMeshesPTRArray;
   u32 AnimatedMeshesCount;
   u32 AnimatedSkinnedMeshesCount;
   // Yes, the Smart Shader manager has identical members..
   core::array <core::stringc> FragmentIntParamNames;
   core::array <core::stringc> FragmentFloatParamNames;
   core::array <core::stringc> Fragment3FloatsParamNames;
   core::array <int>           FragmentIntValues;
   core::array <f32>           FragmentFloatValues;
   core::array <vector3df>           Fragment3FloatsValues;
   u32 FragmentFloatCount;
   u32 Fragment3FloatsCount;
   u32 FragmentIntCount;
 
  };
 
 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

Here is only the class definition for the EFFECT..
One EFFECT can have many Render Passes..

Code: Select all

 
 
 class PostProcessEffect 
  {public:
   PostProcessEffect();    
   ~PostProcessEffect();
   void                SetDevice (IrrlichtDevice* SetDevice);
   SmartShaderManager* AccessThePPShaderCollection();    // We'd add shaders with this..
   void                AddPFXBuffer(u32 XRes, u32 YRes); // How much do we allow in the Constructor? (colour format etc??)
   void                AddPFXBufferAsLoadedImage(stringw ImageFilename); // SPECIAL: Instead of just a buffer pre-fill it with a given image..
   void                AddPFXRenderPass();               // Assign Targets, Sources and Shaders NOT IN CONSTRUCTOR..
   PFXRenderPass*      AccessPFXRenderPass (u32 Ri);
   ITexture*           AccessTexturePTRArray (u32 TextureIndex);
   void                RenderEffectPasses();             // The knitty gritty..
   u32                 GetBufferWidth (u32 TexI);
   u32                 GetBufferHeight (u32 TexI);
   void                SetBackGroundColour (SColor Col);
   void                AddExcludedItem (ISceneNode* Node);
   void                ReferToWaterNode (RealisticWaterSceneNode*        Node);
   void                SetSceneBackGroundColourAddress ( SColor* ColPtr );
   void                AddAnimatedMesh (ISceneNode* Mesh);
   void                AddAnimatedSkinnedMesh (IAnimatedMeshSceneNode* Mesh);
   u32                 GetAnimatedMeshCount ();
   u32                 GetAnimatedSkinnedMeshCount ();
 
   private:
   IrrlichtDevice*            PassedIrrDevice;           // Just like the older PP effect class..
   video::IVideoDriver*       AquiredVideoDriver;
   scene::ISceneManager*      AquiredSceneManager;
   SmartShaderManager         ThePPShaderCollection;     // WHATS THE ISSUE? [[needed to initiate device]]..
   u32                        ImageBufferCount;
   u32                        RenderPassCount;
   core::array<ITexture*>     TextureImagesPTRArray;
   core::array<PFXRenderPass> RenderPassesArray;
   core::dimension2d <u32>    BufferDimensions; // NOT GLOBAL? (rather use in function itself..)
   video::SColor              BckGrndColour;
   video::S3DVertex           vert[4]; // Its own screenquad..
   u16 index[6];
   int*                       DepthRenderAlertPTR; // THIS MUST GO!!!
   SMaterial                  SpecialGLOBALDepthMaterial;
   video::SMaterial           SpecialZBUFFPREPMat; // Work around for some passes refusing to clear the Z buffer..
   u32                        SpecialScreenQuadMatID ;
   SmartShaderManager         InternalSmartShaderManager; // ITS VGERY OWN INTERNAL INSTANCE OF THUIS THING..
   RealisticWaterSceneNode*   TheWaterNode;  // This thing is copmplex so has to have its own place in here..
   u32                        ExcludedItemCount;
   SColor*                    SceneBackGgroundColourPointer;
   core::array<ISceneNode*>   AnimatedMeshesPTRArray;
   core::array<IAnimatedMeshSceneNode*> AnimatedSkinnedMeshesPTRArray;
   u32                        AnimatedMeshesCount;
   u32                        AnimatedSkinnedMeshesCount;
   core::array<u32>           RecoveredMaterialIDsArray;
   core::array<u32>           RecoveredSkinnedMaterialIDsArray;
  };
 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Ways to set Shader Parameters

Post by Vectrotek »

The whole thing actually works and I did break up the whole program into sensible parts (mostly headers)
so that everything is not in a single CPP file like previous posts..

The Main Program has it like this.:

Code: Select all

 
 #include "H_000_main_include.h"
 #include "H_010_Smart_Shader_Initialisation.h"
 #include "H_011_Cloud_System_Initialisation.h"
 #include "H_009_Screen_Quad_Initialisation.h"
 #include "H_012_Sun_Flare_System_Initialisation.h"
 #include "H_013_NonLinear_Effect_System_Initialisation.h"
 #include "H_014_Sound_System_Initialisation.h"
 #include "H_016_Water_System_Initialisation.h"
 #include "H_015_GUI_System_Initialisation.h"
 #include "H_008_user_input.h"
 #include "H_017_Main_App_Initialisation.h"
 
and the "H_000_main_include.h" file has it like this:

Code: Select all

 
 
 #include "H_001_ShaderManagement.h"
 #include "H_002_PostProcessor.h"
 #include "H_003_Water_Scene_Node.h"
 #include "H_004_Audio_System.h" 
 #include "H_005_CloudSceneNode.h"
 #include "H_006_LensFlareSceneNode.h"
 #include "H_007_NodeAnimFollowCam.h"
 
Post Reply