added highlighting -> bug all assets are transparent

This commit is contained in:
Cedric Beck
2024-11-21 09:56:40 +01:00
parent 56256fb9c0
commit a8a725611f
16 changed files with 22953 additions and 3607 deletions

View File

@@ -30,6 +30,7 @@ public static void main(String[] args) {
settings.setCenterWindow(true);
settings.setWidth(1280);
settings.setHeight(720);
settings.setVSync(false);
MdgaApp app = new MdgaApp();
app.setSettings(settings);
@@ -66,29 +67,27 @@ public void simpleInitApp() {
testList_1.add(UUID.randomUUID());
testList_1.add(test1_1);
testList_1.add(test0_1);
boardView.init();
boardView.addPlayer(Color.AIRFORCE, testList);
boardView.movePieceStart(test0, 0);
boardView.movePiece(test0, 0, 1);
boardView.movePiece(test0, 1, 6);
// boardView.movePieceStart(test0, 0);
// boardView.movePiece(test0, 0, 1);
// boardView.movePiece(test0, 1, 6);
// boardView.throwPiece(test0);
boardView.shieldPiece(test0);
// boardView.shieldPiece(test0);
boardView.addPlayer(Color.CYBER, testList_1);
boardView.movePieceStart(test0_1, 10);
boardView.movePiece(test0_1, 10,14);
boardView.movePiece(test0_1, 14,15);
// boardView.addPlayer(Color.CYBER, testList_1);
// boardView.movePieceStart(test0_1, 10);
// boardView.movePiece(test0_1, 10,14);
// boardView.movePiece(test0_1, 14,15);
// boardView.test(test0);
boardView.highlight(test0);
// boardView.moveHomePiece(test0, Color.AIRFORCE, 0);
// boardView.moveHomePiece(test0, 0);
// boardView.moveHomePiece(test0, Color.AIRFORCE,0);
}
@Override

View File

@@ -27,7 +27,7 @@ enum BoardAsset {
tank,
turboCard,
// world(1.2f),
world("./world_new/world_new.obj", "./world_new/world_new_diff.png", 1.2f),
world("./world_new/world_export_new.obj", "./world_new/world_new_diff.png", 1.2f),
shield_ring("./shield_ring/shield_ring.obj", null),
tree_small("./tree_small/tree_small.obj", "./tree_small/tree_small_diff.png"),
tree_big("./tree_big/tree_big.obj", "./tree_big/tree_big_diff.png");

View File

@@ -1,8 +1,10 @@
package pp.mdga.client.board;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
@@ -29,8 +31,11 @@ public class BoardHandler {
private Map<Color, List<PieceControl>> waitingPiecesMap;
private Map<UUID, Color> pieceColor;
private final Node node;
private final OutlineHandler outlineHandler;
public BoardHandler(MdgaApp app) {
assert (app != null) : "app is null";
if(app == null) throw new RuntimeException("app is null");
this.app = app;
@@ -41,14 +46,15 @@ public BoardHandler(MdgaApp app) {
this.waitingNodesMap = new HashMap<>();
this.waitingPiecesMap = new HashMap<>();
this.pieceColor = new HashMap<>();
this.node = new Node();
this.outlineHandler = new OutlineHandler(app, app.getRootNode());
initMap();
// app.getRootNode().attachChild(node);
}
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
List<AssetOnMap> inMap = addItemToMapList(colorAssetsMap, col, assetOnMap);
assert (inMap.size() <= 4) : "BoardView: to many assets for " + col;
if (inMap.size() > 4) throw new RuntimeException("to many assets for " + col);
}
private void initMap() {
@@ -97,6 +103,7 @@ private Spatial createModel(BoardAsset asset, Vector3f pos, float rot) {
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
model.setMaterial(mat);
// node.attachChild(model);
app.getRootNode().attachChild(model);
return model;
}
@@ -123,7 +130,7 @@ private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl)
private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){
List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl()));
assert(homeNodes.size() <= 4) : "BoardView: too many homeNodes for " + color;
if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
}
private float getRotationMove(Vector3f prev, Vector3f next) {
@@ -164,11 +171,11 @@ private <T, E> List<T> removeItemFromMapList(Map<E,List<T>> map, E key, T item){
//public methods****************************************************************************************************
public void addPlayer(Color color, List<UUID> uuid) {
List<AssetOnMap> playerAssets = colorAssetsMap.get(color);
assert (playerAssets != null) : "Assets for Player color are not defined";
assert (uuid.size() == playerAssets.size()) : "UUID array and playerAssets are not the same size";
if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined");
if (uuid.size() != playerAssets.size()) throw new RuntimeException("UUID array and playerAssets are not the same size");
List<NodeControl> waitNodes = waitingNodesMap.get(color);
assert(waitNodes.size() == playerAssets.size()) : "BoardHandler: waitNodes size does not match playerAssets size";
if (waitNodes.size() != playerAssets.size()) throw new RuntimeException("waitNodes size does not match playerAssets size");
for (int i = 0; i < playerAssets.size(); i++){
@@ -186,12 +193,13 @@ public void addPlayer(Color color, List<UUID> uuid) {
public void moveHomePiece(UUID uuid, int index){
Color color = pieceColor.get(uuid);
assert(color != null) : "BoardHandler: uuid is not mapped to a color";
if(color == null) throw new RuntimeException("uuid is not mapped to a color");
List<NodeControl> homeNodes = homeNodesMap.get(color);
assert(homeNodesMap.size() == 4) : "BoardView: HomeNodes for " + color + " are not defined";
if(homeNodesMap.size() != 4) throw new RuntimeException("HomeNodes for" + color + " are not properly defined");
PieceControl pieceControl = pieces.get(uuid);
NodeControl nodeControl = homeNodes.get(index);
@@ -206,7 +214,7 @@ public void moveHomePiece(UUID uuid, int index){
public void movePieceStart(UUID uuid, int nodeIndex){
Color color = pieceColor.get(uuid);
assert(color != null) : "BoardHandler: uuid is not mapped to a color";
if(color == null) throw new RuntimeException("uuid is not mapped to a color");
PieceControl pieceControl = pieces.get(uuid);
movePieceToNode(pieceControl, infield.get(nodeIndex));
@@ -220,7 +228,8 @@ public void movePiece(UUID uuid, int curIndex, int moveIndex){
public void throwPiece(UUID uuid){
Color color = pieceColor.get(uuid);
assert(color != null) : "BoardHandler: uuid is not mapped to a color";
if(color == null) throw new RuntimeException("uuid is not mapped to a color");
PieceControl pieceControl = pieces.get(uuid);
List<NodeControl> waitNodes = waitingNodesMap.get(color);
@@ -246,8 +255,8 @@ public void swapPieces(UUID piece1, UUID piece2){
PieceControl piece1_control = pieces.get(piece1);
PieceControl piece2_control = pieces.get(piece2);
assert(piece1_control != null) : "BoardHandler: swap: piece1 UUID is not valid";
assert(piece2_control != null) : "BoardHandler: swap: piece2 UUID is not valid";
if(piece1_control == null) throw new RuntimeException("piece1 UUID is not valid");
if(piece2_control == null) throw new RuntimeException("piece2 UUID is not valid");
float rot1 = piece1_control.getRotation();
float rot2 = piece2_control.getRotation();
@@ -262,20 +271,28 @@ public void swapPieces(UUID piece1, UUID piece2){
piece2_control.setLocation(pos1);
}
public void test(UUID uuid){
System.out.println((float) Math.toDegrees(Math.atan2(1,0)));
System.out.println((float) Math.toDegrees(Math.atan2(-1,0)));
System.out.println((float) Math.toDegrees(Math.atan2(0,1)));
System.out.println((float) Math.toDegrees(Math.atan2(0,-1)));
public void init(){
initMap();
}
public void shutdown(){
//TODO
//Wrapper node
System.out.println(pieces.get(uuid).getRotation());
//komische lichter
}
pieces.get(uuid).setRotation(-90);
System.out.println(pieces.get(uuid).getRotation());
//List<Pieces>
//List<NodesIndexe>
public void highlight(UUID uuid){
outlineHandler.outlineOwn(pieces.get(uuid).getSpatial());
}
public void unHighlight(UUID uuid){
outlineHandler.deOutline(pieces.get(uuid).getSpatial());
}
}

View File

@@ -0,0 +1,79 @@
package pp.mdga.client.board;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.MaterialDef;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.FrameBuffer;
public class OutlineFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/Outline.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
// System.out.println("OutlineFilter.preFrame()");
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
// material.setTexture("OutlineDepthTexture", outlinePreFilter.getDefaultPassDepthTexture());
// System.out.println("OutlineFilter.postFrame()");
}
@Override
protected Material getMaterial() {
return material;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public float getOutlineWidth() {
return outlineWidth;
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
}

View File

@@ -0,0 +1,43 @@
package pp.mdga.client.board;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import pp.mdga.client.MdgaApp;
public class OutlineHandler {
private SelectObjectOutliner outlineOwn;
private SelectObjectOutliner outlineEnemy;
private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White;
private static final ColorRGBA OUTLINE_ENEMY_COLOR = ColorRGBA.Red;
private static final int OUTLINE_THICKNESS = 4;
public OutlineHandler(MdgaApp app, Node rootNode){
FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
app.getViewPort().addProcessor(fpp);
this.outlineOwn = new SelectObjectOutliner();
this.outlineOwn.initOutliner(SelectObjectOutliner.OUTLINER_TYPE_FILTER, OUTLINE_THICKNESS, OUTLINE_OWN_COLOR, rootNode, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
// this.outlineEnemy = new SelectObjectOutliner();
// this.outlineEnemy.initOutliner(SelectObjectOutliner.OUTLINER_TYPE_FILTER, OUTLINE_THICKNESS, OUTLINE_ENEMY_COLOR, rootNode, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
}
public void outlineOwn(Spatial spatial){
this.outlineOwn.select(spatial);
}
public void outlineEnemy(Spatial spatial){
// this.outlineEnemy.select(spatial);
}
public void deOutline(Spatial spatial){
this.outlineOwn.deselect(spatial);
this.outlineEnemy.deselect(spatial);
}
}

View File

@@ -0,0 +1,67 @@
package pp.mdga.client.board;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
public class OutlinePreFilter extends Filter {
private Pass normalPass;
private RenderManager renderManager;
/**
* Creates a OutlinePreFilter
*/
public OutlinePreFilter() {
super("OutlinePreFilter");
}
@Override
protected boolean isRequiresDepthTexture() {
return true;
}
@Override
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, false);
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
}
@Override
protected Material getMaterial() {
return material;
}
public Texture getOutlineTexture() {
return normalPass.getRenderedTexture();
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "MatDefs/SelectObjectOutliner/OutlinePre.j3md");
}
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
}

View File

@@ -6,12 +6,15 @@
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
public class PieceControl extends AbstractControl {
private float rotation;
@@ -20,12 +23,15 @@ public class PieceControl extends AbstractControl {
private Spatial shieldRing;
private Node rootNode;
private Material shield_mat;
private MdgaApp app;
private static final float SHIELD_SPEED = 1f;
private static final float SHIELD_TRANSPARENCY = 0.6f;
private static final ColorRGBA SHIELD_COLOR = new ColorRGBA(0, 0.9f, 1, SHIELD_TRANSPARENCY);
private static final ColorRGBA SHIELD_SUPPRESSED_COLOR = new ColorRGBA(1f, 0.5f, 0, SHIELD_TRANSPARENCY);
private static final float SHIELD_Z = 0f;
private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.White;
private static final int OUTLINE_THICKNESS = 4;
public PieceControl(float initRotation, AssetManager assetManager, Node rootNode){
super();
@@ -34,25 +40,18 @@ public PieceControl(float initRotation, AssetManager assetManager, Node rootNode
this.shieldRing = null;
this.rootNode = rootNode;
this.shield_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
this.shield_mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
}
public float getRotation() {
return (float) Math.toDegrees(this.spatial.getLocalRotation().toAngleAxis(new Vector3f(0,0,1)));
// return rotation;
}
public void setRotation(float rot){
Quaternion quaternion = new Quaternion();
quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0,0,1));
this.spatial.setLocalRotation(quaternion);
// this.getSpatial().rotate(0, 0, (float) Math.toRadians(rot));
}
public Vector3f getLocation(){
@@ -110,4 +109,12 @@ public void suppressShield(){
assert(shieldRing != null) : "PieceControl: shieldRing is not set";
shield_mat.setColor("Color", SHIELD_SUPPRESSED_COLOR);
}
public void setMaterial(Material mat){
this.spatial.setMaterial(mat);
}
public Material getMaterial(){
return ((Geometry) this.spatial).getMaterial();
}
}

View File

@@ -0,0 +1,179 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pp.mdga.client.board;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
/**
*
* @author xxx
*/
public class SelectObjectOutliner {
private FilterPostProcessor fpp;
private RenderManager renderManager;
private AssetManager assetManager;
private Camera cam;
/**
*
*/
public static int OUTLINER_TYPE_FILTER=0;
/**
*
*/
public static int OUTLINER_TYPE_MATERIAL=1;
private Material wireMaterial;
private Node modelNode;
int outlinerType=OUTLINER_TYPE_FILTER;
private int width=5;
private ColorRGBA color=ColorRGBA.Yellow;
/**
*
*/
public SelectObjectOutliner()
{
}
/**
*
* @param type of filter: OUTLINER_TYPE_FILTER or OUTLINER_TYPE_MATERIAL
* @param width of the selection border
* @param color of the selection border
* @param modelNode direct node containing the spacial. Wil be used to add geometry in OUTLINER_TYPE_MATERIAL node.
* @param fpp - FilterPostProcessor to handle filtering
* @param renderManager
* @param assetManager
* @param cam - main cam
*/
public void initOutliner(int type, int width, ColorRGBA color, Node modelNode, FilterPostProcessor fpp, RenderManager renderManager,AssetManager assetManager, Camera cam)
{
outlinerType=type;
this.fpp=fpp;
this.renderManager=renderManager;
this.assetManager=assetManager;
this.cam=cam;
this.modelNode=modelNode;
this.width=width;
this.color=color;
if(outlinerType==OUTLINER_TYPE_MATERIAL)
{
wireMaterial= new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
wireMaterial.setColor("Color", color);//color
wireMaterial.getAdditionalRenderState().setWireframe(true); //we want wireframe
wireMaterial.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);//that's just because we add an alpha pulse to the selection later, this is not mandatory
wireMaterial.getAdditionalRenderState().setLineWidth(width); //you can play with this param to increase the line thickness
wireMaterial.getAdditionalRenderState().setPolyOffset(-3f,-3f); //this is trick one, offsetting the polygons
wireMaterial.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Front); // trick 2 we hide the front faces to not see the wireframe on top of the geom
}
}
/**
*
* @param model to be delected
*/
public void deselect(Spatial model)
{
if(outlinerType==OUTLINER_TYPE_FILTER)
hideOutlineFilterEffect(model);
else
hideOutlineMaterialEffect(model);
model.setUserData("OutlineSelected", false);
}
/**
*
* @param model to delected
*/
public void select(Spatial model)
{
if(outlinerType==OUTLINER_TYPE_FILTER)
showOutlineFilterEffect( model, width, color);
else
showOutlineMaterialEffect( model, width, color);
model.setUserData("OutlineSelected", true);
}
/**
*
* @param model
* @return
*/
public boolean isSelected(Spatial model)
{
if(model.getUserData("OutlineSelected")!=null && ((Boolean)model.getUserData("OutlineSelected"))==true)
return true;
else
return false;
}
private void hideOutlineMaterialEffect(Spatial model) {
Spatial geo= (Spatial)model.getUserData("OutlineGeo");
if (geo != null)
modelNode.detachChild(geo);
}
private void showOutlineMaterialEffect(Spatial model, int width, ColorRGBA color) {
Spatial geo=model.clone(false);
geo.setMaterial(wireMaterial);
model.setUserData("OutlineGeo", geo);
modelNode.attachChild(geo);
}
private void hideOutlineFilterEffect(Spatial model) {
OutlineFilter outlineFilter = model.getUserData("OutlineFilter");
if (outlineFilter != null) {
outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false);
}
}
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
Filter outlineFilter = model.getUserData("OutlineFilter");
OutlinePreFilter outlinePreFilter;
if (outlineFilter == null) {
ViewPort outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlinefpp = new FilterPostProcessor(assetManager);
outlinePreFilter = new OutlinePreFilter();
outlinefpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlinefpp);
//
outlineFilter = new OutlineFilter(outlinePreFilter);
((OutlineFilter)outlineFilter).setOutlineColor(color);
((OutlineFilter)outlineFilter).setOutlineWidth(width);
model.setUserData("OutlineFilter", outlineFilter);
fpp.addFilter(outlineFilter);
} else {
outlineFilter.setEnabled(true);
//
((OutlineFilter)outlineFilter).getOutlinePreFilter().setEnabled(true);
}
}
}

View File

@@ -1,5 +1,5 @@
package pp.mdga.client.gui;
public class GuiView {
public class GuiHandler {
}

View File

@@ -0,0 +1,29 @@
uniform sampler2D m_Texture;
uniform sampler2D m_OutlineDepthTexture;
uniform sampler2D m_DepthTexture;
varying vec2 texCoord;
uniform vec2 m_Resolution;
uniform vec4 m_OutlineColor;
uniform float m_OutlineWidth;
void main() {
vec4 depth = texture2D(m_OutlineDepthTexture, texCoord);
vec4 depth1 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,m_OutlineWidth))/m_Resolution);
vec4 depth2 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
vec4 depth3 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,m_OutlineWidth))/m_Resolution);
vec4 depth4 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
vec4 depth5 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,m_OutlineWidth))/m_Resolution);
vec4 depth6 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-m_OutlineWidth))/m_Resolution);
vec4 depth7 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,0.))/m_Resolution);
vec4 depth8 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,0.))/m_Resolution);
vec4 color = texture2D(m_Texture, texCoord);
//如果是背景
if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){
gl_FragColor = m_OutlineColor;
}else{
gl_FragColor = color;
}
//debug
//gl_FragColor = vec4(0.,(1.-ratio),0.,1.);
}

