Skip to content

Commit

Permalink
try add refract and depth buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Jun 8, 2024
1 parent db7aa9a commit e19a747
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 28 deletions.
184 changes: 182 additions & 2 deletions data/Compositors/SR3.compositor
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ abstract target cubemap_target

visibility_mask 0x0000042D // 1 rd 4 ter 8 vgt 20 obj 400 sky
// visibility_mask 0x0000046D // + 40 grass
rq_last 199

overlays off
camera_cubemap_reorient true
Expand Down Expand Up @@ -270,13 +271,191 @@ compositor_node CubemapNodeMsaa


//------------------------------------------------------------------------------------
// 🏞️ [Main render] (👥 split screens too and 🏗️ ed)
// 🏞️ [Main render] (👥 split screens too and 🏗️ ed) NEW Refract
//------------------------------------------------------------------------------------
abstract compositor_node SR3_RenderAbs
{
in 0 rt_renderwindow
in 1 dynamic_cubemap

texture depthBuffer target_width target_height PFG_D32_FLOAT
texture rtt01 target_width target_height target_format
texture rtt_final target_width target_height target_format

rtv rtt01
{
depth_stencil depthBuffer
}
rtv rtt_final
{
depth_stencil depthBuffer
}

target rtt01
{
// pass clear // --------
// {
// profiling_id "Clear all"
// identifier 22000

// // executed on first view/eye
// execution_mask 0x01
// // affected by modifier, apply to the whole screen
// viewport_modifier_mask 0x00

// // Only write to MSAA surface, don't resolve, overlays legacy problem
// store
// {
// colour store
// depth store
// stencil store
// }
// colour_value 0.02 0.015 0.03 1
// }

// [Main Render] --------
pass render_scene
{
profiling_id "Main view"
identifier 22202

// executed in all views/eyes
execution_mask 0xff
// affected by modifier, so renders to a portion of screen
viewport_modifier_mask 0xff

load
{
all clear
// clear_depth 1.0
clear_colour 0.2 0.4 0.6 1
}
store
{
colour store_or_resolve
depth store
stencil dont_care
}

// materials in this pass will be using this cubemap
expose dynamic_cubemap

// visibility_mask 0x000011FF // set later RV_MaskGameAll
// visibility_mask 0x00000001 // set later RV_MaskGameAll
visibility_mask 0x000011FD // set later RV_MaskGameAll
// rq_last 110 // glass,par etc
rq_last 209

overlays off
// shadows SR3_Shadows //** added in code
}


// for Hud, split --------
pass render_scene
{
profiling_id "HUD"
identifier 22501

// executed in all eyes, not views
// execution_mask 0xff
// executed on first view/eye
execution_mask 0x01
// affected by modifier, apply to the whole screen
viewport_modifier_mask 0x00

store
{
colour store
depth store //-
stencil store
}
visibility_mask 0x00002000 // RV_Hud

rq_first 225
rq_last 230

overlays off
}

//** added in code --------
// pass custom MYGUI
// {
// provider?
// profiling_id "GUI"

// executed in the second eye
// execution_mask 0x02
// apply to the whole screen
// viewport_modifier_mask 0x00

// rq_first 254
// rq_last 255

// overlays on
// }
}

target rtt_final
{
pass render_quad
{
// Only colour must be dont_care, since we must still preserve the depth buffer's contents!
load { colour dont_care }
material Ogre/Copy/4xFP32
input 0 rtt01
}

// Pass with refractive objects
pass render_scene
{
load
{
all load
}
store
{
colour store_or_resolve
depth dont_care
stencil dont_care
}

// ?
// expose demo_dynamic_cubemap
// identifier 22201
// identifier 25001

visibility_mask 0x01000000
// visibility_mask 0x00000002
rq_first 210
rq_last 211

overlays on
//shadows Tutorial_TerrainShadowNode reuse
use_refractions depthBuffer rtt01
}
}

target rt_renderwindow
{
// Output to window
pass render_quad
{
load { all dont_care }
material Ogre/Copy/4xFP32
input 0 rtt_final
}
}
}


// 🏞️ [Main render] OLD no refract
//------------------------------------------------------------------------------------
abstract compositor_node SR3_RenderAbsOld
{
in 0 rt_renderwindow
in 1 dynamic_cubemap

target rt_renderwindow
{
pass clear // --------
Expand Down Expand Up @@ -348,7 +527,7 @@ abstract compositor_node SR3_RenderAbs
}
visibility_mask 0x00002000 // RV_Hud

rq_first 200
rq_first 221 //200
rq_last 230

overlays off
Expand Down Expand Up @@ -400,6 +579,7 @@ compositor_node PlanarReflectNode
}

visibility_mask 0x0000022D // 1 rd 4 ter 8 vgt 20 obj 200 sky
rq_last 209
overlays off
//shadows SR3_Shadows // no-
}
Expand Down
13 changes: 10 additions & 3 deletions data/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,11 @@


//-----------------------------------------------------------------------------
// BODY CODE
// BODY CODE //** This is Pbs
//-----------------------------------------------------------------------------
@property( hlms_shadowcaster )
// BODY CODE //** This is Shadow !
@end

@piece( LoadMaterial )
@property( !lower_gpu_overhead )
Expand Down Expand Up @@ -404,7 +407,7 @@


@property( (water || river) && !hlms_shadowcaster )
//~~~~~~~ water begin
//~~~~~~~ water begin //** This is Water

@piece( GetNorm )
getTSNormal( textureMaps@value( normal_map_tex_idx ),
Expand Down Expand Up @@ -889,6 +892,7 @@ uv3 = UV * WAVE_SCALE*2.0 + WIND_DIR *timer* WIND_SPEED*0.7 -(normal4.xy/normal4
@end

@property( paint )
//** This is Paint
//---- clr3 mix color changing paints ***
if (material.userValue[0].w > _h( 0.0 )) // all black
{
Expand Down Expand Up @@ -1022,7 +1026,10 @@ uv3 = UV * WAVE_SCALE*2.0 + WIND_DIR *timer* WIND_SPEED*0.7 -(normal4.xy/normal4
@insertpiece( BRDF_EnvMap )
@end

@insertpiece( applyRefractions )
@property( !hlms_shadowcaster && !paint && !grass && !sky )
//** applyRefractions **
@insertpiece( applyRefractions )
@end


//** ed Selected Glow **
Expand Down
2 changes: 2 additions & 0 deletions data/Hlms/Pbs/Any/Refractions_piece_ps.any
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@end

@piece( applyRefractions )
@property( !hlms_shadowcaster )
@property( !fresnel_scalar )
midf refractF0 = pixelData.F0;
@else
Expand Down Expand Up @@ -61,3 +62,4 @@
finalColour += refractionCol.xyz * (_h( 1.0 ) - refractionAlpha);
@end
@end
@end
2 changes: 1 addition & 1 deletion data/Hlms/Terra/Any/800.PixelShader_piece_ps.any
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@end

//-----------------------------------------------------------------------------
// BODY CODE
// BODY CODE //** This is Terra
//-----------------------------------------------------------------------------

@undefpiece( UnpackTextureIndices0 )
Expand Down
84 changes: 73 additions & 11 deletions data/materials/Pbs/all.material.json
Original file line number Diff line number Diff line change
Expand Up @@ -17990,16 +17990,84 @@
}
},

"WaterBlue":
{
"shadow_const_bias" : 0.01,
"workflow" : "specular_ogre",
"transparency" :
{
"value" : 0.15,
"mode" : "Refractive",
"use_alpha_from_textures" : true
},
"diffuse" :
{
"value" : [0.026, 0.037, 0.057],
"background" : [1, 1, 1, 1],
"sampler" : "wrap"
},
"specular" :
{
"value" : [0.5, 0.55, 0.59],
"sampler" : "wrap"
},
"fresnel" :
{
"value" : 0.4,
"mode" : "coeff"
},
"normal" :
{
"value" : 0.5,
"texture" : "mntn_black_n.jpg",
"sampler" : "wrap"
},
"roughness" :
{
"value" : 0.25,
"sampler" : "wrap"
},

"detail_diffuse0" :
{
"value" : 1,
"offset" : [0.15, 0.1],
"scale" : [0.3, 0.15],
"sampler" : "wrap"
},
"detail_diffuse1" :
{
"value" : 1,
"offset" : [0.3, 0.3],
"sampler" : "wrap"
},
"detail_diffuse2" :
{
"value" : 1,
"offset" : [1, 0.15],
"scale" : [25, 1.5],
"sampler" : "wrap"
},
"detail_diffuse3" :
{
"value" : 1,
"offset" : [6, 0.4],
"sampler" : "wrap"
}
},

"Water_cyan" :
{
"macroblock" : "Macroblock_0",
"macroblock" : "Macroblock_2",
"blendblock" : "Blendblock_2",
"shadow_const_bias" : 0.01,
"workflow" : "specular_ogre",
"fluid" : true,
"refraction_strength" : 0.9,
"transparency" :
{
"value" : 0.9061712,
"mode" : "Transparent",
"value" : 0.8061712,
"mode" : "Refractive",
"use_alpha_from_textures" : true
},
"diffuse" :
Expand All @@ -18015,8 +18083,8 @@
},
"fresnel" :
{
"value" : [0.23471282, 0.3, 0.3],
"mode" : "coloured"
"value" : 0.2,
"mode" : "coeff"
},
"normal" :
{
Expand Down Expand Up @@ -21726,12 +21794,6 @@
"shadow_const_bias" : 0.01,
"workflow" : "specular_ogre",
"receive_shadows" : false,
"transparency" :
{
"value" : 0.9,
"mode" : "Transparent",
"use_alpha_from_textures" : true
},
"diffuse" :
{
"value" : [0.2, 0.7, 0.1],
Expand Down

0 comments on commit e19a747

Please sign in to comment.