View File

@@ -0,0 +1,21 @@
MaterialDef Cartoon Edge {
MaterialParameters {
Int NumSamples
Int NumSamplesDepth
Texture2D Texture
Texture2D OutlineDepthTexture
Texture2D DepthTexture
Vector2 Resolution
Color OutlineColor
Float OutlineWidth
}
Technique {
VertexShader GLSL100: MatDefs/SelectObjectOutliner/Post15.vert
FragmentShader GLSL100: MatDefs/SelectObjectOutliner/Outline.frag
WorldParameters {
}
}
}

View File

@@ -0,0 +1,10 @@
varying vec2 texCoord;
uniform sampler2D m_Texture;
uniform sampler2D m_NormalsTexture;
uniform sampler2D m_DepthTexture;
void main(){
vec4 color = texture2D(m_Texture, texCoord);
gl_FragColor=color;
}

View File

@@ -0,0 +1,28 @@
MaterialDef Cartoon Edge {
MaterialParameters {
Int NumSamples
Int NumSamplesDepth
Texture2D Texture
Texture2D NormalsTexture
Texture2D DepthTexture
}
Technique {
VertexShader GLSL150: MatDefs/SelectObjectOutliner/Post15.vert
FragmentShader GLSL150: MatDefs/SelectObjectOutliner/OutlinePre.frag
WorldParameters {
}
}
Technique {
VertexShader GLSL100: Common/MatDefs/Post/Post.vert
FragmentShader GLSL100: Shaders/outline/OutlinePre.frag
WorldParameters {
}
}
}

View File

@@ -0,0 +1,10 @@
in vec4 inPosition;
in vec2 inTexCoord;
out vec2 texCoord;
void main() {
vec2 pos = inPosition.xy * 2.0 - 1.0;
gl_Position = vec4(pos, 0.0, 1.0);
texCoord = inTexCoord;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff